api: add end_datetime in meetings datetimes (#60789)
gitea/chrono/pipeline/head This commit looks good Details

This commit is contained in:
Emmanuel Cazenave 2023-03-09 14:49:23 +01:00
parent 433bb7f1d7
commit 46e7b51357
2 changed files with 37 additions and 0 deletions

View File

@ -1090,6 +1090,7 @@ class MeetingDatetimes(APIView):
'id': slot_id,
'date': format_response_date(slot.start_datetime),
'datetime': format_response_datetime(slot.start_datetime),
'end_datetime': format_response_datetime(slot.end_datetime),
'text': date_format(slot.start_datetime, format='DATETIME_FORMAT'),
'disabled': bool(slot.full),
'api': {'fillslot_url': fillslot_url.replace(fake_event_identifier, slot_id)},

View File

@ -121,6 +121,7 @@ def test_datetimes_api_meetings_agenda_time_change(app):
'api': {'fillslot_url': 'http://testserver/api/agenda/agenda/fillslot/foo:2020-10-24-0900/'},
'date': '2020-10-24',
'datetime': '2020-10-24 09:00:00',
'end_datetime': '2020-10-24 10:00:00',
'disabled': False,
'id': 'foo:2020-10-24-0900',
'text': 'Oct. 24, 2020, 9 a.m.',
@ -129,6 +130,7 @@ def test_datetimes_api_meetings_agenda_time_change(app):
'api': {'fillslot_url': 'http://testserver/api/agenda/agenda/fillslot/foo:2020-10-24-1400/'},
'date': '2020-10-24',
'datetime': '2020-10-24 14:00:00',
'end_datetime': '2020-10-24 15:00:00',
'disabled': False,
'id': 'foo:2020-10-24-1400',
'text': 'Oct. 24, 2020, 2 p.m.',
@ -137,6 +139,7 @@ def test_datetimes_api_meetings_agenda_time_change(app):
'api': {'fillslot_url': 'http://testserver/api/agenda/agenda/fillslot/foo:2020-10-25-0900/'},
'date': '2020-10-25',
'datetime': '2020-10-25 09:00:00',
'end_datetime': '2020-10-25 10:00:00',
'disabled': False,
'id': 'foo:2020-10-25-0900',
'text': 'Oct. 25, 2020, 9 a.m.',
@ -145,6 +148,7 @@ def test_datetimes_api_meetings_agenda_time_change(app):
'api': {'fillslot_url': 'http://testserver/api/agenda/agenda/fillslot/foo:2020-10-25-1400/'},
'date': '2020-10-25',
'datetime': '2020-10-25 14:00:00',
'end_datetime': '2020-10-25 15:00:00',
'disabled': False,
'id': 'foo:2020-10-25-1400',
'text': 'Oct. 25, 2020, 2 p.m.',
@ -153,6 +157,7 @@ def test_datetimes_api_meetings_agenda_time_change(app):
'api': {'fillslot_url': 'http://testserver/api/agenda/agenda/fillslot/foo:2020-10-26-0900/'},
'date': '2020-10-26',
'datetime': '2020-10-26 09:00:00',
'end_datetime': '2020-10-26 10:00:00',
'disabled': False,
'id': 'foo:2020-10-26-0900',
'text': 'Oct. 26, 2020, 9 a.m.',
@ -161,6 +166,7 @@ def test_datetimes_api_meetings_agenda_time_change(app):
'api': {'fillslot_url': 'http://testserver/api/agenda/agenda/fillslot/foo:2020-10-26-1400/'},
'date': '2020-10-26',
'datetime': '2020-10-26 14:00:00',
'end_datetime': '2020-10-26 15:00:00',
'disabled': False,
'id': 'foo:2020-10-26-1400',
'text': 'Oct. 26, 2020, 2 p.m.',
@ -2572,3 +2578,33 @@ def test_datetimes_api_meetings_agenda_date_time_period_dst_change(app):
'2023-03-21 10:00:00',
'2023-03-28 10:00:00',
]
@pytest.mark.freeze_time('2023-03-09 08:00')
def test_datetimes_end_datetime(app):
agenda = Agenda.objects.create(
label='Foo bar', kind='meetings', minimal_booking_delay=0, maximal_booking_delay=60
)
meeting_type = MeetingType.objects.create(agenda=agenda, label='Plop', duration=30)
desk = Desk.objects.create(agenda=agenda, label='desk')
# DST change happens on 26/03
TimePeriod.objects.create(
date=datetime.date(2023, 3, 10),
start_time=datetime.time(10, 0),
end_time=datetime.time(10, 30),
desk=desk,
)
TimePeriod.objects.create(
date=datetime.date(2023, 3, 10),
start_time=datetime.time(10, 30),
end_time=datetime.time(11, 0),
desk=desk,
)
api_url = '/api/agenda/%s/meetings/%s/datetimes/' % (agenda.slug, meeting_type.slug)
resp = app.get(api_url)
assert [(x['datetime'], x['end_datetime']) for x in resp.json['data']] == [
('2023-03-10 10:00:00', '2023-03-10 10:30:00'),
('2023-03-10 10:30:00', '2023-03-10 11:00:00'),
]