Sendmail: Abstract away to allow more types of recipients (#2994)

Co-authored-by: Richard Schreiber <schreiber@rami.io>
This commit is contained in:
Raphael Michel
2023-01-10 12:03:50 +01:00
committed by GitHub
parent d07948613a
commit 9b1d7cc522
17 changed files with 780 additions and 284 deletions

View File

@@ -48,10 +48,11 @@ from django_scopes import scope, scopes_disabled
from pretix.base.models import SubEvent
from pretix.base.signals import (
event_copy_data, logentry_display, periodic_task,
EventPluginSignal, event_copy_data, logentry_display, periodic_task,
)
from pretix.control.signals import nav_event
from pretix.plugins.sendmail.models import ScheduledMail
from pretix.plugins.sendmail.views import OrderSendView, WaitinglistSendView
logger = logging.getLogger(__name__)
@@ -91,7 +92,7 @@ def control_nav_import(sender, request=None, **kwargs):
'event': request.event.slug,
'organizer': request.event.organizer.slug,
}),
'active': (url.namespace == 'plugins:sendmail' and url.url_name == 'send'),
'active': (url.namespace == 'plugins:sendmail' and url.url_name.startswith('send')),
},
{
'label': _('Automated emails'),
@@ -117,7 +118,8 @@ def control_nav_import(sender, request=None, **kwargs):
@receiver(signal=logentry_display)
def pretixcontrol_logentry_display(sender, logentry, **kwargs):
plains = {
'pretix.plugins.sendmail.sent': _('Email was sent'),
'pretix.plugins.sendmail.sent': _('Mass email was sent to customers or attendees.'),
'pretix.plugins.sendmail.sent.waitinglist': _('Mass email was sent to waiting list entries.'),
'pretix.plugins.sendmail.order.email.sent': _('The order received a mass email.'),
'pretix.plugins.sendmail.order.email.sent.attendee': _('A ticket holder of this order received a mass email.'),
'pretix.plugins.sendmail.rule.added': _('An email rule was created'),
@@ -219,3 +221,17 @@ def sendmail_copy_data_receiver(sender, other, item_map, **kwargs):
r.save()
if limit_products:
r.limit_products.add(*[item_map[p.id] for p in limit_products if p.id in item_map])
sendmail_view_classes = EventPluginSignal()
"""
This signal allows you to register subclasses of ``pretix.plugins.sendmail.views.BaseSenderView`` that should be
discovered by this plugin.
As with all plugin signals, the ``sender`` keyword will contain the event.
"""
@receiver(signal=sendmail_view_classes, dispatch_uid="sendmail_register_sendmail_view_classes")
def register_view_classes(sender, **kwargs):
return [OrderSendView, WaitinglistSendView]