From 6ab97b79743b426d5b4b012bac2e99b79963df0e Mon Sep 17 00:00:00 2001 From: Serghei MIHAI Date: Mon, 22 Sep 2014 15:45:05 +0200 Subject: [PATCH] agenda: displaying free periods only for current service in scheduled and availability bar --- calebasse/agenda/appointments.py | 4 ++-- calebasse/agenda/views.py | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/calebasse/agenda/appointments.py b/calebasse/agenda/appointments.py index d8f1f854..ac7e7e25 100644 --- a/calebasse/agenda/appointments.py +++ b/calebasse/agenda/appointments.py @@ -143,7 +143,7 @@ def get_daily_appointments(date, worker, service, time_tables, events, holidays) timetables_set = IntervalSet((t.to_interval(date) for t in time_tables)) holidays_set = IntervalSet((h.to_interval(date) for h in holidays)) - busy_occurrences_set = IntervalSet((o.to_interval() for o in events if not o.is_event_absence())) + busy_occurrences_set = IntervalSet((o.to_interval() for o in events if not o.is_event_absence() and service in o.services.all())) for free_time in timetables_set - (busy_occurrences_set+holidays_set): if free_time: delta = free_time.upper_bound - free_time.lower_bound @@ -218,7 +218,7 @@ def get_daily_appointments(date, worker, service, time_tables, events, holidays) appointment.init_start_stop(u"Arrivée", start_time, 'arrival', appointment_kind) activity['arrival'] = start_time - appointment.weight = 1 + appointment.weight = -1 appointments.append(appointment) appointment = Appointment() appointment.init_start_stop(u"Départ", end_time, 'departure', diff --git a/calebasse/agenda/views.py b/calebasse/agenda/views.py index 6d19d602..79985c5e 100644 --- a/calebasse/agenda/views.py +++ b/calebasse/agenda/views.py @@ -533,14 +533,14 @@ class AjaxWorkerTabView(TemplateView): .select_related() events = Event.objects.for_today(self.date) \ .exclude(event_type_id=1) \ - .filter(participants=worker, services=self.service) \ + .filter(participants=worker) \ .order_by('start_datetime') \ .select_related() \ .prefetch_related('services', 'exceptions', 'participants') eventswithact = EventWithAct.objects.for_today(self.date) \ - .filter(participants=worker, services=self.service) \ + .filter(participants=worker) \ .order_by('start_datetime') \ .select_related() \ .prefetch_related('patient__addresses', @@ -592,8 +592,7 @@ class AjaxDisponibilityColumnView(TemplateView): self.date.day, 8, 0) end_datetime = datetime.datetime(self.date.year, self.date.month, self.date.day, 8, 15) - events = Event.objects.filter(ressource__id=ressource_id, - services=self.service).today_occurrences(self.date) + events = Event.objects.filter(ressource__id=ressource_id).today_occurrences(self.date) while (start_datetime.hour <= 19): if start_datetime.hour not in disponibility: @@ -628,17 +627,17 @@ class AjaxDisponibilityColumnView(TemplateView): filter(services=self.service, worker=worker). \ for_today(self.date). \ order_by('start_date') - holidays = Holiday.objects.for_worker(worker). \ + holidays = Holiday.objects.for_worker(worker).for_service(self.service). \ for_period(self.date, self.date). \ order_by('start_date') events = Event.objects.for_today(self.date) \ .exclude(event_type_id=1) \ - .filter(services=self.service, participants=worker) \ + .filter(participants=worker, services=self.service) \ .order_by('start_datetime') \ .select_related() \ .prefetch_related('participants', 'exceptions') eventswithact = EventWithAct.objects.for_today(self.date) \ - .filter(services=self.service, participants=worker) \ + .filter(participants=worker, services=self.service) \ .order_by('start_datetime') \ .select_related() \ .prefetch_related('participants', 'exceptions',