Update report_sem?_date after sending report to student

This commit is contained in:
Claude Paroz 2018-02-06 09:43:53 +01:00
parent 3758982989
commit b15a8418fc
2 changed files with 6 additions and 0 deletions

View file

@ -395,3 +395,6 @@ class ImportTests(TestCase):
# Second email as bcc
self.assertEqual(mail.outbox[0].recipients(), ['albin@example.org', 'me@example.org'])
self.assertIn("le bulletin scolaire de Monsieur Albin Dupond", mail.outbox[0].body)
student.refresh_from_db()
self.assertIsNotNone(student.report_sem1_sent)
self.assertIsNone(student.report_sem2_sent)

View file

@ -21,6 +21,7 @@ from django.http import HttpResponse, HttpResponseNotAllowed, HttpResponseRedire
from django.shortcuts import get_object_or_404
from django.template import loader
from django.urls import reverse
from django.utils import timezone
from django.utils.translation import ugettext as _
from django.utils.text import slugify
from django.views.generic import DetailView, FormView, TemplateView, ListView
@ -642,6 +643,8 @@ class SendStudentReportsView(FormView):
except Exception as err:
messages.error(self.request, "Échec denvoi pour l'étudiant {0} ({1})".format(self.student, err))
else:
setattr(self.student, 'report_sem%d_sent' % self.semestre, timezone.now())
self.student.save()
messages.success(self.request, "Le message a été envoyé.")
return HttpResponseRedirect(reverse('class', args=[self.student.klass.pk]))