Skip to content

Commit

Permalink
Improve has_templates check
Browse files Browse the repository at this point in the history
  • Loading branch information
ThiefMaster committed Jun 14, 2024
1 parent 1c5df53 commit 144349b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
5 changes: 5 additions & 0 deletions indico/modules/events/models/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 0 additions & 5 deletions indico/modules/events/registration/models/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
<div class="regform-done">
Expand Down
4 changes: 2 additions & 2 deletions indico/modules/receipts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'),
Expand Down

0 comments on commit 144349b

Please sign in to comment.