wcs: do not mix category and form descriptions (#70349)
gitea-wip/combo/pipeline/head Build started... Details
gitea/combo/pipeline/head Something is wrong with the build of this commit Details

This commit is contained in:
Serghei Mihai 2022-10-17 16:51:49 +02:00
parent 1d6c14ba80
commit d31bfde62b
4 changed files with 24 additions and 4 deletions

View File

@ -676,7 +676,7 @@ class WcsFormsOfCategoryCell(WcsCommonCategoryCell, WcsBlurpMixin):
return extra_context
extra_context['slug'] = self.category_reference.split(':')[-1]
extra_context['title'] = self.cached_title
extra_context['description'] = self.cached_description
extra_context['category_description'] = self.cached_description
try:
extra_context['forms'] = list(extra_context['forms'][self.wcs_site]['data'])
except (KeyError, TypeError):

View File

@ -4,9 +4,9 @@
{% block cell-header %}
<h2>{{ title }}</h2>
{% include "combo/asset_picture_fragment.html" %}
{% if description %}
{% if category_description %}
<div class="intro">
{{ description|safe }}
{{ category_description|safe }}
</div>
{% endif %}
{% endblock %}

View File

@ -160,6 +160,19 @@ def test_category_cell_save_cache(mock_send):
assert cell.get_additional_label() == 'Test 3'
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
def test_category_cell_render(mock_send):
page = Page(title='xxx', slug='test_category_cell_save_cache', template_name='standard')
page.save()
cell = WcsCategoryCell(page=page, placeholder='content', order=0, category_reference='default:test-3')
cell.save()
context = {'synchronous': True} # to get fresh content
result = cell.render(context)
assert "Test 3" in result
assert "category 3 description" in result
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
def test_category_cell_validity(mock_send):
page = Page.objects.create(title='xxx', slug='test_category_cell_save_cache', template_name='standard')
@ -874,6 +887,7 @@ def test_forms_of_category_cell_render(mock_send, context):
assert 'keyword-foo' in result
assert 'keyword-bar' in result
assert '<p>a form description</p>' in result
assert '<p>category 9 description</p>' not in result
cell.ordering = 'popularity'
cell.save()

View File

@ -18,7 +18,13 @@ WCS_FORMDEFS_DATA = [
]
WCS_CATEGORIES_DATA = [
{'slug': 'test-%s' % i, 'title': 'Test %s' % i, 'url': '/test-%s/' % i} for i in [3, 9]
{
'slug': 'test-%s' % i,
'title': 'Test %s' % i,
'url': '/test-%s/' % i,
'description': 'category %s description' % i,
}
for i in [3, 9]
]
WCS_CATEGORIES_FORMDEFS_DATA = [