misc: include cell key in config json cell CSS class names (#23079)

This commit is contained in:
Frédéric Péters 2018-04-10 21:59:09 +02:00
parent dbd744e3d2
commit 69ac9adf88
2 changed files with 5 additions and 0 deletions

View File

@ -1098,6 +1098,10 @@ class ConfigJsonCell(JsonCellBase):
def set_variant(self, variant):
self.key = variant
@property
def css_class_names(self):
return super(ConfigJsonCell, self).css_class_names + ' ' + self.key
@property
def ajax_refresh(self):
return settings.JSON_CELL_TYPES[self.key].get('auto_refresh', None)

View File

@ -304,6 +304,7 @@ def test_config_json_cell():
assert cell.get_label() == 'Foobar'
assert cell.url == 'http://test/'
assert cell.template_name == 'combo/json/foobar.html'
assert cell.css_class_names.split() == ['configjsoncell', 'foobar']
with mock.patch('combo.utils.requests.get') as requests_get:
requests_get.return_value = mock.Mock(content=json.dumps({'hello': 'world'}), status_code=200)