From f21dd8dab119fa0513026686f6283ff0afed4bde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 29 Oct 2018 12:16:22 +0100 Subject: [PATCH] wcs: add support for qualifying assets with an optional suffix (#27630) --- combo/apps/wcs/models.py | 16 ++++++++++++---- tests/test_wcs.py | 7 +++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/combo/apps/wcs/models.py b/combo/apps/wcs/models.py index 71f96814..c5440dab 100644 --- a/combo/apps/wcs/models.py +++ b/combo/apps/wcs/models.py @@ -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 diff --git a/tests/test_wcs.py b/tests/test_wcs.py index a4744021..c172cdd8 100644 --- a/tests/test_wcs.py +++ b/tests/test_wcs.py @@ -651,6 +651,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 -- 2.19.1