diff --git a/combo/apps/wcs/templates/combo/wcs/card-field-as-text.html b/combo/apps/wcs/templates/combo/wcs/card-field-as-text.html
index 91f6890d..a3908309 100644
--- a/combo/apps/wcs/templates/combo/wcs/card-field-as-text.html
+++ b/combo/apps/wcs/templates/combo/wcs/card-field-as-text.html
@@ -2,5 +2,5 @@
{{ field.label }}
{% endif %}
{% if item.field_content == "value" or item.field_content == "label-and-value" %}
- {% include "combo/wcs/card-field-value.html" %}
+ {% include "combo/wcs/card-field-value.html" with empty=empty %}
{% endif %}
diff --git a/combo/apps/wcs/templates/combo/wcs/card-field-value.html b/combo/apps/wcs/templates/combo/wcs/card-field-value.html
index e13c5c83..37688a22 100644
--- a/combo/apps/wcs/templates/combo/wcs/card-field-value.html
+++ b/combo/apps/wcs/templates/combo/wcs/card-field-value.html
@@ -13,7 +13,7 @@
{{ value|date }}
{% elif field.type == "bool" and value is not None %}
{{ value|yesno }}
- {% elif field.type == "email" and value is not None %}
+ {% elif field.type == "email" and value is not None and not empty %}
{{ value }}
{% elif field.type == 'file' and value %}
{% if value.content_type|startswith:"image/" %}
diff --git a/combo/apps/wcs/templates/combo/wcs/card.html b/combo/apps/wcs/templates/combo/wcs/card.html
index 89b25067..3b3ba209 100644
--- a/combo/apps/wcs/templates/combo/wcs/card.html
+++ b/combo/apps/wcs/templates/combo/wcs/card.html
@@ -73,7 +73,7 @@
{% include "combo/wcs/card-field-as-text.html" %}
{% else %}
{% with item.empty_value as value %}
- {% include "combo/wcs/card-field-as-text.html" %}
+ {% include "combo/wcs/card-field-as-text.html" with empty=True %}
{% endwith %}
{% endif %}
{% endif %}
diff --git a/combo/apps/wcs/templates/combo/wcs/cards-field.html b/combo/apps/wcs/templates/combo/wcs/cards-field.html
index 6e9d0444..ba485b6d 100644
--- a/combo/apps/wcs/templates/combo/wcs/cards-field.html
+++ b/combo/apps/wcs/templates/combo/wcs/cards-field.html
@@ -36,7 +36,7 @@
{% if field and value %}
{% if not ul_display %}{% endif %}{% include "combo/wcs/card-field-value.html" with mode='inline' %}{% if not ul_display %} | {% endif %}
{% elif field %}
- {% if not ul_display %}{% endif %}{% include "combo/wcs/card-field-value.html" with mode='inline' value=item.empty_value %}{% if not ul_display %} | {% endif %}
+ {% if not ul_display %}{% endif %}{% include "combo/wcs/card-field-value.html" with mode='inline' value=item.empty_value empty=True %}{% if not ul_display %} | {% endif %}
{% endif %}
{% endwith %}
{% endif %}
diff --git a/tests/wcs/test_card.py b/tests/wcs/test_card.py
index a32486da..87966307 100644
--- a/tests/wcs/test_card.py
+++ b/tests/wcs/test_card.py
@@ -951,6 +951,7 @@ def test_card_cell_table_mode_render_custom_schema_card_empty_field(mock_send, c
else:
assert PyQuery(result).find('table tr td') == []
assert PyQuery(result).find('ul li:first-child').text() == value
+ return result
test('')
@@ -961,6 +962,24 @@ def test_card_cell_table_mode_render_custom_schema_card_empty_field(mock_send, c
cell.save()
test('Custom text')
+ cell.custom_schema['cells'][0] = {
+ 'varname': 'empty_email',
+ 'empty_value': '',
+ }
+ cell.save()
+ result = test('')
+ assert PyQuery(result).find('table tr:first-child td:first-child a') == []
+ assert PyQuery(result).find('ul li:first-child a') == []
+
+ cell.custom_schema['cells'][0] = {
+ 'varname': 'empty_email',
+ 'empty_value': 'Custom text',
+ }
+ cell.save()
+ result = test('Custom text')
+ assert PyQuery(result).find('table tr:first-child td:first-child a') == []
+ assert PyQuery(result).find('ul li:first-child a') == []
+
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
@pytest.mark.parametrize('nb_cells', [1, 2])
@@ -1998,6 +2017,19 @@ def test_card_cell_card_mode_render_custom_schema_card_empty_field(mock_send, co
'Empty' if field_content == 'label' else 'Custom text'
)
+ cell.custom_schema['cells'][0] = {
+ 'varname': 'empty_email',
+ 'field_content': 'label-and-value',
+ 'display_mode': 'text',
+ 'empty_value': 'Custom text',
+ }
+ cell.save()
+ result = cell.render(context)
+ assert len(PyQuery(result).find('.cell--body > div > div')) == 1
+ assert PyQuery(result).find('.label').text() == 'Empty Email'
+ assert PyQuery(result).find('.value').text() == 'Custom text'
+ assert PyQuery(result).find('.value a') == []
+
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
def test_card_cell_card_mode_render_custom_schema_custom_entry(mock_send, context, app):
diff --git a/tests/wcs/utils.py b/tests/wcs/utils.py
index 7589474a..6c964d5f 100644
--- a/tests/wcs/utils.py
+++ b/tests/wcs/utils.py
@@ -246,6 +246,7 @@ WCS_CARDDEF_SCHEMAS = {
{'label': 'Field H', 'varname': 'fieldh', 'type': 'string'},
{'label': 'Field I', 'varname': 'fieldi', 'type': 'text', 'display_mode': 'rich'},
{'label': 'Empty', 'varname': 'empty', 'type': 'string'},
+ {'label': 'Empty Email', 'varname': 'empty_email', 'type': 'email'},
{'label': 'Related', 'varname': 'related', 'type': 'item'},
{'label': 'Page', 'type': 'page'},
{'label': 'Comment', 'type': 'comment'},