api: display category on agenda details (#57670)

This commit is contained in:
Nicolas Roche 2021-10-08 09:47:52 +02:00
parent 60aea84fb3
commit 0660f76ee7
2 changed files with 9 additions and 1 deletions

View File

@ -355,6 +355,7 @@ def get_agenda_detail(request, agenda, check_events=False):
'maximal_booking_delay': agenda.maximal_booking_delay,
'edit_role': agenda.edit_role.name if agenda.edit_role else None,
'view_role': agenda.view_role.name if agenda.view_role else None,
'category': agenda.category.slug if agenda.category else None,
}
if agenda.kind == 'meetings':
@ -705,7 +706,7 @@ class Agendas(APIView):
def get(self, request, format=None):
agendas_queryset = (
Agenda.objects.all()
.select_related('absence_reasons_group')
.select_related('absence_reasons_group', 'category')
.prefetch_related('resources', 'absence_reasons_group__absence_reasons')
.order_by('label')
)

View File

@ -68,6 +68,7 @@ def test_agendas_api(app):
'maximal_booking_delay': 56,
'edit_role': 'Edit',
'view_role': None,
'category': 'category-a',
'absence_reasons': [
{'id': reason.slug, 'slug': reason.slug, 'text': reason.label, 'label': reason.label},
{'id': reason2.slug, 'slug': reason2.slug, 'text': reason2.label, 'label': reason2.label},
@ -87,6 +88,7 @@ def test_agendas_api(app):
'maximal_booking_delay': 56,
'edit_role': None,
'view_role': None,
'category': 'category-a',
'api': {
'datetimes_url': 'http://testserver/api/agenda/foo-bar-2/datetimes/',
'fillslots_url': 'http://testserver/api/agenda/foo-bar-2/fillslots/',
@ -102,6 +104,7 @@ def test_agendas_api(app):
'maximal_booking_delay': 56,
'edit_role': None,
'view_role': None,
'category': None,
'absence_reasons': [
{'id': reason.slug, 'slug': reason.slug, 'text': reason.label, 'label': reason.label},
{'id': reason2.slug, 'slug': reason2.slug, 'text': reason2.label, 'label': reason2.label},
@ -119,6 +122,7 @@ def test_agendas_api(app):
'maximal_booking_delay': 56,
'edit_role': None,
'view_role': 'View',
'category': 'category-b',
'kind': 'meetings',
'resources': [
{'id': 'resource-1', 'text': 'Resource 1', 'description': 'Foo bar Resource 1'},
@ -139,6 +143,7 @@ def test_agendas_api(app):
'maximal_booking_delay': 56,
'edit_role': None,
'view_role': None,
'category': None,
'kind': 'meetings',
'resources': [],
'api': {
@ -156,6 +161,7 @@ def test_agendas_api(app):
'maximal_booking_delay': 56,
'edit_role': 'Edit',
'view_role': 'View',
'category': None,
'kind': 'virtual',
'api': {
'meetings_url': 'http://testserver/api/agenda/virtual-agenda/meetings/',
@ -505,6 +511,7 @@ def test_virtual_agenda_detail(app, virtual_meetings_agenda):
'maximal_booking_delay': None,
'edit_role': None,
'view_role': None,
'category': None,
'kind': 'virtual',
'api': {
'meetings_url': 'http://testserver/api/agenda/%s/meetings/' % virtual_meetings_agenda.slug,