From f6b4f0584b0c3c103f12cff564a931e37af3d965 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Wed, 20 Jan 2021 08:52:22 +0100 Subject: [PATCH] some data should be in every mail --- evapp/settings.py | 2 ++ evapp/templates/evapp/dataloop.txt | 1 - evapp/views.py | 8 +++++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/evapp/settings.py b/evapp/settings.py index d6661b9..51626c5 100644 --- a/evapp/settings.py +++ b/evapp/settings.py @@ -1,5 +1,7 @@ EVA_MAIL = 'benni.baermann@wikimedia.de' +BASIC_DATA = ['firstname', 'lastname'] + MAILS = {'IT': { 'MAIL': 'it@wikimedia.de', 'DATA': ['laptop', 'os',], diff --git a/evapp/templates/evapp/dataloop.txt b/evapp/templates/evapp/dataloop.txt index 6f016a4..a47b40e 100644 --- a/evapp/templates/evapp/dataloop.txt +++ b/evapp/templates/evapp/dataloop.txt @@ -1,4 +1,3 @@ -dataloop {% for key, value in data.items %} {{ key }}: {{ value }} {% endfor %} diff --git a/evapp/views.py b/evapp/views.py index 9a47f9e..37fcdd2 100644 --- a/evapp/views.py +++ b/evapp/views.py @@ -12,7 +12,7 @@ from django.shortcuts import render from .models import Employee, DEPARTMENT_CHOICES, LAPTOP_CHOICES, OS_CHOICES,\ MOBILE_CHOICES, LANG_CHOICES, ACCOUNT_CHOICES, TRANSPONDER_CHOICES 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): 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}...') - # only the relevant data should be in the context 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)}