Skip to content
Snippets Groups Projects
Commit bc4d3af9 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

color codes are visible in the calendar

parent e46616cd
No related branches found
No related tags found
1 merge request!1Appointments dev
...@@ -253,6 +253,10 @@ class Room (models.Model): ...@@ -253,6 +253,10 @@ class Room (models.Model):
class AppointmentType (models.Model): class AppointmentType (models.Model):
DEFAULT_COLOR = '#cfc600'
required_equipment = models.ManyToManyField(Item, required_equipment = models.ManyToManyField(Item,
verbose_name='Required equipment', verbose_name='Required equipment',
blank = True blank = True
...@@ -266,6 +270,14 @@ class AppointmentType (models.Model): ...@@ -266,6 +270,14 @@ class AppointmentType (models.Model):
default_duration = models.IntegerField( default_duration = models.IntegerField(
verbose_name='Default duration (in minutes)' verbose_name='Default duration (in minutes)'
) )
calendar_color_priority = models.IntegerField(
verbose_name='Calendar color priority',
default=1
)
calendar_color = models.CharField(max_length=2000,
verbose_name='Calendar color',
default=DEFAULT_COLOR
)
rest_time = models.IntegerField( rest_time = models.IntegerField(
verbose_name='Suggested rest time' verbose_name='Suggested rest time'
) )
...@@ -464,6 +476,15 @@ class Appointment(models.Model): ...@@ -464,6 +476,15 @@ class Appointment(models.Model):
else: else:
return self.datetime_when + timedelta(minutes=max(self.length, 15)) return self.datetime_when + timedelta(minutes=max(self.length, 15))
def color(self):
result = AppointmentType.DEFAULT_COLOR
priority = 1000000
for type in self.appointment_types.all():
if type.calendar_color_priority<priority:
priority=type.calendar_color_priority
result = type.calendar_color
return result
def title(self): def title(self):
if self.visit.subject.screening_number=="---": if self.visit.subject.screening_number=="---":
return self.comment return self.comment
......
...@@ -140,7 +140,7 @@ ...@@ -140,7 +140,7 @@
title: '{{ approach.title }}', title: '{{ approach.title }}',
start: '{{ approach.datetime_when | date:"c" }}', start: '{{ approach.datetime_when | date:"c" }}',
end: '{{ approach.datetime_until | date:"c" }}', end: '{{ approach.datetime_until | date:"c" }}',
color: '#cfc600', color: '{{ approach.color }}',
subject_id: '{{ approach.visit.subject.id }}', subject_id: '{{ approach.visit.subject.id }}',
id: '{{ approach.id }}' id: '{{ approach.id }}'
}, },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment