wcs: add support for qualifying assets with an optional suffix (#27630)

This commit is contained in:
Frédéric Péters 2018-10-29 12:16:22 +01:00
parent 0c7b57fad0
commit 7a04dbba74
2 changed files with 19 additions and 4 deletions

View File

@ -104,10 +104,14 @@ class WcsFormCell(CellBase):
def get_asset_slots(self):
slots = {}
for slot_template_key, slot_template_data in settings.WCS_FORM_ASSET_SLOTS.items():
suffix = ''
if slot_template_data.get('suffix'):
suffix = ' (%s)' % slot_template_data['suffix']
slots['wcs:form:%s:%s' % (slot_template_key, self.formdef_reference)] = {
'label': u'%(prefix)s%(label)s' % {
'label': u'%(prefix)s%(label)s%(suffix)s' % {
'prefix': slot_template_data['prefix'],
'label': self.cached_title}}
'label': self.cached_title,
'suffix': suffix}}
return slots
@ -143,10 +147,14 @@ class WcsCommonCategoryCell(CellBase):
def get_asset_slots(self):
slots = {}
for slot_template_key, slot_template_data in settings.WCS_CATEGORY_ASSET_SLOTS.items():
suffix = ''
if slot_template_data.get('suffix'):
suffix = ' (%s)' % slot_template_data['suffix']
slots['wcs:category:%s:%s' % (slot_template_key, self.category_reference)] = {
'label': u'%(prefix)s%(label)s' % {
'label': u'%(prefix)s%(label)s%(suffix)s' % {
'prefix': slot_template_data['prefix'],
'label': self.cached_title}}
'label': self.cached_title,
'suffix': suffix}}
return slots

View File

@ -650,6 +650,13 @@ def test_cell_assets(app, admin_user):
assert u'>Logo — Test 9<' in resp.text
assert u'>Picture — form title<' in resp.text
with override_settings(
WCS_CATEGORY_ASSET_SLOTS={'logo': {'prefix': 'Logo', 'suffix': 'test'}},
WCS_FORM_ASSET_SLOTS={'picture': {'prefix': 'Picture', 'suffix': 'test'}}):
resp = app.get('/manage/assets/')
assert u'>Logo — Test 9 (test)<' in resp.text
assert u'>Picture — form title (test)<' in resp.text
@wcsctl_present
def test_tracking_code_search(app):
assert len(app.get('/api/search/tracking-code/').json.get('data')) == 0