diff --git a/smash/web/models.py b/smash/web/models.py index 3c1a699b3c4f6a9b56e79201dd4519e7b15d2f21..2559c837f475b96ccc764af1d0d46f4ff52e1a3e 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 d743a78d353469e78e931c2df8d476d1fcd2ecfd..bd829b466d7ebe5f8de509f9fa9299b378922d57 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 }}'