api: only show presence filter for events agendas in statistics (#74327)
gitea/chrono/pipeline/head This commit looks good
Details
gitea/chrono/pipeline/head This commit looks good
Details
This commit is contained in:
parent
d895b810b3
commit
73192ed8bf
|
@ -3240,9 +3240,14 @@ class BookingsStatistics(APIView):
|
|||
.values_list('extra_data_keys', flat=True)
|
||||
)
|
||||
|
||||
group_by_options = [{'id': 'user_was_present', 'label': _('Presence/Absence')}] + [
|
||||
{'id': x, 'label': x.capitalize()} for x in extra_data_keys
|
||||
]
|
||||
group_by_options = [{'id': x, 'label': x.capitalize()} for x in extra_data_keys]
|
||||
|
||||
if any(x.kind == 'events' for x in agendas):
|
||||
group_by_options = [{'id': 'user_was_present', 'label': _('Presence/Absence')}] + group_by_options
|
||||
|
||||
if not group_by_options:
|
||||
return []
|
||||
|
||||
return [
|
||||
{
|
||||
'id': 'group_by',
|
||||
|
|
|
@ -203,6 +203,14 @@ def test_statistics_bookings_subfilters_list(app, user):
|
|||
resp = app.get(url + '?agenda=category:category-b')
|
||||
assert len(resp.json['data']['subfilters'][0]['options']) == 1
|
||||
|
||||
Agenda.objects.create(label='Meetings', kind='meetings', category=category_b)
|
||||
|
||||
resp = app.get(url + '?agenda=meetings')
|
||||
assert resp.json['data']['subfilters'] == []
|
||||
|
||||
resp = app.get(url + '?agenda=category:category-b')
|
||||
assert len(resp.json['data']['subfilters'][0]['options']) == 1
|
||||
|
||||
resp = app.get(url + '?agenda=xxx', status=400)
|
||||
assert resp.json['err_desc'] == 'No agendas found.'
|
||||
|
||||
|
|
Loading…
Reference in New Issue