statistics: remove all forms filter option (#80462) #619
|
@ -145,7 +145,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'},
|
||||
]
|
||||
|
@ -166,7 +165,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',
|
||||
[
|
||||
|
@ -191,7 +189,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
Normale que le required saute ?
Oui c'était déjà ceinture et bretelles avant, plus bas on fait
donc pas de pb si ce paramètre est pas là.
Et fonctionnellement c'est parce qu'on remplace le select multiple par un champ select2, et donc au lieu d'avoir « Tous les formulaires » pour filtrer sur rien, on a le choix vide