From 924811f1e3e2c9245ebc04e1ffcfaebe1d7425cb Mon Sep 17 00:00:00 2001 From: Serghei Mihai Date: Sun, 25 Nov 2018 20:09:25 +0100 Subject: [PATCH 1/2] lingo: refactor TIPI payment form rendering (#26057) --- combo/apps/lingo/models.py | 9 +++++++++ combo/apps/lingo/templates/lingo/tipi_form.html | 15 +++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/combo/apps/lingo/models.py b/combo/apps/lingo/models.py index 5cdf143c..f2eb8f3f 100644 --- a/combo/apps/lingo/models.py +++ b/combo/apps/lingo/models.py @@ -723,10 +723,19 @@ class TipiPaymentFormCell(CellBase): def get_cell_extra_context(self, context): extra_context = super(TipiPaymentFormCell, self).get_cell_extra_context(context) + context['reference_fields'] = ( + {'name': 'exer', 'pattern': '[0-9]+', 'length': '4', 'placeholder': '0'*4, 'protocol': 'any'}, + {'name': 'idpce', 'pattern': '[0-9]+', 'length': '8', 'placeholder': '0'*8, 'protocol': 'pesv2'}, + {'name': 'idligne', 'pattern': '[0-9]+', 'length': '6', 'placeholder': '0'*6, 'protocol': 'pesv2'}, + {'name': 'rolrec', 'pattern': '[A-Z0-9]+', 'length': '2', 'placeholder': '0'*2, 'protocol': 'rolmre'}, + {'name': 'roldeb', 'pattern': '[0-9]+', 'length': '2', 'placeholder': '0'*2, 'protocol': 'rolmre'}, + {'name': 'roldet', 'pattern': '[0-9]+', 'length': '13', 'placeholder': '0'*13, 'protocol': 'rolmre'} + ) context['title'] = self.title context['url'] = self.url context['mode'] = 'T' if self.test_mode else 'M' context['pesv2'] = (self.control_protocol == 'pesv2') + context['control_protocol'] = self.control_protocol context['regies'] = [] for regie in self.regies.split(','): regie_id = regie.strip() diff --git a/combo/apps/lingo/templates/lingo/tipi_form.html b/combo/apps/lingo/templates/lingo/tipi_form.html index 98dfc575..39b3c480 100644 --- a/combo/apps/lingo/templates/lingo/tipi_form.html +++ b/combo/apps/lingo/templates/lingo/tipi_form.html @@ -24,15 +24,14 @@

- - - {% if pesv2 %} - - - - {% else %} - - - - - + {% regroup reference_fields by protocol as fields %} + {% for field in fields %} + {% for f in field.list %} + {% if field.grouper == control_protocol or field.grouper == 'any' %} + {% if field.grouper == 'any' or not forloop.last %} - {% endif %} {% endif %} + {% endfor %} + {% endfor %}