diff --git a/indico/modules/events/models/events.py b/indico/modules/events/models/events.py index b4883f41009..dc6de655b0d 100644 --- a/indico/modules/events/models/events.py +++ b/indico/modules/events/models/events.py @@ -1148,6 +1148,11 @@ def force_event_locale(self, user=None, *, allow_session=False): with force_locale(locale): yield + def has_receipt_templates(self): + """Check if the event has any receipt document templates.""" + from indico.modules.receipts.util import has_any_templates + return has_any_templates(self) + Event.register_location_events() Event.register_protection_events() diff --git a/indico/modules/events/registration/models/forms.py b/indico/modules/events/registration/models/forms.py index b6e4374d245..5c0163964d8 100644 --- a/indico/modules/events/registration/models/forms.py +++ b/indico/modules/events/registration/models/forms.py @@ -600,11 +600,6 @@ def log(self, *args, **kwargs): """Log with prefilled metadata for the regform.""" return self.event.log(*args, meta={'registration_form_id': self.id}, **kwargs) - def has_templates(self): - """Check if event has templates for the documents.""" - from indico.modules.receipts.util import has_any_templates - return has_any_templates(self.event) - @listens_for(orm.mapper, 'after_configured', once=True) def _mappers_configured(): diff --git a/indico/modules/events/registration/templates/display/_registration_summary_blocks.html b/indico/modules/events/registration/templates/display/_registration_summary_blocks.html index 5f1bc8cde12..dec13b15d28 100644 --- a/indico/modules/events/registration/templates/display/_registration_summary_blocks.html +++ b/indico/modules/events/registration/templates/display/_registration_summary_blocks.html @@ -143,7 +143,7 @@ {% macro render_receipts_list(registration, from_management=false) %} {% set receipts = registration.receipt_files if from_management else registration.published_receipts %} - {% set can_get_document = from_management and registration.registration_form.has_templates() %} + {% set can_get_document = from_management and registration.event.has_receipt_templates() %} {% if receipts or can_get_document %}
diff --git a/indico/modules/receipts/__init__.py b/indico/modules/receipts/__init__.py index 640ed162787..d0f0b881fd2 100644 --- a/indico/modules/receipts/__init__.py +++ b/indico/modules/receipts/__init__.py @@ -9,7 +9,7 @@ from indico.core import signals from indico.modules.events.registration.util import ActionMenuEntry -from indico.modules.receipts.util import can_user_manage_receipt_templates, has_any_receipts, has_any_templates +from indico.modules.receipts.util import can_user_manage_receipt_templates, has_any_receipts from indico.util.i18n import _ from indico.web.flask.util import url_for from indico.web.menu import SideMenuItem @@ -38,7 +38,7 @@ def _category_sidemenu_items(sender, category, **kwargs): @signals.event.registrant_list_action_menu.connect def _get_action_menu_items(regform, **kwargs): - has_templates = has_any_templates(regform.event) + has_templates = regform.event.has_receipt_templates() if has_templates: yield ActionMenuEntry( _('Generate Documents'),