basic mail sending system added (withour actual sending mails in the moment)
This commit is contained in:
parent
da8b58279f
commit
d971798018
|
@ -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',],
|
||||||
|
},
|
||||||
|
}
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue