Agenda virtuel : ajouter des infos sur les agendas concernés dans les appels à datetime (#78064) #92
|
@ -801,6 +801,8 @@ class MeetingDatetimes(APIView):
|
|||
# slot from the list if there is still a bookable slot on a desk at the
|
||||
# same time.
|
||||
# The generator also remove slots starting before the current time.
|
||||
if agenda.kind == 'meetings':
|
||||
|
||||
def unique_slots():
|
||||
last_slot = None
|
||||
all_slots = list(
|
||||
|
@ -819,7 +821,35 @@ class MeetingDatetimes(APIView):
|
|||
if last_slot and last_slot[:2] == slot[:2]:
|
||||
continue
|
||||
last_slot = slot
|
||||
yield slot
|
||||
yield slot, None
|
||||
|
||||
elif agenda.kind == 'virtual':
|
||||
|
||||
def unique_slots():
|
||||
all_slots = list(
|
||||
agenda.get_all_slots(
|
||||
meeting_type,
|
||||
resources=resources,
|
||||
unique=False,
|
||||
start_datetime=start_datetime,
|
||||
end_datetime=end_datetime,
|
||||
user_external_id=booked_user_external_id or excluded_user_external_id,
|
||||
)
|
||||
)
|
||||
last_slot, slot_agendas = None, set()
|
||||
for slot in sorted(all_slots, key=lambda slot: slot[:3]):
|
||||
if slot.start_datetime < now_datetime:
|
||||
continue
|
||||
if last_slot is None:
|
||||
last_slot = slot
|
||||
elif last_slot[:2] != slot[:2]:
|
||||
yield last_slot, slot_agendas
|
||||
last_slot = slot
|
||||
slot_agendas = set()
|
||||
if not slot.full:
|
||||
slot_agendas.add(slot.desk.agenda)
|
||||
if last_slot:
|
||||
yield last_slot, slot_agendas
|
||||
|
||||
generator_of_unique_slots = unique_slots()
|
||||
|
||||
|
@ -839,7 +869,7 @@ class MeetingDatetimes(APIView):
|
|||
bookable_datetimes_number_available = 0
|
||||
first_bookable_slot = None
|
||||
data = []
|
||||
for slot in generator_of_unique_slots:
|
||||
for slot, slot_agendas in generator_of_unique_slots:
|
||||
if request.GET.get('hide_disabled') and slot.full:
|
||||
continue
|
||||
if minutes and slot.start_datetime.minute not in minutes:
|
||||
|
@ -861,6 +891,23 @@ class MeetingDatetimes(APIView):
|
|||
}
|
||||
if booked_user_external_id and slot.booked_for_external_user:
|
||||
slot_data['booked_for_external_user'] = True
|
||||
if slot_agendas is not None:
|
||||
slot_data['agendas'] = [
|
||||
{
|
||||
'id': agenda.id,
|
||||
'text': agenda.label,
|
||||
'slug': agenda.slug,
|
||||
'api': {
|
||||
'fillslot_url': request.build_absolute_uri(
|
||||
reverse(
|
||||
'api-fillslot',
|
||||
kwargs={'agenda_identifier': agenda.slug, 'event_identifier': slot_id},
|
||||
)
|
||||
)
|
||||
},
|
||||
}
|
||||
for agenda in sorted(slot_agendas, key=lambda a: a.label)
|
||||
]
|
||||
data.append(slot_data)
|
||||
|
||||
bookable_datetimes_number_total += 1
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue