From 05fafff31714bead51f33bfbe099db9815b437f4 Mon Sep 17 00:00:00 2001 From: jacobtoppm Date: Thu, 19 Mar 2020 16:33:25 +0000 Subject: [PATCH] Changes to make subclassing notifications for Wagtail Review simpler --- wagtail/admin/mail.py | 9 +++++---- .../admin/templates/wagtailadmin/notifications/base.html | 8 ++++++-- .../admin/templates/wagtailadmin/notifications/base.txt | 3 ++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/wagtail/admin/mail.py b/wagtail/admin/mail.py index e66c148fd0..f255fc638e 100644 --- a/wagtail/admin/mail.py +++ b/wagtail/admin/mail.py @@ -139,6 +139,7 @@ class Notifier: notifications using rendered templates. """ notification = '' + template_directory = 'wagtailadmin/notifications/' def __init__(self, valid_classes): # the classes of the calling instance that the notifier can handle @@ -162,7 +163,7 @@ class Notifier: """Return a dictionary of template paths for the templates: by default, a text message""" template_base = self.get_template_base_prefix(instance) + self.notification - template_text = 'wagtailadmin/notifications/' + template_base + '.txt' + template_text = self.template_directory + template_base + '.txt' return { 'text': template_text, @@ -213,9 +214,9 @@ class EmailNotifier(Notifier): alternatives""" template_base = self.get_template_base_prefix(instance) + self.notification - template_subject = 'wagtailadmin/notifications/' + template_base + '_subject.txt' - template_text = 'wagtailadmin/notifications/' + template_base + '.txt' - template_html = 'wagtailadmin/notifications/' + template_base + '.html' + template_subject = self.template_directory + template_base + '_subject.txt' + template_text = self.template_directory + template_base + '.txt' + template_html = self.template_directory + template_base + '.html' return { 'subject': template_subject, diff --git a/wagtail/admin/templates/wagtailadmin/notifications/base.html b/wagtail/admin/templates/wagtailadmin/notifications/base.html index 8b83d98cbb..bae4881f2e 100644 --- a/wagtail/admin/templates/wagtailadmin/notifications/base.html +++ b/wagtail/admin/templates/wagtailadmin/notifications/base.html @@ -113,8 +113,12 @@ body[yahoo] .text { {% block content %} {% endblock %} - -
{% trans "Edit your notification preferences here:" %} {{ settings.BASE_URL }}{% url 'wagtailadmin_account_notification_preferences' %}
+ +
+ {% block preferences %} + {% trans "Edit your notification preferences here:" %} {{ settings.BASE_URL }}{% url 'wagtailadmin_account_notification_preferences' %} + {% endblock %} +
diff --git a/wagtail/admin/templates/wagtailadmin/notifications/base.txt b/wagtail/admin/templates/wagtailadmin/notifications/base.txt index 3dbdb70bc1..a4e132e9b8 100644 --- a/wagtail/admin/templates/wagtailadmin/notifications/base.txt +++ b/wagtail/admin/templates/wagtailadmin/notifications/base.txt @@ -7,5 +7,6 @@ {% block content %} {% endblock %} - +{% block preferences %} {% trans "Edit your notification preferences here:" %} {{ settings.BASE_URL }}{% url 'wagtailadmin_account_notification_preferences' %} +{% endblock %} \ No newline at end of file