Files
django-dav-events/dav_registration/emails.py
heinzel 98a6fc3ce7
All checks were successful
buildbot/tox Build done.
try to make pylint happy
2022-06-08 00:08:09 +02:00

58 lines
2.3 KiB
Python

# -*- coding: utf-8 -*-
from dav_base.emails import AbstractMail
class AbstractRegistrationMail(AbstractMail): # pylint: disable=too-few-public-methods
def __init__(self, recipient, registration):
self._recipient = recipient
self._registration = registration
self._event = registration.event
def _get_subject(self, subject_fmt=None, **kwargs):
if subject_fmt is None:
subject_fmt = self._subject
if self._event.number:
subject_fmt = '%s: %s' % (self._event.number, subject_fmt)
return super()._get_subject(subject_fmt=subject_fmt, **kwargs)
def _get_recipients(self):
if hasattr(self._recipient, 'get_full_name') and hasattr(self._recipient, 'email'):
r = '"{fullname}" <{email}>'.format(fullname=self._recipient.get_full_name(),
email=self._recipient.email)
else:
r = self._recipient
return [r]
def _get_context_data(self, extra_context=None):
context = super()._get_context_data(extra_context=extra_context)
context['recipient'] = self._recipient
context['registration'] = self._registration
context['event'] = self._event
return context
class InformTrainerRegistrationMail(AbstractRegistrationMail): # pylint: disable=too-few-public-methods
_subject = 'Anmeldung {full_name}'
_template_name = 'dav_registration/emails/inform_trainer.txt'
def _get_subject(self, subject_fmt=None, **kwargs):
kwargs['full_name'] = self._registration.get_full_name()
return super()._get_subject(subject_fmt=subject_fmt, **kwargs)
def _get_reply_to(self):
reply_to = '"{fullname}" <{email}>'.format(fullname=self._registration.get_full_name(),
email=self._registration.email_address)
return [reply_to]
class InformSelfRegistrationMail(AbstractRegistrationMail): # pylint: disable=too-few-public-methods
_subject = 'Deine Anmeldung'
_template_name = 'dav_registration/emails/inform_self.txt'
def _get_reply_to(self):
reply_to = '"{fullname}" <{email}>'.format(fullname=self._event.owner.get_full_name(),
email=self._event.owner.email)
return [reply_to]