0001-wcs-custom-title-for-current-forms-cell-57966.patch
combo/apps/wcs/forms.py | ||
---|---|---|
163 | 163 |
field_order = [ |
164 | 164 |
'wcs_site', |
165 | 165 |
'categories', |
166 |
'custom_title', |
|
166 | 167 |
'current_forms', |
167 | 168 |
'done_forms', |
168 | 169 |
'include_drafts', |
... | ... | |
173 | 174 |
model = WcsCurrentFormsCell |
174 | 175 |
fields = [ |
175 | 176 |
'wcs_site', |
177 |
'custom_title', |
|
176 | 178 |
'current_forms', |
177 | 179 |
'done_forms', |
178 | 180 |
'include_drafts', |
combo/apps/wcs/migrations/0041_current_forms_custom_title.py | ||
---|---|---|
1 |
from django.db import migrations, models |
|
2 | ||
3 | ||
4 |
class Migration(migrations.Migration): |
|
5 | ||
6 |
dependencies = [ |
|
7 |
('wcs', '0040_cards_limit'), |
|
8 |
] |
|
9 | ||
10 |
operations = [ |
|
11 |
migrations.AddField( |
|
12 |
model_name='wcscurrentformscell', |
|
13 |
name='custom_title', |
|
14 |
field=models.CharField(blank=True, max_length=150, verbose_name='Custom Title'), |
|
15 |
), |
|
16 |
] |
combo/apps/wcs/models.py | ||
---|---|---|
462 | 462 |
loading_message = _('Loading forms...') |
463 | 463 | |
464 | 464 |
categories = JSONField(_('Categories'), blank=True, default=dict) |
465 |
custom_title = models.CharField(_('Custom Title'), max_length=150, blank=True) |
|
465 | 466 |
current_forms = models.BooleanField(_('Current Forms'), default=True) |
466 | 467 |
done_forms = models.BooleanField(_('Done Forms'), default=False) |
467 | 468 |
include_drafts = models.BooleanField(_('Include drafts'), default=False) |
combo/apps/wcs/templates/combo/wcs/current_forms.html | ||
---|---|---|
1 | 1 |
{% load i18n %} |
2 | 2 |
{% block cell-content %} |
3 |
<h2>{% trans 'Current Forms' %}</h2>
|
|
3 |
<h2>{{ cell.custom_title|default:_('Current Forms') }}</h2>
|
|
4 | 4 |
{% if forms %} |
5 | 5 |
{% for slug, forms in current_forms.items %} |
6 | 6 |
<div class="links-list current-forms-{{ slug }} current-forms list-of-forms"> |
combo/apps/wcs/templates/combo/wcs/user_all_forms.html | ||
---|---|---|
1 | 1 |
{% load i18n %} |
2 | 2 |
{% block cell-content %} |
3 |
<h2>{% trans 'All Forms' %}</h2>
|
|
3 |
<h2>{{ cell.custom_title|default:_('All Forms') }}</h2>
|
|
4 | 4 |
{% if forms %} |
5 | 5 |
{% for slug, forms in user_forms.items %} |
6 | 6 |
<div class="links-list user-forms-{{ slug }} user-all-forms list-of-forms"> |
combo/apps/wcs/templates/combo/wcs/user_done_forms.html | ||
---|---|---|
1 | 1 |
{% load i18n %} |
2 | 2 |
{% block cell-content %} |
3 |
<h2>{% trans 'Done Forms' %}</h2>
|
|
3 |
<h2>{{ cell.custom_title|default:_('Done Forms') }}</h2>
|
|
4 | 4 |
{% if forms %} |
5 | 5 |
{% for slug, forms in user_forms.items %} |
6 | 6 |
<div class="links-list user-forms-{{ slug }} list-of-forms"> |
tests/test_wcs.py | ||
---|---|---|
632 | 632 |
== '/api/user/forms/?status=done&include-accessible=on&limit=100&sort=desc' |
633 | 633 |
) |
634 | 634 | |
635 |
# check empty messages |
|
635 |
# check empty messages and title
|
|
636 | 636 |
with mock.patch('combo.apps.wcs.models.requests.get') as requests_get: |
637 | 637 |
mock_json = mock.Mock(status_code=200) |
638 | 638 |
requests_get.return_value = mock_json |
... | ... | |
640 | 640 |
cell.done_forms = False |
641 | 641 |
cell.include_drafts = False |
642 | 642 |
result = cell.render(context) |
643 |
assert '<h2>Current Forms</h2>' in result |
|
643 | 644 |
assert 'There are no current forms.' in result |
645 |
cell.custom_title = 'Foo bar' |
|
646 |
result = cell.render(context) |
|
647 |
assert '<h2>Foo bar</h2>' in result |
|
648 |
cell.custom_title = '' |
|
644 | 649 |
cell.done_forms = True |
645 | 650 |
result = cell.render(context) |
651 |
assert '<h2>All Forms</h2>' in result |
|
646 | 652 |
assert 'There are no forms.' in result |
653 |
cell.custom_title = 'Foo bar' |
|
654 |
result = cell.render(context) |
|
655 |
assert '<h2>Foo bar</h2>' in result |
|
656 |
cell.custom_title = '' |
|
647 | 657 |
cell.current_forms = False |
648 | 658 |
result = cell.render(context) |
659 |
assert '<h2>Done Forms</h2>' in result |
|
649 | 660 |
assert 'There are no done forms' in result |
661 |
cell.custom_title = 'Foo bar' |
|
662 |
result = cell.render(context) |
|
663 |
assert '<h2>Foo bar</h2>' in result |
|
650 | 664 | |
651 | 665 | |
652 | 666 |
@mock.patch('combo.apps.wcs.utils.requests.send', side_effect=mocked_requests_send) |
653 |
- |