diff --git a/doc/development/api/general.rst b/doc/development/api/general.rst index d28dec0014..80bddcba35 100644 --- a/doc/development/api/general.rst +++ b/doc/development/api/general.rst @@ -26,7 +26,7 @@ Frontend -------- .. automodule:: pretix.presale.signals - :members: html_head, html_footer, footer_link, front_page_top, front_page_bottom, fee_calculation_for_cart, contact_form_fields, question_form_fields, checkout_confirm_messages, checkout_confirm_page_content, checkout_all_optional, html_page_header, sass_preamble, sass_postamble, render_seating_plan, checkout_flow_steps, position_info + :members: html_head, html_footer, footer_link, front_page_top, front_page_bottom, fee_calculation_for_cart, contact_form_fields, question_form_fields, checkout_confirm_messages, checkout_confirm_page_content, checkout_all_optional, html_page_header, sass_preamble, sass_postamble, render_seating_plan, checkout_flow_steps, position_info, item_description .. automodule:: pretix.presale.signals diff --git a/src/pretix/presale/signals.py b/src/pretix/presale/signals.py index 95b2162740..08a37838a3 100644 --- a/src/pretix/presale/signals.py +++ b/src/pretix/presale/signals.py @@ -256,3 +256,12 @@ invoice address, confirmations) will be optional, except for questions. Use with As with all plugin signals, the ``sender`` keyword argument will contain the event. A ``request`` argument will contain the request object. """ + +item_description = EventPluginSignal( + providing_args=["item", "variation"] +) +""" +This signal is sent out when the description of an item or variation is rendered and allows you to append +additional text to the description. You are passed the ``item`` and ``variation`` and expected to return +HTML. +""" diff --git a/src/pretix/presale/views/event.py b/src/pretix/presale/views/event.py index c788e8f7db..467c77354a 100644 --- a/src/pretix/presale/views/event.py +++ b/src/pretix/presale/views/event.py @@ -22,6 +22,7 @@ from pretix.base.models.event import SubEvent from pretix.base.models.items import ItemBundle from pretix.multidomain.urlreverse import eventreverse from pretix.presale.ical import get_ical +from pretix.presale.signals import item_description from pretix.presale.views.organizer import ( EventListMixin, add_subevents_for_days, filter_qs_by_attr, weeks_for_template, @@ -126,6 +127,11 @@ def get_grouped_items(event, subevent=None, voucher=None, channel='web', require item._remove = True continue + item.description = str(item.description) + for recv, resp in item_description.send(sender=event, item=item, variation=None): + if resp: + item.description += ("
" if item.description else "") + resp + if not item.has_variations: item._remove = False if not bool(item._subevent_quotas): @@ -171,6 +177,11 @@ def get_grouped_items(event, subevent=None, voucher=None, channel='web', require display_add_to_cart = display_add_to_cart or item.order_max > 0 else: for var in item.available_variations: + var.description = str(var.description) + for recv, resp in item_description.send(sender=event, item=item, variation=var): + if resp: + var.description += ("
" if var.description else "") + resp + if voucher and (voucher.allow_ignore_quota or voucher.block_quota): var.cached_availability = ( Quota.AVAILABILITY_OK, voucher.max_usages - voucher.redeemed