33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
from django.apps import apps
|
|
|
|
from dav_base.emails import AbstractMail
|
|
|
|
app_config = apps.get_containing_app_config(__package__)
|
|
|
|
|
|
class NewSubmissionMail(AbstractMail): # pylint: disable=too-few-public-methods
|
|
_subject = 'Neuer Beitrag: {title}'
|
|
_template_name = 'dav_submission/emails/new_submission.txt'
|
|
|
|
def __init__(self, metadata):
|
|
self._metadata = metadata
|
|
|
|
def _get_subject(self, subject_fmt=None, **kwargs):
|
|
kwargs['title'] = self._metadata['title']
|
|
return super()._get_subject(subject_fmt=subject_fmt, **kwargs)
|
|
|
|
def _get_reply_to(self):
|
|
reply_to = '"{fullname}" <{email}>'.format(fullname=self._metadata['name'],
|
|
email=self._metadata['email_address'])
|
|
return [reply_to]
|
|
|
|
def _get_recipients(self):
|
|
r = app_config.settings.notify_address
|
|
return [r]
|
|
|
|
def _get_context_data(self, extra_context=None):
|
|
context = super()._get_context_data(extra_context=extra_context)
|
|
context['metadata'] = self._metadata
|
|
return context
|