0006-to-fixup-renommage-fc_text_template-text_template-et.patch
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 |
- |