api: add end_datetime in event details (#60789) #48
|
@ -492,6 +492,7 @@ def get_event_detail(
|
|||
'agenda_label': agenda.label,
|
||||
'date': format_response_date(event.start_datetime),
|
||||
'datetime': format_response_datetime(event.start_datetime),
|
||||
'end_datetime': format_response_datetime(event.end_datetime) if event.end_datetime else '',
|
||||
'description': event.description,
|
||||
'pricing': event.pricing,
|
||||
'url': event.url,
|
||||
|
@ -1089,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)},
|
||||
|
|
|
@ -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'),
|
||||
]
|
||||
|
|
|
@ -47,6 +47,7 @@ def test_status(app, user):
|
|||
'agenda_label': 'Foo bar',
|
||||
'date': localtime(event.start_datetime).strftime('%Y-%m-%d'),
|
||||
'datetime': localtime(event.start_datetime).strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'end_datetime': '',
|
||||
'description': None,
|
||||
'pricing': None,
|
||||
'url': None,
|
||||
|
@ -84,6 +85,7 @@ def test_status(app, user):
|
|||
'agenda_label': 'Foo bar',
|
||||
'date': localtime(event.start_datetime).strftime('%Y-%m-%d'),
|
||||
'datetime': localtime(event.start_datetime).strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'end_datetime': '',
|
||||
'description': None,
|
||||
'pricing': None,
|
||||
'url': None,
|
||||
|
@ -454,6 +456,21 @@ def test_add_event(app, user):
|
|||
app.delete('/api/agenda/%s/event/' % agenda.slug, status=405) # forbidden
|
||||
|
||||
|
||||
@pytest.mark.freeze_time('2023-03-09')
|
||||
def test_add_event_end_datetime(app, user):
|
||||
agenda = Agenda.objects.create(label='Foo bar', maximal_booking_delay=0)
|
||||
api_url = '/api/agenda/%s/event/' % (agenda.slug)
|
||||
app.authorization = ('Basic', ('john.doe', 'password'))
|
||||
|
||||
# add an event
|
||||
params = {'start_datetime': '2023-03-10 14:00', 'places': 10, 'duration': 30}
|
||||
resp = app.post_json(api_url, params=params)
|
||||
assert not resp.json['err']
|
||||
assert resp.json['data']['id'] == 'foo-bar-event'
|
||||
assert resp.json['data']['datetime'] == '2023-03-10 14:00:00'
|
||||
assert resp.json['data']['end_datetime'] == '2023-03-10 14:30:00'
|
||||
|
||||
|
||||
@pytest.mark.freeze_time('2021-11-01')
|
||||
def test_update_event(app, user):
|
||||
api_url = '/api/agenda/%s/event/%s/' % ('nop', 'nop')
|
||||
|
|
Loading…
Reference in New Issue