wcs: fix card rendering with missing varname in custom_schema (#68598)
gitea-wip/combo/pipeline/head There was a failure building this commit Details
gitea/combo/pipeline/head Something is wrong with the build of this commit Details

This commit is contained in:
Lauréline Guérin 2022-08-31 22:23:32 +02:00
parent 202c614849
commit d1b26246b7
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 12 additions and 0 deletions

View File

@ -37,6 +37,7 @@
{% endwith %}
</div>
{% else %}
{% if item.varname %}
{% with fields_by_varnames|get:item.varname as field %}
{% if field %}
{% with card.fields|get:item.varname as value %}
@ -60,6 +61,7 @@
{% endwith %}
{% endif %}
{% endwith %}
{% endif %}
{% endif %}
{% endfor%}
</div>

View File

@ -1291,6 +1291,16 @@ def test_card_cell_card_mode_render_custom_schema_card_field(mock_send, context)
assert PyQuery(result).find('.value a').text() == 'https://www.example.net/'
assert PyQuery(result).find('.value a').attr['href'] == 'https://www.example.net/'
# wrong configuration, missing varname
cell.custom_schema['cells'][0] = {
'field_content': 'label-and-value',
'display_mode': 'text',
}
cell.save()
result = cell.render(context)
assert PyQuery(result).find('.label') == []
assert PyQuery(result).find('.value') == []
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
def test_card_cell_card_mode_render_custom_schema_card_empty_field(mock_send, context):