From e4e3959c505eb80908135326a4dfb0e88f842b66 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Tue, 28 Feb 2017 21:13:36 +0100
Subject: [PATCH] appointments are spaned for duration time

---
 smash/web/models.py                         | 18 ++++++++++++++++++
 smash/web/templates/appointments/index.html |  3 ++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/smash/web/models.py b/smash/web/models.py
index 3c1a699b..2559c837 100644
--- a/smash/web/models.py
+++ b/smash/web/models.py
@@ -5,6 +5,7 @@ from django.utils import timezone
 from django.contrib.auth.models import User, AnonymousUser
 import datetime
 
+from datetime import timedelta
 
 def get_current_year():
     return datetime.datetime.now().year
@@ -440,6 +441,11 @@ class Appointment(models.Model):
     visit = models.ForeignKey(Visit,
         verbose_name='Visit ID'
     )
+    comment = models.CharField(max_length=1024,
+        verbose_name='Comment',
+        null=True,
+        blank=True
+    )
     datetime_when = models.DateTimeField(
         verbose_name='Appointment on',
         null=True, blank=True
@@ -451,3 +457,15 @@ class Appointment(models.Model):
         verbose_name='Has the appointment ended?',
         default=False
     )
+
+    def datetime_until(self):
+        if self.datetime_when is None:
+            return None
+        else:
+            return self.datetime_when + timedelta(minutes=max(self.length, 15))
+
+    def title(self):
+        if self.visit.subject.screening_number=="---":
+            return self.comment
+        else:
+            return self.visit.subject.first_name + " " + self.visit.subject.last_name
diff --git a/smash/web/templates/appointments/index.html b/smash/web/templates/appointments/index.html
index d743a78d..bd829b46 100644
--- a/smash/web/templates/appointments/index.html
+++ b/smash/web/templates/appointments/index.html
@@ -137,8 +137,9 @@
 				events: [
         {% for approach in approaching_list %}
           {
-            title: '{{ approach.visit.subject.first_name }} {{ approach.visit.subject.last_name }}',
+            title: '{{ approach.title }}',
             start: '{{ approach.datetime_when | date:"c" }}',
+            end: '{{ approach.datetime_until | date:"c" }}',
             color: '#cfc600',
             subject_id: '{{ approach.visit.subject.id }}',
             id: '{{ approach.id }}'
-- 
GitLab