Révision dce0454a
Ajouté par Serghei Mihai il y a presque 10 ans
calebasse/agenda/appointments.py | ||
---|---|---|
138 | 138 |
""" |
139 | 139 |
""" |
140 | 140 |
appointments = [] |
141 |
activity = {'absences': []} |
|
141 | 142 |
|
142 | 143 |
timetables_set = IntervalSet((t.to_interval(date) for t in time_tables)) |
143 | 144 |
holidays_set = IntervalSet((h.to_interval(date) for h in holidays)) |
... | ... | |
158 | 159 |
validation_states.pop('VALIDE') |
159 | 160 |
validation_states.pop('ACT_LOST') |
160 | 161 |
validation_states = vs + sorted(validation_states.items(), key=lambda tup: tup[0]) |
162 |
|
|
163 |
events.sort(key=lambda event: event.start_datetime) |
|
164 |
|
|
165 |
# get first and last events start times |
|
166 |
if events: |
|
167 |
activity['first_appointment'], activity['last_appointment'] = (e.start_datetime.time() for e in (events[0], events[-1])) |
|
168 |
|
|
161 | 169 |
for event in events: |
162 | 170 |
appointment = Appointment() |
163 | 171 |
appointment.init_from_event(event, service, validation_states) |
... | ... | |
173 | 181 |
label = u"Absence de groupe : %s" % holiday.holiday_type.name |
174 | 182 |
else: |
175 | 183 |
label = u"Absence indiv. : %s" % holiday.holiday_type.name |
184 |
|
|
176 | 185 |
appointment.init_holiday_time(label, |
177 | 186 |
delta_minutes, |
178 | 187 |
time(interval.lower_bound.hour, interval.lower_bound.minute), |
179 | 188 |
description=holiday.comment) |
189 |
activity['absences'].append(label) |
|
180 | 190 |
services = holiday.services.all() |
181 | 191 |
if service not in services: |
182 | 192 |
appointment.type = 'busy-elsewhere' |
... | ... | |
195 | 205 |
end_time = interval_set.upper_bound() |
196 | 206 |
appointment = Appointment() |
197 | 207 |
appointment.init_start_stop(u"Arrivée", start_time) |
208 |
activity['arrival'] = start_time |
|
198 | 209 |
appointment.weight = -1 |
199 | 210 |
appointments.append(appointment) |
200 | 211 |
appointment = Appointment() |
201 | 212 |
appointment.init_start_stop(u"Départ", end_time) |
213 |
activity['departure'] = end_time |
|
202 | 214 |
appointment.weight = 1 |
203 | 215 |
appointments.append(appointment) |
204 | 216 |
|
205 |
return sorted(appointments, key=lambda app: (app.begin_time, app.weight, app.event_id)) |
|
217 |
return activity, sorted(appointments, key=lambda app: (app.begin_time, app.weight, app.event_id))
|
|
206 | 218 |
|
207 | 219 |
def get_daily_usage(date, ressource, service, occurrences): |
208 | 220 |
""" |
Formats disponibles : Unified diff
agenda: display a summary of service activity
Closes #2735