Révision 64438aee
Ajouté par Serghei Mihai (congés, retour 15/05) il y a environ 9 ans
uauth/organization/utils.py | ||
---|---|---|
18 | 18 |
return user |
19 | 19 |
except: |
20 | 20 |
return False |
21 |
|
|
22 |
def create_or_update_users(data): |
|
23 |
created = 0 |
|
24 |
updated = 0 |
|
25 |
for user in data: |
|
26 |
try: |
|
27 |
account = LocalAccount.objects.get(username=user['username']) |
|
28 |
if not user['password']: |
|
29 |
del user['password'] |
|
30 |
account.__dict__.update(user) |
|
31 |
account.save() |
|
32 |
updated += 1 |
|
33 |
except LocalAccount.DoesNotExist: |
|
34 |
if create_user(user): |
|
35 |
created += 1 |
|
36 |
return created, updated |
Formats disponibles : Unified diff
import users view(#7065)