Projet

Général

Profil

0006-to-fixup-renommage-fc_text_template-text_template-et.patch

Benjamin Dauvergne, 27 mai 2021 14:34

Télécharger (3,14 ko)

Voir les différences:

Subject: [PATCH 6/9] =?UTF-8?q?to=20fixup:=20renommage=20fc=5Ftext=5Ftempl?=
 =?UTF-8?q?ate=20->=20text=5Ftemplate=20et=20int=C3=A9gration=20donn=C3=A9?=
 =?UTF-8?q?es=20dgfip=20au=20template?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

 .../franceconnect/migrations/0001_initial.py     |  2 +-
 passerelle/apps/franceconnect/models.py          | 16 +++++++++-------
 2 files changed, 10 insertions(+), 8 deletions(-)
passerelle/apps/franceconnect/migrations/0001_initial.py
40 40
                    models.TextField(default='identite_pivot', verbose_name='FranceConnect scopes'),
41 41
                ),
42 42
                (
43
                    'fc_text_template',
43
                    'text_template',
44 44
                    models.TextField(
45 45
                        default="{{ given_name }} {{ family_name }} {% if gender == 'male' %}né{% else %}née{% endif %} le {{ birthdate }} à {{ birthplace }}",
46 46
                        verbose_name='FranceConnect text template',
passerelle/apps/franceconnect/models.py
52 52

  
53 53
    fc_scopes = models.TextField(_('FranceConnect scopes'), default='identite_pivot')
54 54

  
55
    fc_text_template = models.TextField(
56
        _('FranceConnect text template'),
55
    text_template = models.TextField(
56
        _('Text template'),
57 57
        default=(
58
            '''{{ given_name }} {{ family_name }} '''
59
            '''{% if gender == 'male' %}né{% else %}née{% endif %} le {{ birthdate }} '''
60
            '''à {{ birthplace }}'''
58
            '''{{ fc.given_name }} {{ fc.family_name }} '''
59
            '''{% if fc.gender == 'male' %}né{% else %}née{% endif %} le {{ fc.birthdate }} '''
60
            '''à {{ fc.birthplace }}'''
61 61
        ),
62 62
    )
63 63

  
......
179 179
                    franceconnect.request_dgfip_ir(str(year), id_teleservice=self.dgfip_id_teleservice)
180 180
                token['dgfip_ir'] = franceconnect.dgfip_ressource_ir_response
181 181
            try:
182
                template = Template(self.fc_text_template)
183
                token['text'] = template.render(Context(franceconnect.fc_user_info))
182
                template = Template(self.text_template)
183
                token['text'] = template.render(
184
                    Context({'fc': franceconnect.fc_user_info, 'dgfip': token.get('dgfip_ir')})
185
                )
184 186
            except Exception:
185 187
                token['text'] = '<failed to render>'
186 188
            context['data'] = {'id': self.store(token), 'text': token['text']}
187
-