Browse Source

Merge branch 'data_migrations' of gimli.ms.mff.cuni.cz:/akce/mam/git/mamweb into data_migrations

export_seznamu_prednasek
Kateřina Č 4 years ago
parent
commit
de0ae0a425
  1. BIN
      seminar/static/seminar/cross.png
  2. BIN
      seminar/static/seminar/plus.png
  3. 14
      seminar/templates/seminar/odevzdavatko/detail.html
  4. 16
      seminar/views/views_all.py

BIN
seminar/static/seminar/cross.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 717 B

BIN
seminar/static/seminar/plus.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

14
seminar/templates/seminar/odevzdavatko/detail.html

@ -1,4 +1,5 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load static %}
{% block content %} {% block content %}
@ -25,8 +26,9 @@ function deleteForm(prefix, btn) {
if (total >= 1){ if (total >= 1){
btn.closest('tr').remove(); btn.closest('tr').remove();
var forms = $('.hodnoceni'); var forms = $('.hodnoceni');
$('#id_' + prefix + '-TOTAL_FORMS').val(forms.length); var formCount = forms.length - 1; // There is one extra such form hidden as template!
for (var i=0, formCount=forms.length; i<formCount; i++) { $('#id_' + prefix + '-TOTAL_FORMS').val(formCount);
for (var i=0; i<formCount; i++) {
$(forms.get(i)).find(':input').each(function() { $(forms.get(i)).find(':input').each(function() {
updateElementIndex(this, prefix, i); updateElementIndex(this, prefix, i);
}); });
@ -91,21 +93,21 @@ $(document).ready(function(){
<td>{{ subform.problem }}</td> <td>{{ subform.problem }}</td>
<td>{{ subform.body }}</td> <td>{{ subform.body }}</td>
<td>{{ subform.cislo_body }}</td> <td>{{ subform.cislo_body }}</td>
<td><input type=button class="smazat_hodnoceni" value="Smazat" id="id_{{subform.prefix}}-jsremove"></td> <td><a href="#" class="smazat_hodnoceni" id="id_{{subform.prefix}}-jsremove"><img src="{% static "seminar/cross.png" %}" alt="Smazat"></a></td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
<input type=button id="pridat_hodnoceni" value="Přidat hodnocení"> <a href="#"> <img src="{% static "seminar/plus.png" %}" id="pridat_hodnoceni" alt="Přidat hodnocení"></a> </br>
<input type=submit></form> <input type=submit value="Uložit"></form>
<table id="empty_form" style="display: none;"> <table id="empty_form" style="display: none;">
<tr class="hodnoceni"> <tr class="hodnoceni">
<td>{{ form.empty_form.problem }}</td> <td>{{ form.empty_form.problem }}</td>
<td>{{ form.empty_form.body }}</td> <td>{{ form.empty_form.body }}</td>
<td>{{ form.empty_form.cislo_body }}</td> <td>{{ form.empty_form.cislo_body }}</td>
<td><input type=button class="smazat_hodnoceni" value="Smazat" id="id_{{form.empty_form.prefix}}-jsremove"></td> <td><a href="#" class="smazat_hodnoceni" id="id_{{subform.prefix}}-jsremove"><img src="{% static "seminar/cross.png" %}" alt="Smazat"></a></td>
</tr> </tr>
</table> </table>

16
seminar/views/views_all.py

@ -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
@ -1057,6 +1058,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())

Loading…
Cancel
Save