Revision 7f73eb56
Added by Jérôme Schneider over 12 years ago
calebasse/agenda/appointments.py | ||
---|---|---|
70 | 70 |
self.title = title |
71 | 71 |
self.__set_time(time) |
72 | 72 |
|
73 |
def _add_free_time(delta, appointments, begin_time): |
|
74 |
if delta > 0: |
|
75 |
delta_minutes = delta / 60 |
|
76 |
appointment = Appointment() |
|
77 |
appointment.init_free_time(delta_minutes, begin_time) |
|
78 |
appointments.append(appointment) |
|
79 |
return appointments |
|
73 | 80 |
|
74 | 81 |
def get_daily_appointments(date, worker, service): |
75 | 82 |
""" |
... | ... | |
110 | 117 |
time_table.end_time.hour, time_table.end_time.minute) |
111 | 118 |
if (occurrence.end_time >= start_time_table) and (next_occurrence.start_time < end_time_table): |
112 | 119 |
delta = next_occurrence.start_time - occurrence.end_time |
113 |
if delta.seconds > 0: |
|
114 |
delta_minutes = delta.seconds / 60 |
|
115 |
appointment = Appointment() |
|
116 |
appointment.init_free_time(delta_minutes, time(occurrence.end_time.hour, occurrence.end_time.minute)) |
|
117 |
appointments.append(appointment) |
|
120 |
appointments = _add_free_time(delta.seconds, appointments, |
|
121 |
time(occurrence.end_time.hour, occurrence.end_time.minute)) |
|
118 | 122 |
|
119 | 123 |
for time_table in time_tables: |
120 | 124 |
appointment = Appointment() |
... | ... | |
133 | 137 |
biggest = Occurrence.objects.biggest_end_in_range(start_datetime, end_datetime, [worker]) |
134 | 138 |
if not smallest and not biggest: |
135 | 139 |
delta = end_datetime - start_datetime |
136 |
delta = delta.seconds / 60 |
|
137 |
appointment = Appointment() |
|
138 |
appointment.init_free_time(delta, |
|
140 |
appointments = _add_free_time(delta.seconds, appointments, |
|
139 | 141 |
time(start_datetime.hour, start_datetime.minute)) |
140 |
appointments.append(appointment) |
|
141 | 142 |
if smallest: |
142 | 143 |
delta = smallest.start_time - start_datetime |
143 |
delta = delta.seconds / 60 |
|
144 |
appointment = Appointment() |
|
145 |
appointment.init_free_time(delta, |
|
144 |
appointments = _add_free_time(delta.seconds, appointments, |
|
146 | 145 |
time(start_datetime.hour, start_datetime.minute)) |
147 |
appointments.append(appointment) |
|
148 | 146 |
if biggest: |
149 | 147 |
delta = end_datetime - biggest.end_time |
150 |
delta = delta.seconds / 60 |
|
151 |
appointment = Appointment() |
|
152 |
appointment.init_free_time(delta, |
|
148 |
appointments = _add_free_time(delta.seconds, appointments, |
|
153 | 149 |
time(biggest.end_time.hour, biggest.end_time.minute)) |
154 |
appointments.append(appointment) |
|
155 | 150 |
|
156 | 151 |
appointments = sorted(appointments, key=lambda app: app.begin_time) |
157 | 152 |
return appointments |
Also available in: Unified diff
agenda: fix free time creation