From d971798018c7c713547ebffb71f6a12cd2b3d960 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Wed, 6 Jan 2021 10:20:06 +0100 Subject: [PATCH] basic mail sending system added (withour actual sending mails in the moment) --- evapp/settings.py | 9 +++++++++ evapp/views.py | 20 +++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 evapp/settings.py diff --git a/evapp/settings.py b/evapp/settings.py new file mode 100644 index 0000000..9853b80 --- /dev/null +++ b/evapp/settings.py @@ -0,0 +1,9 @@ +MAILS = {'IT': {'TEMPLATE': 'it_template.txt', + 'MAIL': 'it@wikimedia.de', + 'DATA': ['laptop', 'os',], + }, + 'OFFICE': {'TEMPLATE': 'office_template', + 'MAIL': 'office@wikimedia.de', + 'DATA': ['transponder',], + }, + } diff --git a/evapp/views.py b/evapp/views.py index 1a7e2e4..eb01859 100644 --- a/evapp/views.py +++ b/evapp/views.py @@ -4,10 +4,26 @@ from django.http import HttpResponse from .models import Employee from .forms import EmployeeForm +from .settings import MAILS def success(request): return HttpResponse("gut gemacht!") +def send_mail(department): + 'send a mail to the given department with the nececcary notifications' + + print(f'send mail to department {department}') + + # context = { 'data': data } + # try: + # mail_template = get_template('input/it_mail.txt') + # send_mail( + # 'EVA: Neuzugang', + # mail_template.render(context), + # IF_EMAIL, + # [data['email']], + # fail_silently=False) + class EvaFormView(CreateView): model = Employee form_class = EmployeeForm @@ -16,5 +32,7 @@ class EvaFormView(CreateView): return reverse('success') def form_valid(self, form): - print("VALIDE!!!") + for dep in MAILS: + send_mail(dep) + return super().form_valid(form)