wcs: order wcs_sites by title (#10564)

This commit is contained in:
Serghei Mihai 2016-03-13 18:31:40 +01:00
parent 156f9fc0e7
commit e03cb0846c
2 changed files with 3 additions and 2 deletions

View File

@ -184,7 +184,9 @@ class WcsDataBaseCell(CellBase, WcsBlurpMixin):
if len(get_wcs_services()) == 1:
return None
combo_wcs_sites = [('', _('All'))]
combo_wcs_sites.extend([(x, y.get('title')) for x, y in get_wcs_services().items()])
wcs_sites = [(x, y.get('title')) for x, y in get_wcs_services().items()]
wcs_sites.sort(key=lambda x: x[1])
combo_wcs_sites.extend(wcs_sites)
return model_forms.modelform_factory(self.__class__,
fields=['wcs_site'],
widgets={'wcs_site': Select(choices=combo_wcs_sites)})

View File

@ -254,7 +254,6 @@ def test_current_forms_cell_setup():
form = form_class()
assert form.fields['wcs_site'].widget.choices == [
('', 'All'), (u'default', u'test'), (u'other', u'test2')]
try:
# check there is not wcs_site field if there's a single one defined in
# the configuration