Projet

Général

Profil

0001-wcs-fix-card-rendering-with-missing-varname-in-custo.patch

Lauréline Guérin, 31 août 2022 22:24

Télécharger (1,97 ko)

Voir les différences:

Subject: [PATCH] wcs: fix card rendering with missing varname in custom_schema
 (#68598)

 combo/apps/wcs/templates/combo/wcs/card.html |  2 ++
 tests/wcs/test_card.py                       | 10 ++++++++++
 2 files changed, 12 insertions(+)
combo/apps/wcs/templates/combo/wcs/card.html
37 37
          {% endwith %}
38 38
        </div>
39 39
        {% else %}
40
          {% if item.varname %}
40 41
          {% with fields_by_varnames|get:item.varname as field %}
41 42
          {% if field %}
42 43
          {% with card.fields|get:item.varname as value %}
......
60 61
          {% endwith %}
61 62
          {% endif %}
62 63
          {% endwith %}
64
          {% endif %}
63 65
        {% endif %}
64 66
    {% endfor%}
65 67
  </div>
tests/wcs/test_card.py
1291 1291
    assert PyQuery(result).find('.value a').text() == 'https://www.example.net/'
1292 1292
    assert PyQuery(result).find('.value a').attr['href'] == 'https://www.example.net/'
1293 1293

  
1294
    # wrong configuration, missing varname
1295
    cell.custom_schema['cells'][0] = {
1296
        'field_content': 'label-and-value',
1297
        'display_mode': 'text',
1298
    }
1299
    cell.save()
1300
    result = cell.render(context)
1301
    assert PyQuery(result).find('.label') == []
1302
    assert PyQuery(result).find('.value') == []
1303

  
1294 1304

  
1295 1305
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
1296 1306
def test_card_cell_card_mode_render_custom_schema_card_empty_field(mock_send, context):
1297
-