wcs: add generic support for a picture in forms of a category cell (#27972)

This commit is contained in:
Frédéric Péters 2018-10-21 12:42:40 +02:00
parent d40cb57e27
commit 9831984afb
3 changed files with 18 additions and 4 deletions

View File

@ -1,12 +1,20 @@
{% load i18n %}
{% load assets i18n %}
{% block cell-content %}
<div class="wcs-forms-of-category-{{slug}}">
{% block cell-header %}
<h2>{{ title }}</h2>
{% get_asset "wcs:category:picture:"|add:cell.category_reference as asset %}
{% if asset %}
<picture>
<img src="{% asset_url asset size="440x240" crop="center" %}" alt="">
</picture>
{% endif %}
{% if description %}
<div class="intro">
{{ description|safe }}
</div>
{% endif %}
{% endblock %}
<ul>
{% for form in forms %}
<li class="{% if form.authentication_required %}required-authentication{% endif %}

View File

@ -305,7 +305,12 @@ COMBO_ASSET_SLOTS = {}
# dynamic slots created for wcs category/form cells
# example: {'picture': {'prefix': 'Picture'}}
WCS_CATEGORY_ASSET_SLOTS = {}
WCS_CATEGORY_ASSET_SLOTS = {
'picture': {
'prefix': _('Picture'),
},
}
WCS_FORM_ASSET_SLOTS = {}
# hide work-in-progress/experimental/whatever cells for now

View File

@ -640,8 +640,9 @@ def test_cell_assets(app, admin_user):
cell.save()
app = login(app)
resp = app.get('/manage/assets/')
assert 'have any asset yet.' in resp.text
with override_settings(WCS_CATEGORY_ASSET_SLOTS={}):
resp = app.get('/manage/assets/')
assert 'have any asset yet.' in resp.text
with override_settings(
WCS_CATEGORY_ASSET_SLOTS={'logo': {'prefix': 'Logo'}},