chol
/
eva
forked from tohe/eva
1
0
Fork 0

some data should be in every mail

This commit is contained in:
Benni Bärmann 2021-01-20 08:52:22 +01:00
parent 1111af5e0b
commit f6b4f0584b
3 changed files with 7 additions and 4 deletions

View File

@ -1,5 +1,7 @@
EVA_MAIL = 'benni.baermann@wikimedia.de' EVA_MAIL = 'benni.baermann@wikimedia.de'
BASIC_DATA = ['firstname', 'lastname']
MAILS = {'IT': { MAILS = {'IT': {
'MAIL': 'it@wikimedia.de', 'MAIL': 'it@wikimedia.de',
'DATA': ['laptop', 'os',], 'DATA': ['laptop', 'os',],

View File

@ -1,4 +1,3 @@
dataloop
{% for key, value in data.items %} {% for key, value in data.items %}
{{ key }}: {{ value }} {{ key }}: {{ value }}
{% endfor %} {% endfor %}

View File

@ -12,7 +12,7 @@ from django.shortcuts import render
from .models import Employee, DEPARTMENT_CHOICES, LAPTOP_CHOICES, OS_CHOICES,\ from .models import Employee, DEPARTMENT_CHOICES, LAPTOP_CHOICES, OS_CHOICES,\
MOBILE_CHOICES, LANG_CHOICES, ACCOUNT_CHOICES, TRANSPONDER_CHOICES MOBILE_CHOICES, LANG_CHOICES, ACCOUNT_CHOICES, TRANSPONDER_CHOICES
from .forms import PersonalForm, WorkingForm, ITForm, OfficeForm, DummyForm from .forms import PersonalForm, WorkingForm, ITForm, OfficeForm, DummyForm
from .settings import MAILS, EVA_MAIL from .settings import MAILS, EVA_MAIL, BASIC_DATA
def success(request): def success(request):
return HttpResponse("Vielen Dank! Du hast E.V.A. erfolgreich ausgefüllt. Die Mails an die Abteilungen wurden versendet.") return HttpResponse("Vielen Dank! Du hast E.V.A. erfolgreich ausgefüllt. Die Mails an die Abteilungen wurden versendet.")
@ -54,9 +54,11 @@ class EvaFormView(CookieWizardView):
print(f'send mail to department {department}...') print(f'send mail to department {department}...')
# only the relevant data should be in the context
data = self.get_all_cleaned_data() data = self.get_all_cleaned_data()
newdata = {k: v for k, v in data.items() if (k in MAILS[department]['DATA'])} # some data should be in every mail
newdata = {k: v for k, v in data.items() if (k in BASIC_DATA)}
# 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'])})
context = {'data': self.beautify_data(newdata)} context = {'data': self.beautify_data(newdata)}