api: fix event meta for ocurrences (#53209)

This commit is contained in:
Lauréline Guérin 2021-04-16 15:53:31 +02:00
parent 6554c0a42c
commit e9c9655064
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 11 additions and 2 deletions

View File

@ -390,15 +390,16 @@ def is_event_disabled(event, min_places=1):
def get_event_detail(request, event, agenda=None, min_places=1):
agenda = agenda or event.agenda
event_text = force_text(event)
if event.label and event.primary_event is not None:
event.label = '%s (%s)' % (
event_text = '%s (%s)' % (
event.label,
date_format(localtime(event.start_datetime), 'DATETIME_FORMAT'),
)
return {
'id': event.slug,
'slug': event.slug, # kept for compatibility
'text': force_text(event),
'text': event_text,
'datetime': format_response_datetime(event.start_datetime),
'description': event.description,
'pricing': event.pricing,

View File

@ -5936,6 +5936,14 @@ def test_datetimes_api_meta(app, freezer):
'first_bookable_slot': None,
}
# recurring event
Event.objects.all().delete()
Event.objects.create(
slug='abc', label='Test', start_datetime=localtime(), repeat='weekly', places=5, agenda=agenda
)
resp = app.get(api_url)
assert resp.json['meta']['first_bookable_slot']['text'] == 'Test (May 27, 2017, 1:12 a.m.)'
def test_datetimes_api_meetings_agenda_meta(app, freezer):
# 2017-05-20 -> saturday