api: add label to event details (#54932)

This commit is contained in:
Thomas NOËL 2021-06-17 01:39:36 +02:00 committed by Thomas NOEL
parent abb2be9cdb
commit f3bb5e44ac
3 changed files with 4 additions and 0 deletions

View File

@ -455,6 +455,7 @@ def get_event_detail(request, event, agenda=None, min_places=1):
'id': event.slug,
'slug': event.slug, # kept for compatibility
'text': event_text,
'label': event.label or '',
'datetime': format_response_datetime(event.start_datetime),
'description': event.description,
'pricing': event.pricing,

View File

@ -392,6 +392,7 @@ def test_status(app, user):
'id': 'event-slug',
'slug': 'event-slug',
'text': str(event),
'label': '',
'datetime': localtime(event.start_datetime).strftime('%Y-%m-%d %H:%M:%S'),
'description': None,
'pricing': None,

View File

@ -103,11 +103,13 @@ def test_datetime_api_label(app):
)
resp = app.get('/api/agenda/%s/datetimes/' % agenda.slug)
assert 'Hello world' == resp.json['data'][0]['text']
assert 'Hello world' == resp.json['data'][0]['label']
agenda.event_display_template = '{{ event.label }} - {{ event.start_datetime }}'
agenda.save()
resp = app.get('/api/agenda/%s/datetimes/' % agenda.slug)
assert resp.json['data'][0]['text'] == 'Hello world - May 7, 2021, 4 p.m.'
assert resp.json['data'][0]['label'] == 'Hello world'
Booking.objects.create(event=event)
agenda.event_display_template = (