summaryrefslogtreecommitdiff
path: root/ishtar_common/wizards.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-07-06 00:07:43 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-07-06 00:07:43 +0200
commit77c3070f669854e06196dd1220d747b44942e210 (patch)
treef167ac27056b4d704c0c1efcedbad407f2d37e95 /ishtar_common/wizards.py
parentcfe916133f341f6e8470a91c1151eab8233dd3ab (diff)
downloadIshtar-77c3070f669854e06196dd1220d747b44942e210.tar.bz2
Ishtar-77c3070f669854e06196dd1220d747b44942e210.zip
Fix account creation
Diffstat (limited to 'ishtar_common/wizards.py')
-rw-r--r--ishtar_common/wizards.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py
index a98b14f8e..e8b079bf6 100644
--- a/ishtar_common/wizards.py
+++ b/ishtar_common/wizards.py
@@ -1382,17 +1382,24 @@ class AccountWizard(Wizard):
if key.startswith('hidden_password'):
dct['password'] = dct.pop(key)
try:
- account = models.IshtarUser.objects.get(person=person)
+ account = models.IshtarUser.objects.get(person=person).user_ptr
account.username = dct['username']
account.email = dct['email']
except ObjectDoesNotExist:
now = datetime.datetime.now()
- account = models.IshtarUser(
- person=person, username=dct['username'], email=dct['email'],
+ account = models.User.objects.create(
+ username=dct['username'], email=dct['email'],
first_name=person.surname or '***',
last_name=person.name or '***',
is_staff=False, is_active=True, is_superuser=False,
- last_login=now, date_joined=now)
+ last_login=now, date_joined=now
+ )
+ ishtaruser = account.ishtaruser
+ old_person_pk = ishtaruser.person.pk
+ ishtaruser.person = person
+ ishtaruser.save()
+ models.Person.objects.get(pk=old_person_pk).delete()
+
if dct['password']:
account.set_password(dct['password'])
account.save()