wcs: urlize card content field values (#59931)
This commit is contained in:
parent
99b0682efb
commit
ec9ff0c493
|
@ -16,7 +16,7 @@
|
|||
<a href="{% make_public_url url=value.url %}" download="{{ value.filename }}">{{ value.filename }}</a>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{{ value|default:"" }}
|
||||
{{ value|default:""|urlize }}
|
||||
{% endif %}
|
||||
{% if not mode == 'inline' %}</span>{% endif %}
|
||||
{% endif %}
|
||||
|
|
|
@ -176,6 +176,7 @@ WCS_CARDDEF_SCHEMA = {
|
|||
{'label': 'Field E', 'varname': 'fielde', 'type': 'text'},
|
||||
{'label': 'Field F', 'varname': 'fieldf', 'type': 'text', 'pre': True},
|
||||
{'label': 'Field G', 'varname': 'fieldg', 'type': 'email'},
|
||||
{'label': 'Field H', 'varname': 'fieldh', 'type': 'string'},
|
||||
{'label': 'Related', 'varname': 'related', 'type': 'item'},
|
||||
{'label': 'Page', 'type': 'page'},
|
||||
{'label': 'Comment', 'type': 'comment'},
|
||||
|
@ -200,6 +201,7 @@ WCS_CARD_DATA = {
|
|||
'fielde': 'lorem<strong>ipsum\n\nhello world',
|
||||
'fieldf': 'lorem<strong>ipsum\n\nhello world',
|
||||
'fieldg': 'test@localhost',
|
||||
'fieldh': 'https://www.example.net/',
|
||||
'related': 'Foo Bar',
|
||||
'related_raw': 42,
|
||||
'related_structured': {'id': 42, 'text': 'blah'},
|
||||
|
@ -1946,6 +1948,32 @@ def test_card_cell_render_email_field(mock_send, context):
|
|||
)
|
||||
|
||||
|
||||
@mock.patch('combo.apps.wcs.utils.requests.send', side_effect=mocked_requests_send)
|
||||
def test_card_cell_render_string_with_url_field(mock_send, context):
|
||||
page = Page.objects.create(title='xxx', template_name='standard')
|
||||
cell = WcsCardInfosCell(page=page, placeholder='content', order=0)
|
||||
cell.carddef_reference = 'default:card_model_1'
|
||||
cell.custom_title = 'Foo bar {{ card.fields.title }}'
|
||||
cell.save()
|
||||
|
||||
context['card_model_1_id'] = 11
|
||||
request = RequestFactory().get('/')
|
||||
cell.modify_global_context(context, request)
|
||||
cell.repeat_index = 0
|
||||
context['synchronous'] = True # to get fresh content
|
||||
|
||||
result = cell.render(context)
|
||||
|
||||
assert (
|
||||
PyQuery(result).find('span.label:contains("Field H") + .value a').text() == 'https://www.example.net/'
|
||||
)
|
||||
|
||||
assert (
|
||||
PyQuery(result).find('span.label:contains("Field H") + .value a').attr['href']
|
||||
== 'https://www.example.net/'
|
||||
)
|
||||
|
||||
|
||||
@mock.patch('combo.apps.wcs.utils.requests.send', side_effect=mocked_requests_send)
|
||||
def test_card_cell_render_custom_schema(mock_send, context):
|
||||
page = Page.objects.create(title='xxx', template_name='standard')
|
||||
|
|
Loading…
Reference in New Issue