WMDE
/
eva
forked from tohe/eva
7
1
Fork 0

usermail fix in mail templates

This commit is contained in:
Benni Bärmann 2021-05-18 09:42:00 +02:00
parent 1b122d8f0d
commit 6352064931
4 changed files with 9 additions and 4 deletions

2
TODO
View File

@ -1 +1,3 @@
* remove dot before "Nextcloud" at login page. * remove dot before "Nextcloud" at login page.
* Datumsformat bei Ausgabe ist englisch nicht deutsch.

View File

@ -5,7 +5,7 @@ ONLY_ONBOARDING = True
EVA_MAIL = 'benni.baermann@wikimedia.de' EVA_MAIL = 'benni.baermann@wikimedia.de'
# these Fields should be included in every mail # these Fields should be included in every mail
BASIC_DATA = ['usermail', 'firstname', 'lastname', 'firstdate_employment', 'firstdate_presence',] BASIC_DATA = ['firstname', 'lastname', 'firstdate_employment', 'firstdate_presence',]
# for every department: 'MAIL' => mail adress, 'DATA': additional fields to include # for every department: 'MAIL' => mail adress, 'DATA': additional fields to include
MAILS = { MAILS = {

View File

@ -6,4 +6,6 @@ die Du dafür brauchst:
{% include 'evapp/dataloop.txt' %} {% include 'evapp/dataloop.txt' %}
Wenn Du Fragen hast, melde Dich bei {{contact}}.
Grüße, Deine E.V.A. Grüße, Deine E.V.A.

View File

@ -125,13 +125,14 @@ class EvaFormView(LoginRequiredMixin, CookieWizardView):
print(f'send mail to department {department}...') print(f'send mail to department {department}...')
contact = self.request.user.email
data = self.get_all_cleaned_data() data = self.get_all_cleaned_data()
# some data should be in every mail # some data should be in every mail
newdata = {k: v for k, v in data.items() if (k in BASIC_DATA)} newdata = {k: v for k, v in data.items() if (k in BASIC_DATA)}
# only the relevant data should be in the context # only the relevant data should be in the context
newdata.update({k: v for k, v in data.items() if (k in MAILS[department]['DATA'])}) newdata.update({k: v for k, v in data.items() if (k in MAILS[department]['DATA'])})
context = {'data': self.beautify_data(newdata)} context = {'data': self.beautify_data(newdata), 'contact': contact}
try: try:
mail_template = get_template(f'evapp/department_mail.txt') mail_template = get_template(f'evapp/department_mail.txt')
@ -140,14 +141,14 @@ class EvaFormView(LoginRequiredMixin, CookieWizardView):
'EVA: Neuzugang', 'EVA: Neuzugang',
mail_template.render(context), mail_template.render(context),
EVA_MAIL, EVA_MAIL,
[EVA_MAIL, self.request.user.email], [EVA_MAIL, contact],
fail_silently=False) fail_silently=False)
else: else:
send_mail( send_mail(
'EVA: Neuzugang', 'EVA: Neuzugang',
mail_template.render(context), mail_template.render(context),
EVA_MAIL, EVA_MAIL,
[MAILS[department]['MAIL'], self.request.user.email], [MAILS[department]['MAIL'], contact],
fail_silently=False) fail_silently=False)
except BadHeaderError: except BadHeaderError:
self.instance.delete() self.instance.delete()