Check required data before printing examination-compensation form

This commit is contained in:
Claude Paroz 2018-04-17 09:15:31 +02:00
parent ebe02ec6a6
commit cc036bc1e2
2 changed files with 10 additions and 1 deletions

View file

@ -213,11 +213,17 @@ tél. 032 886 33 00
def test_print_ede_expert_compensation(self):
st = Student.objects.get(first_name="Albin")
url = reverse('examination-compensation', args=[st.pk])
self.client.login(username='me', password='mepassword')
response = self.client.post(url, follow=True)
self.assertContains(response, "Toutes les informations ne sont pas disponibles")
st.expert = CorpContact.objects.get(last_name="Horner")
st.internal_expert = Teacher.objects.get(last_name="Caux")
st.date_exam = datetime(2018, 6, 28, 12, 00)
st.room = "B123"
st.save()
self.client.login(username='me', password='mepassword')
url = reverse('examination-compensation', args=[st.pk])
response = self.client.post(url, follow=True)
self.assertEqual(
response['Content-Disposition'],

View file

@ -933,6 +933,9 @@ def print_examination_compensation_form(request, pk):
travail de diplôme
"""
student = Student.objects.get(pk=pk)
if not student.is_examination_valid:
messages.error(request, "Toutes les informations ne sont pas disponibles pour la lettre à lexpert!")
return redirect(reverse("admin:stages_student_change", args=(student.pk,)))
pdf = ExaminationCompensationPdfForm(student)
pdf.produce()