diff options
| -rw-r--r-- | ishtar_common/forms_common.py | 4 | ||||
| -rw-r--r-- | ishtar_common/wizards.py | 15 | 
2 files changed, 13 insertions, 6 deletions
| diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py index 44af3a588..4d14e4544 100644 --- a/ishtar_common/forms_common.py +++ b/ishtar_common/forms_common.py @@ -585,7 +585,7 @@ class AccountForm(forms.Form):          if 'initial' in kwargs and 'pk' in kwargs['initial']:              try:                  person = models.Person.objects.get(pk=kwargs['initial']['pk']) -                account = models.IshtarUser.objects.get(person=person) +                account = models.IshtarUser.objects.get(person=person).user_ptr                  if not kwargs['initial'].get('username'):                      kwargs['initial']['username'] = account.username                  if not kwargs['initial'].get('email'): @@ -613,7 +613,7 @@ class AccountForm(forms.Form):                                                u"password."))          # check username unicity          q = models.IshtarUser.objects.filter( -            username=cleaned_data.get('username')) +            user_ptr__username=cleaned_data.get('username'))          if cleaned_data.get('pk'):              q = q.exclude(person__pk=cleaned_data.get('pk'))          if q.count(): 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() | 
