2020-12-23 14:08:27 +00:00
|
|
|
from django.views.generic.edit import CreateView
|
2021-01-05 13:10:28 +00:00
|
|
|
from django.urls import reverse
|
|
|
|
from django.http import HttpResponse
|
2020-12-23 14:08:27 +00:00
|
|
|
|
|
|
|
from .models import Employee
|
2021-01-04 14:48:32 +00:00
|
|
|
from .forms import EmployeeForm
|
2021-01-06 09:20:06 +00:00
|
|
|
from .settings import MAILS
|
2020-12-23 10:42:57 +00:00
|
|
|
|
2021-01-05 13:10:28 +00:00
|
|
|
def success(request):
|
|
|
|
return HttpResponse("gut gemacht!")
|
|
|
|
|
2021-01-06 09:20:06 +00:00
|
|
|
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)
|
|
|
|
|
2020-12-23 14:08:27 +00:00
|
|
|
class EvaFormView(CreateView):
|
|
|
|
model = Employee
|
2021-01-04 14:48:32 +00:00
|
|
|
form_class = EmployeeForm
|
2021-01-05 13:10:28 +00:00
|
|
|
|
|
|
|
def get_success_url(self):
|
|
|
|
return reverse('success')
|
|
|
|
|
|
|
|
def form_valid(self, form):
|
2021-01-06 09:20:06 +00:00
|
|
|
for dep in MAILS:
|
|
|
|
send_mail(dep)
|
|
|
|
|
2021-01-05 13:10:28 +00:00
|
|
|
return super().form_valid(form)
|