I am trying to remove the “withdraw” button from registration forms, when the registration is waiting for an approval. The button on the right in the image:
I have found that the necessary template is located under /indico/modules/events/registration/templates/display/registration_summary.html and if I remove the block starting in line 77:
{% if registration.can_be_withdrawn %}
<button class="i-button icon-exit"
data-href="{{ url_for('.withdraw_registration', registration.locator.registrant) }}"
data-method="POST"
data-title="{% trans %}Withdraw{% endtrans %}"
data-confirm="{% trans %}Are you sure that you want to withdraw your registration? This action cannot be undone.{% endtrans %}">
{% trans %}Withdraw{% endtrans %}
</button>
{% else %}
<button class="i-button icon-exit disabled"
title="{% trans %}The registration can no longer be withdrawn. Please contact an organizer.{% endtrans %}">
{% trans %}Withdraw{% endtrans %}
</button>
{% endif %}
It works! But I am not sure how to do this from plugin side. I copied the whole template, but it under my_plugin/templates/events/registration/display/registration_summary.html and removed that specific block, and try to override the existing template via:
# Template overrides
self.connect(signals.plugin.get_template_customization_paths, self._get_tpl_overrides)
def _get_tpl_overrides(self, sender, **kwargs):
# 2. Return the absolute path to your plugin's 'templates' folder
return os.path.join(self.root_path, "templates")
But doesn’t seem to work. My question:
Is this the way to go, and if it is, where am I doing wrong?
Is there a better way to tackle this?
I am using Indico 3.3.8 at the moment in my development setup, if that helps. Thanks!
This is not something you can do in an easy and clean way from a plugin. Template customizations won’t work because you’d have to replace huge parts of the original template (so upstream changes to that template would no longer be used if you override the whole thing), and the alternative would be to monkeypatch Registration’s can_be_withdrawn method which would be fairly safe, but nonetheless ugly!
But… Disabling modifications in the registration form settings is enough, no development needed for that
@property
def can_be_withdrawn(self):
from indico.modules.events.registration.models.forms import ModificationMode
if not self.is_active:
return False
elif self.is_paid:
return False
elif self.event.end_dt < now_utc():
return False
elif self.registration_form.modification_mode == ModificationMode.not_allowed:
return False
elif self.registration_form.modification_end_dt and self.registration_form.modification_end_dt < now_utc():
return False
else:
return True
PS: Just out of curiosity, why do you want to disallow withdrawing registrations?
Ohhh I see! Your suggestion is to set modification_mode to not_allowed during the registration form creation? So hook into signals.event.registration_form_created.connect and change the mode, right?
This loses me the “Modify” button, too though from what I understand. We might like to keep it, and just disable “Withdraw” button. Now that I think about it, may I hook into signals.event.registration_created and do a change there somehow?
To answer your question, basically the reason is the internal company process for applications. From what I understand, there are certain processes outside of Indico that just gets complicated if users can freely withdraw and reapply. I don’t have full knowledge of the process, I am just on the developing side of requests
But this also disables “Modify” button. I am wondering if I can somehow just remove/disable “Withdraw” button. If there isn’t an easy/clean way, I will probably settle for this though
I will make sure to relay this info, and also try to understand Indico better myself too. Thanks!