From 77c3070f669854e06196dd1220d747b44942e210 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 6 Jul 2017 00:07:43 +0200 Subject: Fix account creation --- ishtar_common/wizards.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'ishtar_common/wizards.py') 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() -- cgit v1.2.3