api: return agenda booking_form_url (#72545)
gitea/chrono/pipeline/head Build queued... Details

This commit is contained in:
Valentin Deniaud 2023-06-29 15:09:00 +02:00
parent cce129b8bc
commit 9125b7af10
3 changed files with 13 additions and 0 deletions

View File

@ -575,6 +575,7 @@ class AgendaSerializer(serializers.ModelSerializer):
'edit_role',
'view_role',
'category',
'booking_form_url',
'mark_event_checked_auto',
'disable_check_update',
'booking_check_filters',

View File

@ -95,6 +95,7 @@ def get_agenda_detail(request, agenda, check_events=False):
}
if check_events:
agenda_detail['opened_events_available'] = bool(agenda.get_open_events().filter(full=False))
agenda_detail['booking_form_url'] = agenda.get_booking_form_url()
elif agenda.accept_meetings():
agenda_detail['api'] = {
'meetings_url': request.build_absolute_uri(

View File

@ -72,6 +72,7 @@ def test_agendas_api(app):
'category': 'category-a',
'category_label': 'Category A',
'events_type': 'type-a',
'booking_form_url': None,
'api': {
'datetimes_url': 'http://testserver/api/agenda/foo-bar/datetimes/',
'fillslots_url': 'http://testserver/api/agenda/foo-bar/fillslots/',
@ -92,6 +93,7 @@ def test_agendas_api(app):
'category': 'category-a',
'category_label': 'Category A',
'events_type': 'type-b',
'booking_form_url': None,
'api': {
'datetimes_url': 'http://testserver/api/agenda/foo-bar-2/datetimes/',
'fillslots_url': 'http://testserver/api/agenda/foo-bar-2/fillslots/',
@ -112,6 +114,7 @@ def test_agendas_api(app):
'category': None,
'category_label': None,
'events_type': None,
'booking_form_url': None,
'api': {
'datetimes_url': 'http://testserver/api/agenda/foo-bar-3/datetimes/',
'fillslots_url': 'http://testserver/api/agenda/foo-bar-3/fillslots/',
@ -466,6 +469,7 @@ def test_agenda_api_delete_busy(app, user):
@pytest.mark.freeze_time('2021-07-09T08:00:00.0+02:00')
def test_add_agenda(app, user, settings):
settings.TEMPLATE_VARS = {'eservices_url': 'http://demarches/'}
events_type = EventsType.objects.create(label='Type A')
category_a = Category.objects.create(label='Category A')
api_url = '/api/agenda/'
@ -606,6 +610,7 @@ def test_add_agenda(app, user, settings):
'mark_event_checked_auto': False,
'disable_check_update': True,
'booking_check_filters': 'foo,bar,baz',
'booking_form_url': '{{ eservices_url }}backoffice/submission/inscription-aux-activites/',
}
resp = app.post_json(api_url, params=params)
assert not resp.json['err']
@ -622,8 +627,14 @@ def test_add_agenda(app, user, settings):
assert agenda.mark_event_checked_auto is False
assert agenda.disable_check_update is True
assert agenda.booking_check_filters == 'foo,bar,baz'
assert agenda.booking_form_url == '{{ eservices_url }}backoffice/submission/inscription-aux-activites/'
assert Desk.objects.filter(agenda=agenda, slug='_exceptions_holder').exists()
assert (
resp.json['data'][0]['booking_form_url']
== 'http://demarches/backoffice/submission/inscription-aux-activites/'
)
resp = app.get('/api/agendas/datetimes/?agendas=%s' % agenda.slug)
assert 'data' in resp.json