statistics: remove all forms filter option (#80462)
gitea/wcs/pipeline/head This commit looks good
Details
gitea/wcs/pipeline/head This commit looks good
Details
This commit is contained in:
parent
62d178f73c
commit
00f84bfa12
|
@ -144,7 +144,6 @@ def test_statistics_index_forms(pub):
|
|||
resp = get_app(pub).get(sign_uri('/api/statistics/'))
|
||||
form_filter = [x for x in resp.json['data'][0]['filters'] if x['id'] == 'form'][0]
|
||||
assert form_filter['options'] == [
|
||||
{'id': '_all', 'label': 'All Forms'},
|
||||
{'id': 'test-1', 'label': 'test 1'},
|
||||
{'id': 'test-2', 'label': 'test 2'},
|
||||
]
|
||||
|
@ -165,7 +164,6 @@ def test_statistics_index_forms(pub):
|
|||
resp = get_app(pub).get(sign_uri('/api/statistics/'))
|
||||
form_filter = [x for x in resp.json['data'][0]['filters'] if x['id'] == 'form'][0]
|
||||
assert form_filter['options'] == [
|
||||
[None, [{'id': '_all', 'label': 'All Forms'}]],
|
||||
[
|
||||
'Category A',
|
||||
[
|
||||
|
@ -190,7 +188,6 @@ def test_statistics_index_forms(pub):
|
|||
resp = get_app(pub).get(sign_uri('/api/statistics/'))
|
||||
form_filter = [x for x in resp.json['data'][0]['filters'] if x['id'] == 'form'][0]
|
||||
assert form_filter['options'] == [
|
||||
[None, [{'id': '_all', 'label': 'All Forms'}]],
|
||||
[
|
||||
'Category A',
|
||||
[
|
||||
|
|
|
@ -93,10 +93,8 @@ class IndexView(RestrictedView):
|
|||
},
|
||||
{
|
||||
'id': 'form',
|
||||
'label': _('Form'),
|
||||
'label': _('Form(s)'),
|
||||
'options': self.get_form_options(FormDef),
|
||||
'required': True,
|
||||
'default': '_all',
|
||||
'has_subfilters': True,
|
||||
'multiple': True,
|
||||
},
|
||||
|
@ -181,15 +179,13 @@ class IndexView(RestrictedView):
|
|||
|
||||
@staticmethod
|
||||
def get_form_options(formdef_class, include_all_option=True):
|
||||
all_forms_option = [{'id': '_all', 'label': _('All Forms')}]
|
||||
|
||||
forms = formdef_class.select(lightweight=True)
|
||||
forms.sort(key=lambda x: misc.simplify(x.name))
|
||||
|
||||
forms_with_category = [x for x in forms if x.category]
|
||||
if not forms_with_category:
|
||||
form_options = [{'id': x.url_name, 'label': x.name} for x in forms]
|
||||
return all_forms_option + form_options if include_all_option else form_options
|
||||
return form_options
|
||||
|
||||
form_options = collections.defaultdict(list)
|
||||
for x in forms_with_category:
|
||||
|
@ -211,9 +207,6 @@ class IndexView(RestrictedView):
|
|||
if forms_without_category_options:
|
||||
form_options.append((_('Misc'), forms_without_category_options))
|
||||
|
||||
if include_all_option:
|
||||
form_options = [(None, all_forms_option)] + form_options
|
||||
|
||||
return form_options
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue