From 470fa1afcf600b654a04cd28c0959d9609bb6167 Mon Sep 17 00:00:00 2001 From: Serghei Mihai Date: Wed, 19 Apr 2017 17:23:31 +0200 Subject: [PATCH] cells: provide description for TIPI payment form (#15927) --- .../0029_tipipaymentformcell_description.py | 19 +++++++++++++++++++ combo/apps/lingo/models.py | 2 ++ combo/apps/lingo/templates/lingo/tipi_form.html | 5 +++++ tests/test_lingo_cells.py | 7 +++++++ 4 files changed, 33 insertions(+) create mode 100644 combo/apps/lingo/migrations/0029_tipipaymentformcell_description.py diff --git a/combo/apps/lingo/migrations/0029_tipipaymentformcell_description.py b/combo/apps/lingo/migrations/0029_tipipaymentformcell_description.py new file mode 100644 index 0000000..2f490c4 --- /dev/null +++ b/combo/apps/lingo/migrations/0029_tipipaymentformcell_description.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('lingo', '0028_tipipaymentformcell'), + ] + + operations = [ + migrations.AddField( + model_name='tipipaymentformcell', + name='description', + field=models.TextField(null=True, blank=True), + ), + ] diff --git a/combo/apps/lingo/models.py b/combo/apps/lingo/models.py index 5e22024..f4ac572 100644 --- a/combo/apps/lingo/models.py +++ b/combo/apps/lingo/models.py @@ -512,6 +512,7 @@ TIPI_CONTROL_PROCOTOLS = ( @register_cell_class class TipiPaymentFormCell(CellBase): title = models.CharField(_('Title'), max_length=150, blank=True) + description = models.TextField(null=True, blank=True) url = models.URLField(_('TIPI payment service URL'), default='https://www.tipi.budget.gouv.fr/tpa/paiement.web') regies = models.CharField(_('Regies'), help_text=_('separated by commas'), max_length=256) control_protocol = models.CharField(_('Control protocol'), max_length=8, choices=TIPI_CONTROL_PROCOTOLS, default='pesv2') @@ -527,6 +528,7 @@ class TipiPaymentFormCell(CellBase): def get_cell_extra_context(self, context): extra_context = super(TipiPaymentFormCell, self).get_cell_extra_context(context) context['title'] = self.title + context['description'] = self.description context['url'] = self.url context['mode'] = 'T' if self.test_mode else 'M' context['pesv2'] = (self.control_protocol == 'pesv2') diff --git a/combo/apps/lingo/templates/lingo/tipi_form.html b/combo/apps/lingo/templates/lingo/tipi_form.html index de57117..02524ee 100644 --- a/combo/apps/lingo/templates/lingo/tipi_form.html +++ b/combo/apps/lingo/templates/lingo/tipi_form.html @@ -2,6 +2,11 @@

{{ title }}

+ {% if description %} +
+ {{ description }} +
+ {% endif %} diff --git a/tests/test_lingo_cells.py b/tests/test_lingo_cells.py index 543d399..b8c36b8 100644 --- a/tests/test_lingo_cells.py +++ b/tests/test_lingo_cells.py @@ -186,6 +186,13 @@ def test_tipi_cell(): assert 'id="idpce"' not in html assert 'id="idligne"' not in html assert 'data-saisie="T"' in html + assert '
' not in html cell_media = str(cell.media) assert "js/tipi.js" in cell_media + + cell.description = 'Here is the help text' + cell.save() + html = cell.render(Context({})) + assert '
' in html + assert 'Here is the help text' in html -- 2.11.0