0007-to-fixup-format-birtdate-using-locale-in-text-field.patch
passerelle/apps/franceconnect/models.py | ||
---|---|---|
14 | 14 |
# You should have received a copy of the GNU Affero General Public License |
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | |
17 |
import datetime |
|
17 | 18 |
import uuid |
18 | 19 | |
19 | 20 |
from django.core.cache import cache |
... | ... | |
180 | 181 |
token['dgfip_ir'] = franceconnect.dgfip_ressource_ir_response |
181 | 182 |
try: |
182 | 183 |
template = Template(self.text_template) |
183 |
token['text'] = template.render( |
|
184 |
Context({'fc': franceconnect.fc_user_info, 'dgfip': token.get('dgfip_ir')}) |
|
185 |
) |
|
184 |
text_template_context = { |
|
185 |
'fc': franceconnect.fc_user_info.copy(), |
|
186 |
'dgfip': token.get('dgfip_ir'), |
|
187 |
} |
|
188 |
if franceconnect.fc_user_info.get('birthdate'): |
|
189 |
birthdate = franceconnect.fc_user_info['birthdate'] |
|
190 |
try: |
|
191 |
text_template_context['fc']['birthdate'] = datetime.datetime.strptime( |
|
192 |
birthdate, '%Y-%m-%d' |
|
193 |
).date() |
|
194 |
except ValueError: |
|
195 |
pass |
|
196 |
token['text'] = template.render(Context(text_template_context)) |
|
186 | 197 |
except Exception: |
187 | 198 |
token['text'] = '<failed to render>' |
188 | 199 |
context['data'] = {'id': self.store(token), 'text': token['text']} |
189 |
- |