wcs: card cell with table mode can use cards cell assets (#68063)
This commit is contained in:
parent
5a1f1a9a51
commit
0712cbe5d6
|
@ -1605,6 +1605,18 @@ class WcsCardInfosCell(CardMixin, CellBase):
|
|||
|
||||
return custom_schema
|
||||
|
||||
def get_asset_slot_key(self, key):
|
||||
if self.display_mode == 'table':
|
||||
# for legacy: card cell with table mode should use assets of old cards cell
|
||||
return 'cell:wcs_wcscardscell:%s:%s' % (key, self.get_slug_for_asset())
|
||||
return super().get_asset_slot_key(key)
|
||||
|
||||
def get_asset_slot_templates(self):
|
||||
if self.display_mode == 'table' and settings.COMBO_CELL_ASSET_SLOTS.get('wcs_wcscardscell'):
|
||||
# for legacy: card cell with table mode should use assets of old cards cell
|
||||
return settings.COMBO_CELL_ASSET_SLOTS['wcs_wcscardscell']
|
||||
return super().get_asset_slot_templates()
|
||||
|
||||
|
||||
@register_cell_class
|
||||
class TrackingCodeInputCell(CellBase):
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% load assets i18n %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block cell-content %}
|
||||
{% if not card_not_found %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% load assets i18n %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block cell-content %}
|
||||
|
||||
|
|
|
@ -2471,3 +2471,45 @@ def test_card_file_redirection(mock_send, app):
|
|||
|
||||
# invalid session key
|
||||
resp = app.get(file_url.replace('file/', 'file/X'), status=403)
|
||||
|
||||
|
||||
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
|
||||
def test_card_cell_assets(mock_send, settings, app, admin_user):
|
||||
page = Page.objects.create(title='xxx', slug='test_cell_assets', template_name='standard')
|
||||
cell1 = WcsCardInfosCell.objects.create(
|
||||
page=page,
|
||||
placeholder='content',
|
||||
order=0,
|
||||
carddef_reference='default:card_model_1',
|
||||
display_mode='card',
|
||||
slug='slug1',
|
||||
)
|
||||
cell2 = WcsCardInfosCell.objects.create(
|
||||
page=page,
|
||||
placeholder='content',
|
||||
order=0,
|
||||
carddef_reference='default:card_model_1',
|
||||
display_mode='table',
|
||||
slug='slug2',
|
||||
)
|
||||
|
||||
app = login(app)
|
||||
settings.COMBO_CELL_ASSET_SLOTS = {}
|
||||
resp = app.get('/manage/assets/')
|
||||
assert 'have any asset yet.' in resp.text
|
||||
|
||||
settings.COMBO_CELL_ASSET_SLOTS = {
|
||||
'wcs_wcscardscell': {
|
||||
'logo': {
|
||||
'prefix': 'Logo',
|
||||
},
|
||||
},
|
||||
'wcs_wcscardinfoscell': {
|
||||
'picture': {
|
||||
'prefix': 'Picture',
|
||||
},
|
||||
},
|
||||
}
|
||||
resp = app.get('/manage/assets/')
|
||||
assert 'Picture — %s' % cell1.get_label_for_asset() in resp.text
|
||||
assert 'Logo — %s' % cell2.get_label_for_asset() in resp.text
|
||||
|
|
Loading…
Reference in New Issue