wcs: custom title for current forms cell (#57966)
gitea-wip/combo/pipeline/head There was a failure building this commit Details
gitea/combo/pipeline/head Build started... Details

This commit is contained in:
Lauréline Guérin 2021-10-26 10:53:30 +02:00
parent f8138782f1
commit bbfc19618a
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
7 changed files with 37 additions and 4 deletions

View File

@ -163,6 +163,7 @@ class WcsCurrentFormsCellForm(WcsFormsMixin, forms.ModelForm):
field_order = [
'wcs_site',
'categories',
'custom_title',
'current_forms',
'done_forms',
'include_drafts',
@ -173,6 +174,7 @@ class WcsCurrentFormsCellForm(WcsFormsMixin, forms.ModelForm):
model = WcsCurrentFormsCell
fields = [
'wcs_site',
'custom_title',
'current_forms',
'done_forms',
'include_drafts',

View File

@ -0,0 +1,16 @@
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('wcs', '0041_card_id'),
]
operations = [
migrations.AddField(
model_name='wcscurrentformscell',
name='custom_title',
field=models.CharField(blank=True, max_length=150, verbose_name='Custom Title'),
),
]

View File

@ -462,6 +462,7 @@ class WcsCurrentFormsCell(CategoriesAndWcsSiteValidityMixin, CategoriesFiltering
loading_message = _('Loading forms...')
categories = JSONField(_('Categories'), blank=True, default=dict)
custom_title = models.CharField(_('Custom Title'), max_length=150, blank=True)
current_forms = models.BooleanField(_('Current Forms'), default=True)
done_forms = models.BooleanField(_('Done Forms'), default=False)
include_drafts = models.BooleanField(_('Include drafts'), default=False)

View File

@ -1,6 +1,6 @@
{% load i18n %}
{% block cell-content %}
<h2>{% trans 'Current Forms' %}</h2>
<h2>{{ cell.custom_title|default:_('Current Forms') }}</h2>
{% if forms %}
{% for slug, forms in current_forms.items %}
<div class="links-list current-forms-{{ slug }} current-forms list-of-forms">

View File

@ -1,6 +1,6 @@
{% load i18n %}
{% block cell-content %}
<h2>{% trans 'All Forms' %}</h2>
<h2>{{ cell.custom_title|default:_('All Forms') }}</h2>
{% if forms %}
{% for slug, forms in user_forms.items %}
<div class="links-list user-forms-{{ slug }} user-all-forms list-of-forms">

View File

@ -1,6 +1,6 @@
{% load i18n %}
{% block cell-content %}
<h2>{% trans 'Done Forms' %}</h2>
<h2>{{ cell.custom_title|default:_('Done Forms') }}</h2>
{% if forms %}
{% for slug, forms in user_forms.items %}
<div class="links-list user-forms-{{ slug }} list-of-forms">

View File

@ -636,7 +636,7 @@ def test_current_forms_cell_render(mock_send, context):
== '/api/user/forms/?status=done&include-accessible=on&limit=100&sort=desc'
)
# check empty messages
# check empty messages and title
with mock.patch('combo.apps.wcs.models.requests.get') as requests_get:
mock_json = mock.Mock(status_code=200)
requests_get.return_value = mock_json
@ -644,13 +644,27 @@ def test_current_forms_cell_render(mock_send, context):
cell.done_forms = False
cell.include_drafts = False
result = cell.render(context)
assert '<h2>Current Forms</h2>' in result
assert 'There are no current forms.' in result
cell.custom_title = 'Foo bar'
result = cell.render(context)
assert '<h2>Foo bar</h2>' in result
cell.custom_title = ''
cell.done_forms = True
result = cell.render(context)
assert '<h2>All Forms</h2>' in result
assert 'There are no forms.' in result
cell.custom_title = 'Foo bar'
result = cell.render(context)
assert '<h2>Foo bar</h2>' in result
cell.custom_title = ''
cell.current_forms = False
result = cell.render(context)
assert '<h2>Done Forms</h2>' in result
assert 'There are no done forms' in result
cell.custom_title = 'Foo bar'
result = cell.render(context)
assert '<h2>Foo bar</h2>' in result
@mock.patch('combo.apps.wcs.utils.requests.send', side_effect=mocked_requests_send)