0001-cells-provide-description-for-TIPI-payment-form-1592.patch
combo/apps/lingo/migrations/0029_tipipaymentformcell_description.py | ||
---|---|---|
1 |
# -*- coding: utf-8 -*- |
|
2 |
from __future__ import unicode_literals |
|
3 | ||
4 |
from django.db import migrations, models |
|
5 | ||
6 | ||
7 |
class Migration(migrations.Migration): |
|
8 | ||
9 |
dependencies = [ |
|
10 |
('lingo', '0028_tipipaymentformcell'), |
|
11 |
] |
|
12 | ||
13 |
operations = [ |
|
14 |
migrations.AddField( |
|
15 |
model_name='tipipaymentformcell', |
|
16 |
name='description', |
|
17 |
field=models.TextField(null=True, blank=True), |
|
18 |
), |
|
19 |
] |
combo/apps/lingo/models.py | ||
---|---|---|
512 | 512 |
@register_cell_class |
513 | 513 |
class TipiPaymentFormCell(CellBase): |
514 | 514 |
title = models.CharField(_('Title'), max_length=150, blank=True) |
515 |
description = models.TextField(null=True, blank=True) |
|
515 | 516 |
url = models.URLField(_('TIPI payment service URL'), default='https://www.tipi.budget.gouv.fr/tpa/paiement.web') |
516 | 517 |
regies = models.CharField(_('Regies'), help_text=_('separated by commas'), max_length=256) |
517 | 518 |
control_protocol = models.CharField(_('Control protocol'), max_length=8, choices=TIPI_CONTROL_PROCOTOLS, default='pesv2') |
... | ... | |
527 | 528 |
def get_cell_extra_context(self, context): |
528 | 529 |
extra_context = super(TipiPaymentFormCell, self).get_cell_extra_context(context) |
529 | 530 |
context['title'] = self.title |
531 |
context['description'] = self.description |
|
530 | 532 |
context['url'] = self.url |
531 | 533 |
context['mode'] = 'T' if self.test_mode else 'M' |
532 | 534 |
context['pesv2'] = (self.control_protocol == 'pesv2') |
combo/apps/lingo/templates/lingo/tipi_form.html | ||
---|---|---|
2 | 2 |
<h2>{{ title }}</h2> |
3 | 3 |
<div> |
4 | 4 |
<form name="tipi_form" id="tipi_form" data-url="{{ url }}" data-saisie="{{ mode }}" data-pesv2="{{ pesv2 }}"> |
5 |
{% if description %} |
|
6 |
<div class="description"> |
|
7 |
{{ description|safe }} |
|
8 |
</div> |
|
9 |
{% endif %} |
|
5 | 10 |
<ul class="errorlist" id="popup_warning" style="display: none"> |
6 | 11 |
<li>{% trans "Your browser is blocking popups but they are required to start the payment, make sure they are allowed for this site." %}</li> |
7 | 12 |
</ul> |
tests/test_lingo_cells.py | ||
---|---|---|
186 | 186 |
assert 'id="idpce"' not in html |
187 | 187 |
assert 'id="idligne"' not in html |
188 | 188 |
assert 'data-saisie="T"' in html |
189 |
assert '<div class="description">' not in html |
|
189 | 190 | |
190 | 191 |
cell_media = str(cell.media) |
191 | 192 |
assert "js/tipi.js" in cell_media |
193 | ||
194 |
cell.description = 'Here is the help text' |
|
195 |
cell.save() |
|
196 |
html = cell.render(Context({})) |
|
197 |
assert '<div class="description">' in html |
|
198 |
assert 'Here is the help text' in html |
|
192 |
- |