From 2fd2041ac266b287c5053187c29efb8399322150 Mon Sep 17 00:00:00 2001 From: Tom Teichler <tom.teichler@teckids.org> Date: Fri, 4 Mar 2022 22:52:16 +0100 Subject: [PATCH] Allow to configure email notification recipient for events --- CHANGELOG.rst | 8 ++++++++ aleksis/apps/paweljong/models.py | 6 +++++- aleksis/apps/paweljong/preferences.py | 22 ++++++++++++++++++++++ aleksis/apps/paweljong/views.py | 3 ++- 4 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 aleksis/apps/paweljong/preferences.py diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 7cd01b0..cc14961 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,14 @@ All notable changes to this project will be documented in this file. The format is based on `Keep a Changelog`_, and this project adheres to `Semantic Versioning`_. +Unreleased +---------- + +Added +~~~~~ + +* Allow to configure email notification recipient for events + `1.3.2`_ -------- diff --git a/aleksis/apps/paweljong/models.py b/aleksis/apps/paweljong/models.py index 1cd8038..976b744 100644 --- a/aleksis/apps/paweljong/models.py +++ b/aleksis/apps/paweljong/models.py @@ -108,7 +108,11 @@ class Event(ExtensibleModel): information = RichTextField(verbose_name=_("Information about the event")) terms = models.ManyToManyField(Terms, verbose_name=_("Terms"), related_name="event", blank=True) info_mailings = models.ManyToManyField( - InfoMailing, verbose_name=_("Info mailings"), related_name="events", through="EventInfoMailingThrough", blank=True + InfoMailing, + verbose_name=_("Info mailings"), + related_name="events", + through="EventInfoMailingThrough", + blank=True, ) def save(self, *args, **kwargs): diff --git a/aleksis/apps/paweljong/preferences.py b/aleksis/apps/paweljong/preferences.py new file mode 100644 index 0000000..a3a9a2c --- /dev/null +++ b/aleksis/apps/paweljong/preferences.py @@ -0,0 +1,22 @@ +from django.conf import settings +from django.forms import EmailField +from django.utils.translation import gettext_lazy as _ + +from dynamic_preferences.preferences import Section +from dynamic_preferences.types import StringPreference + +from aleksis.core.registries import site_preferences_registry + +paweljong = Section("paweljong", verbose_name=_("Paweljong")) + + +@site_preferences_registry.register +class EventNotificationRecipient(StringPreference): + """Mail recipient for event nofications (e.g. registrations).""" + + section = paweljong + name = "event_notification_recipient" + default = settings.ADMINS[0][1] + verbose_name = _("Mail recipient for event notifications") + field_class = EmailField + required = True diff --git a/aleksis/apps/paweljong/views.py b/aleksis/apps/paweljong/views.py index efe2fee..429f4c1 100644 --- a/aleksis/apps/paweljong/views.py +++ b/aleksis/apps/paweljong/views.py @@ -651,12 +651,13 @@ class RegisterEventWizardView(SessionWizardView): send_templated_mail( template_name="event_registered", from_email=get_site_preferences()["mail__address"], - recipient_list=["orga@teckids.org"], + recipient_list=get_site_prefenreces()["paweljong__event_notification_recipient"], headers={ "reply_to": [ person.email, person.guardians.first().email, ], + "X-Zammad-Customer-Email": person.email, }, context=context, ) -- GitLab