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

basic mail sending system added (withour actual sending mails in the moment)

This commit is contained in:
Benni Bärmann 2021-01-06 10:20:06 +01:00
parent da8b58279f
commit d971798018
2 changed files with 28 additions and 1 deletions

9
evapp/settings.py Normal file
View File

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

View File

@ -4,10 +4,26 @@ from django.http import HttpResponse
from .models import Employee from .models import Employee
from .forms import EmployeeForm from .forms import EmployeeForm
from .settings import MAILS
def success(request): def success(request):
return HttpResponse("gut gemacht!") 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): class EvaFormView(CreateView):
model = Employee model = Employee
form_class = EmployeeForm form_class = EmployeeForm
@ -16,5 +32,7 @@ class EvaFormView(CreateView):
return reverse('success') return reverse('success')
def form_valid(self, form): def form_valid(self, form):
print("VALIDE!!!") for dep in MAILS:
send_mail(dep)
return super().form_valid(form) return super().form_valid(form)