summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/authentic2_pratic/management/commands/load-pratic-ldif.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/authentic2_pratic/management/commands/load-pratic-ldif.py b/src/authentic2_pratic/management/commands/load-pratic-ldif.py
index 9295fff..2e45b3a 100644
--- a/src/authentic2_pratic/management/commands/load-pratic-ldif.py
+++ b/src/authentic2_pratic/management/commands/load-pratic-ldif.py
@@ -185,14 +185,20 @@ class PraticLDIFParser(ldif.LDIFParser):
'phone': 'telephoneNumber',
}
others = self.resolve_mapping(mapping, entry)
+ uid = others['uid']
last_login_duration = int(entry.get('cdg59lastConnectionDuration', [0])[0])
is_admin = entry.get('cdg59isAdmin', ['FALSE'])[0] == 'TRUE'
- user = User(
- collectivity=collectivity,
- is_active=is_active,
- last_login_duration=last_login_duration,
- is_admin=is_admin,
- **others)
+ try:
+ user = User.objects.get(uid=uid, collectivity=collectivity)
+ for k, v in others.iteritems():
+ setattr(user, k, v)
+ except User.DoesNotExist:
+ user = User(
+ collectivity=collectivity,
+ is_active=is_active,
+ last_login_duration=last_login_duration,
+ is_admin=is_admin,
+ **others)
if 'cdg59lastConnectionTime' in entry:
last_login = datetime.fromtimestamp(int(entry['cdg59lastConnectionTime'][0]))
last_login = make_aware(last_login, get_default_timezone())
@@ -202,7 +208,6 @@ class PraticLDIFParser(ldif.LDIFParser):
user.password = password
user.clean()
self.users.append(user)
- #accesses
for siid in entry.get('cdg59serviceAccesses', []):
def g(siid):
def f():