agenda: displaying free periods only for current service in scheduled and

availability bar
This commit is contained in:
Serghei Mihai 2014-09-22 15:45:05 +02:00
parent 2d6ba14afa
commit 6ab97b7974
2 changed files with 8 additions and 9 deletions

View File

@ -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',

View File

@ -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',