change email if employee is extern and mail does not end with _ext

This commit is contained in:
Benni Bärmann 2021-02-08 13:13:44 +01:00
parent 70b849ffd6
commit eb7d71bf69
2 changed files with 10 additions and 2 deletions

View File

@ -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',

View File

@ -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'''