wcs: include selected site name in additional label (#11257)
This commit is contained in:
parent
1c41179455
commit
beaefbe8b7
|
@ -189,6 +189,14 @@ class WcsDataBaseCell(CellBase, WcsBlurpMixin):
|
|||
class Meta:
|
||||
abstract = True
|
||||
|
||||
def get_additional_label(self):
|
||||
wcs_sites = dict([(x, y.get('title')) for x, y in get_wcs_services().items()])
|
||||
if len(wcs_sites.keys()) < 2:
|
||||
return ''
|
||||
if self.wcs_site in wcs_sites:
|
||||
return wcs_sites[self.wcs_site]
|
||||
return _('All Sites')
|
||||
|
||||
def get_form_fields(self):
|
||||
if len(get_wcs_services()) == 1:
|
||||
return []
|
||||
|
@ -249,11 +257,16 @@ class WcsCurrentFormsCell(WcsUserDataBaseCell):
|
|||
return 'combo/wcs/current_forms.html'
|
||||
|
||||
def get_additional_label(self):
|
||||
initial_label = super(WcsCurrentFormsCell, self).get_additional_label()
|
||||
if self.current_forms and self.done_forms:
|
||||
return _('All Forms')
|
||||
if self.done_forms:
|
||||
return _('Done Forms')
|
||||
return _('Current Forms')
|
||||
label = _('All Forms')
|
||||
elif self.done_forms:
|
||||
label = _('Done Forms')
|
||||
else:
|
||||
label = _('Current Forms')
|
||||
if initial_label:
|
||||
return '%s - %s' % (initial_label, label)
|
||||
return label
|
||||
|
||||
def render(self, context):
|
||||
context[self.variable_name] = self.get_data(context)
|
||||
|
|
|
@ -260,6 +260,18 @@ def test_current_forms_cell_setup():
|
|||
assert form.fields['wcs_site'].widget.choices == [
|
||||
('', 'All'), (u'default', u'test'), (u'other', u'test2')]
|
||||
assert 'current_forms' in form.fields
|
||||
assert cell.get_additional_label() == 'All Sites - Current Forms'
|
||||
cell.wcs_site = 'default'
|
||||
assert cell.get_additional_label() == 'test - Current Forms'
|
||||
cell.wcs_site = None
|
||||
|
||||
cell.current_forms = True
|
||||
cell.done_forms = True
|
||||
assert cell.get_additional_label() == 'All Sites - All Forms'
|
||||
|
||||
cell.current_forms = False
|
||||
cell.done_forms = True
|
||||
assert cell.get_additional_label() == 'All Sites - Done Forms'
|
||||
|
||||
try:
|
||||
# check there is not wcs_site field if there's a single one defined in
|
||||
|
@ -270,6 +282,7 @@ def test_current_forms_cell_setup():
|
|||
form_class = cell.get_default_form_class()
|
||||
form = form_class()
|
||||
assert not 'wcs_site' in form.fields.keys()
|
||||
assert cell.get_additional_label() == 'Done Forms'
|
||||
finally:
|
||||
# restore original settings
|
||||
settings.KNOWN_SERVICES = temp_settings
|
||||
|
|
Loading…
Reference in New Issue