Basic email template for notifications #96
@ -96,7 +96,7 @@ class EmailPreviewAdmin(NoAddDeleteMixin, EmailAdmin):
|
|||||||
def get_object(self, request, object_id, from_field=None, fake_context=None):
|
def get_object(self, request, object_id, from_field=None, fake_context=None):
|
||||||
"""Construct the Email on the fly from known email templates."""
|
"""Construct the Email on the fly from known email templates."""
|
||||||
if not fake_context:
|
if not fake_context:
|
||||||
fake_context = self._get_fake_context(request)
|
fake_context = self._get_emails_with_fake_context(request)
|
||||||
context = fake_context[object_id]
|
context = fake_context[object_id]
|
||||||
mail_name = context.get('template', object_id)
|
mail_name = context.get('template', object_id)
|
||||||
email_body_html, email_body_txt, subject = construct_email(mail_name, context)
|
email_body_html, email_body_txt, subject = construct_email(mail_name, context)
|
||||||
@ -109,21 +109,21 @@ class EmailPreviewAdmin(NoAddDeleteMixin, EmailAdmin):
|
|||||||
message=email_body_txt,
|
message=email_body_txt,
|
||||||
)
|
)
|
||||||
|
|
||||||
def _get_fake_context(self, request):
|
def _get_emails_with_fake_context(self, request):
|
||||||
fake_context = {'feedback': {}}
|
email_with_fake_context = {'feedback': {}}
|
||||||
|
|
||||||
fake_notifications = construct_fake_notifications()
|
fake_notifications = construct_fake_notifications()
|
||||||
for fake_notification in fake_notifications:
|
for fake_notification in fake_notifications:
|
||||||
mail_name = fake_notification.full_template_name
|
mail_name = fake_notification.full_template_name
|
||||||
fake_context[mail_name] = {
|
email_with_fake_context[mail_name] = {
|
||||||
'template': fake_notification.template_name,
|
'template': fake_notification.template_name,
|
||||||
**fake_notification.get_template_context(),
|
**fake_notification.get_template_context(),
|
||||||
}
|
}
|
||||||
return fake_context
|
return email_with_fake_context
|
||||||
|
|
||||||
def _get_emails_list(self, request):
|
def _get_emails_list(self, request):
|
||||||
emails = []
|
emails = []
|
||||||
fake_context = self._get_fake_context(request)
|
fake_context = self._get_emails_with_fake_context(request)
|
||||||
for mail_name in fake_context:
|
for mail_name in fake_context:
|
||||||
emails.append(self.get_object(request, object_id=mail_name, fake_context=fake_context))
|
emails.append(self.get_object(request, object_id=mail_name, fake_context=fake_context))
|
||||||
return emails
|
return emails
|
||||||
|
Loading…
Reference in New Issue
Block a user