from django.dispatch import receiver from django.urls import resolve, reverse from django.utils.translation import ugettext_lazy as _ from pretix.base.signals import (register_mail_placeholders, register_ticket_outputs) from pretix.base.email import SimpleFunctionalMailTextPlaceholder from pretix.control.signals import nav_event_settings @receiver(register_mail_placeholders, dispatch_uid="pretix_digital_items_mail_placeholder") def register_mail_secrets(sender, **kwargs): token_mail_format = "{name}: {secret}" if sender.settings.digitalitems_token_mail_format: token_mail_format = sender.settings.digitalitems_token_mail_format return SimpleFunctionalMailTextPlaceholder('secrets', ['order'], lambda order: '\n' + '\n\n'.join(token_mail_format.format(secret = position.secret, name = str(position.item.name)) for position in order.positions.all() if position.item.admission), '\nej7f73xs8vfmwvkk2p73yeve4fueq849\n\np8yct9752a897rpsmqzf7beby34a2w25\n\nwwqxtw6guy5s8c5tdarfhyez2ft2juap') @receiver(register_ticket_outputs, dispatch_uid="pretix_digital_items_ticket_output") def register_ticket_outputs(sender, **kwargs): from .textticketoutput import TextTicketOutput return TextTicketOutput @receiver(nav_event_settings, dispatch_uid='pretix_digital_items_nav_settings') def navbar_settings(sender, request, **kwargs): url = resolve(request.path_info) return [{ 'label': _('Digital Items'), 'url': reverse('plugins:pretix_digital_items:settings', kwargs={ 'event': request.event.slug, 'organizer': request.organizer.slug, }), 'active': url.namespace == 'plugins:pretix_digital_items' and url.url_name == 'settings', }]