handle native authentic birthdate field

This commit is contained in:
Frédéric Péters 2018-08-30 11:23:56 +02:00
parent f9d0087fa8
commit b53a421dbb
1 changed files with 8 additions and 2 deletions

View File

@ -14,6 +14,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import datetime
import logging
import requests
@ -147,8 +148,13 @@ class AuthenticAdapter(DefaultAdapter):
birthdate = '%s/%s/20%s' % (nrn[4:6], nrn[2:4], nrn[:2])
else:
birthdate = ''
Attribute.objects.get(name='birthdate').set_value(user, birthdate,
verified=True)
try:
Attribute.objects.get(name='birthdate').set_value(user, birthdate,
verified=True)
except AttributeError: # native authentic date field
birthdate = datetime.datetime.strptime(birthdate, '%d/%m/%Y').date()
Attribute.objects.get(name='birthdate').set_value(user, birthdate,
verified=True)
if int(nrn[6:9]) % 2:
title = 'Monsieur'
else: