WMDE
/
eva
forked from tohe/eva
7
1
Fork 0
eva/evapp/views.py

39 lines
995 B
Python

from django.views.generic.edit import CreateView
from django.urls import reverse
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
def get_success_url(self):
return reverse('success')
def form_valid(self, form):
for dep in MAILS:
send_mail(dep)
return super().form_valid(form)