From 5068f3748d32d3e9cd7630c4e9396fb676323ff2 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Tue, 4 Apr 2017 17:01:21 +0200
Subject: [PATCH] subject.informatio_sent is set to true after finishing
 appointment

---
 smash/web/views/appointment.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/smash/web/views/appointment.py b/smash/web/views/appointment.py
index 8bc59f0c..760b8388 100644
--- a/smash/web/views/appointment.py
+++ b/smash/web/views/appointment.py
@@ -3,7 +3,7 @@ from django.shortcuts import get_object_or_404, redirect
 
 from . import wrap_response
 from ..forms import AppointmentDetailForm, AppointmentAddForm, AppointmentEditForm, SubjectEditForm
-from ..models import Appointment
+from ..models import Appointment, Subject
 
 APPOINTMENT_LIST_GENERIC = "GENERIC"
 APPOINTMENT_LIST_UNFINISHED = "UNFINISHED"
@@ -75,6 +75,12 @@ def appointment_edit(request, id):
             if subject_form is not None:
                 subject_form.save()
             the_appointment = get_object_or_404(Appointment, id=id)
+
+            if the_appointment.status == Appointment.APPOINTMENT_STATUS_FINISHED:
+                subject = Subject.objects.get(id=the_appointment.visit.subject.id)
+                subject.information_sent = True
+                subject.save()
+
             if (the_appointment.status != Appointment.APPOINTMENT_STATUS_SCHEDULED) and (
                         the_appointment.visit is not None):
                 return redirect('web.views.visit_details', id=the_appointment.visit.id)
-- 
GitLab