diff options
Diffstat (limited to 'ishtar_common/wizards.py')
-rw-r--r-- | ishtar_common/wizards.py | 15 |
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() |