From eb7d71bf69c210cd54f72444394d31fa6f193083 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Mon, 8 Feb 2021 13:13:44 +0100 Subject: [PATCH] change email if employee is extern and mail does not end with _ext --- evapp/settings.py | 2 +- evapp/views.py | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/evapp/settings.py b/evapp/settings.py index eed6ec0..e50857b 100644 --- a/evapp/settings.py +++ b/evapp/settings.py @@ -7,7 +7,7 @@ BASIC_DATA = ['firstname', 'lastname'] # for every department: 'MAIL' => mail adress, 'DATA': additional fields to include MAILS = {'IT': { 'MAIL': 'it@wikimedia.de', - 'DATA': ['laptop', 'os',], + 'DATA': ['laptop', 'os', 'email'], }, 'OFFICE': { 'MAIL': 'office@wikimedia.de', diff --git a/evapp/views.py b/evapp/views.py index e03d560..ffa9385 100644 --- a/evapp/views.py +++ b/evapp/views.py @@ -51,9 +51,16 @@ class EvaFormView(CookieWizardView): def get_all_cleaned_data(self): - '''this method deletes data which is only used temporary and is not in the modell''' + '''this method deletes data which is only used temporary and is not in the modell, + it also changes the mail adress of the employee in some circumstances''' data = super().get_all_cleaned_data() + if not data['intern']: + print("intern employee detected") + if not data['email'].endswith('_ext'): + print('added "_ext" to mail adress') + data['email'] += '_ext' + print("delete CHOICE FROM DATA") if 'choice' in data: del data['choice'] @@ -80,6 +87,7 @@ class EvaFormView(CookieWizardView): self.instance = Employee() return self.instance + def done(self, form_list, **kwargs): '''this method is called from CookieWizardView after all forms are filled'''