Projet

Général

Profil

0001-misc-show-form-description-in-links-list-even-if-ini.patch

Corentin Séchet, 31 octobre 2022 11:59

Télécharger (2,6 ko)

Voir les différences:

Subject: [PATCH] misc: show form description in links list even if initially
 hidden

 .../public/templates/combo/link-list-cell.html |  6 +++++-
 tests/wcs/test_all.py                          | 18 ++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)
combo/public/templates/combo/link-list-cell.html
25 25
      {% if more_links %}
26 26
        <ul style="display: none" class="more-items" id="more-items-{{ cell.get_reference }}" aria-labelledby="btn-more-items-{{ cell.get_reference }}">
27 27
          {% for link in more_links %}
28
            <li class="more-items--item {{ link.css_classes|default:""|join:" " }}"><a href="{{ link.url }}">{{ link.title }}</a></li>
28
            <li class="more-items--item {{ link.css_classes|default:""|join:" " }}">{% if link.is_form %}
29
              {% include "combo/wcs/form_link_fragment.html" with form=link %}
30
            {% else %}
31
              <a href="{{ link.url }}">{{ link.title }}</a>
32
            {% endif %}</li>
29 33
          {% endfor %}
30 34
      {% endif %}
31 35
    </ul>
tests/wcs/test_all.py
1876 1876
    resp = app.get('/test_list_of_links_with_form_render/')
1877 1877
    assert PyQuery(resp.text).find('.links-list li').attr('class') == 'keyword-bar'
1878 1878

  
1879
    link.cached_json = {'description': 'en outre, on est des loutres'}
1880
    link.save()
1881
    resp = app.get('/test_list_of_links_with_form_render/')
1882
    assert PyQuery(resp.text).find('.links-list li .description').text() == 'en outre, on est des loutres'
1883

  
1884
    WcsFormCell.objects.create(
1885
        page=page,
1886
        placeholder=cell.link_placeholder,
1887
        cached_title='Another title',
1888
        cached_url='http://example2.com/',
1889
        order=1,
1890
        cached_json={'description': 'ça poutre'},
1891
    )
1892
    cell.limit = 1
1893
    cell.save()
1894
    resp = app.get('/test_list_of_links_with_form_render/')
1895
    assert PyQuery(resp.text).find('.links-list ul.more-items li .description').text() == 'ça poutre'
1896

  
1879 1897

  
1880 1898
def test_view_page_with_wcs_cells_num_queries(app, admin_user):
1881 1899
    page = Page.objects.create(title='bar', slug='index', order=1)
1882
-