Projet

Général

Profil

0001-wcs-add-generic-support-for-a-picture-in-forms-of-a-.patch

Frédéric Péters, 13 novembre 2018 22:12

Télécharger (2,47 ko)

Voir les différences:

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

 .../wcs/templates/combo/wcs/forms_of_category.html     | 10 +++++++++-
 combo/settings.py                                      |  7 ++++++-
 tests/test_wcs.py                                      |  5 +++--
 3 files changed, 18 insertions(+), 4 deletions(-)
combo/apps/wcs/templates/combo/wcs/forms_of_category.html
1
{% load i18n %}
1
{% load assets i18n %}
2 2
{% block cell-content %}
3 3
<div class="wcs-forms-of-category-{{slug}}">
4
{% block cell-header %}
4 5
<h2>{{ title }}</h2>
6
{% get_asset "wcs:category:picture:"|add:cell.category_reference as asset %}
7
{% if asset %}
8
  <picture>
9
  <img src="{% asset_url asset size="440x240" crop="center" %}" alt="">
10
  </picture>
11
{% endif %}
5 12
{% if description %}
6 13
<div class="intro">
7 14
{{ description|safe }}
8 15
</div>
9 16
{% endif %}
17
{% endblock %}
10 18
<ul>
11 19
{% for form in forms %}
12 20
<li class="{% if form.authentication_required %}required-authentication{% endif %}
combo/settings.py
305 305

  
306 306
# dynamic slots created for wcs category/form cells
307 307
# example: {'picture': {'prefix': 'Picture'}}
308
WCS_CATEGORY_ASSET_SLOTS = {}
308
WCS_CATEGORY_ASSET_SLOTS = {
309
    'picture': {
310
        'prefix': _('Picture'),
311
    },
312
}
313

  
309 314
WCS_FORM_ASSET_SLOTS = {}
310 315

  
311 316
# hide work-in-progress/experimental/broken/legacy/whatever cells for now
tests/test_wcs.py
640 640
    cell.save()
641 641

  
642 642
    app = login(app)
643
    resp = app.get('/manage/assets/')
644
    assert 'have any asset yet.' in resp.text
643
    with override_settings(WCS_CATEGORY_ASSET_SLOTS={}):
644
        resp = app.get('/manage/assets/')
645
        assert 'have any asset yet.' in resp.text
645 646

  
646 647
    with override_settings(
647 648
            WCS_CATEGORY_ASSET_SLOTS={'logo': {'prefix': 'Logo'}},
648
-