diff --git a/combo/apps/wcs/forms.py b/combo/apps/wcs/forms.py index 8bd741c7..41cdb585 100644 --- a/combo/apps/wcs/forms.py +++ b/combo/apps/wcs/forms.py @@ -51,7 +51,7 @@ class WcsCardsCellForm(forms.ModelForm): class Meta: model = WcsCardsCell - fields = ('carddef_reference', 'only_for_user') + fields = ('carddef_reference', 'custom_title', 'only_for_user') def __init__(self, *args, **kwargs): instance = kwargs['instance'] diff --git a/combo/apps/wcs/migrations/0029_cards_custom_title.py b/combo/apps/wcs/migrations/0029_cards_custom_title.py new file mode 100644 index 00000000..e3ca7798 --- /dev/null +++ b/combo/apps/wcs/migrations/0029_cards_custom_title.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('wcs', '0028_wcscardscell_without_user'), + ] + + operations = [ + migrations.AddField( + model_name='wcscardscell', + name='custom_title', + field=models.CharField(blank=True, max_length=150, verbose_name='Custom Title'), + ), + ] diff --git a/combo/apps/wcs/models.py b/combo/apps/wcs/models.py index 9fc58f27..243cf8aa 100644 --- a/combo/apps/wcs/models.py +++ b/combo/apps/wcs/models.py @@ -775,6 +775,7 @@ class CardMixin(object): class WcsCardsCell(CardMixin, WcsBlurpMixin, CellBase): carddef_reference = models.CharField(_('Card Model'), max_length=150) cached_title = models.CharField(_('Title'), max_length=150) + custom_title = models.CharField(_('Custom Title'), max_length=150, blank=True) only_for_user = models.BooleanField(_('Limit to cards linked to the logged-in user'), default=False) without_user = models.BooleanField(_('Ignore the logged-in user'), default=False) @@ -857,7 +858,7 @@ class WcsCardsCell(CardMixin, WcsBlurpMixin, CellBase): def get_cell_extra_context(self, context): extra_context = super().get_cell_extra_context(context) - extra_context['title'] = self.cached_title + extra_context['title'] = self.custom_title or self.cached_title pages_with_sub_slug = Page.objects.exclude(sub_slug='') card_id = '%s_id' % self.carddef_reference.split(':')[1] diff --git a/tests/test_wcs.py b/tests/test_wcs.py index 4fbc49df..90c9f690 100644 --- a/tests/test_wcs.py +++ b/tests/test_wcs.py @@ -1439,6 +1439,12 @@ def test_cards_cell_render(mock_send, context): assert requests_get.call_args_list[0][0][0] == '/api/cards/card_model_1/list/foo' assert requests_get.call_args_list[0][1]['remote_service']['url'] == 'http://127.0.0.1:8999/' + cell.custom_title = 'Foo bar' + cell.save() + result = cell.render(context) + assert '

Card Model 1 - bar

' not in result + assert '

Foo bar

' in result + @mock.patch('combo.apps.wcs.utils.requests.send', side_effect=mocked_requests_send) def test_cards_cell_only_for_user(mock_send, context):