|
@ -4,6 +4,7 @@ from django.shortcuts import get_object_or_404, render, redirect |
|
|
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden, JsonResponse |
|
|
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden, JsonResponse |
|
|
from django.urls import reverse,reverse_lazy |
|
|
from django.urls import reverse,reverse_lazy |
|
|
from django.core.exceptions import PermissionDenied, ObjectDoesNotExist |
|
|
from django.core.exceptions import PermissionDenied, ObjectDoesNotExist |
|
|
|
|
|
from django.core.mail import send_mail |
|
|
from django.views import generic |
|
|
from django.views import generic |
|
|
from django.utils.translation import ugettext as _ |
|
|
from django.utils.translation import ugettext as _ |
|
|
from django.http import Http404,HttpResponseBadRequest,HttpResponseRedirect |
|
|
from django.http import Http404,HttpResponseBadRequest,HttpResponseRedirect |
|
@ -1058,6 +1059,21 @@ class NahrajReseniView(LoginRequiredMixin, CreateView): |
|
|
prilohy.instance = self.object |
|
|
prilohy.instance = self.object |
|
|
prilohy.save() |
|
|
prilohy.save() |
|
|
|
|
|
|
|
|
|
|
|
# Pošleme mail opravovatelům a garantovi |
|
|
|
|
|
# FIXME: Nechat spočítat databázi? Je to pár dotazů (pravděpodobně), takže to za to možná nestojí |
|
|
|
|
|
prijemci = set() |
|
|
|
|
|
for prob in form.cleaned_data['problem']: |
|
|
|
|
|
prijemci.update(prob.opravovatele.all()) |
|
|
|
|
|
prijemci.add(prob.garant) |
|
|
|
|
|
# FIXME: Možná poslat mail i relevantním orgům nadproblémů? |
|
|
|
|
|
# FIXME: Víc informativní obsah mailů, možná vč. příloh? |
|
|
|
|
|
send_mail( |
|
|
|
|
|
subject="Nové řešení k problému", |
|
|
|
|
|
message=f"Řešitel poslal řešení...", |
|
|
|
|
|
from_email="submitovatko@mam.mff.cuni.cz", # FIXME: Chceme to mít radši tady, nebo v nastavení? |
|
|
|
|
|
recipient_list=list(prijemci), |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
return HttpResponseRedirect(self.get_success_url()) |
|
|
return HttpResponseRedirect(self.get_success_url()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|