diff options
| -rw-r--r-- | ishtar_common/wizards.py | 31 | 
1 files changed, 30 insertions, 1 deletions
| diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index 68ca640a0..3f7502c62 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -1477,7 +1477,36 @@ class AccountWizard(Wizard):          profile_form = form_dict['profile-account_management']          for form in profile_form: -            print(form.cleaned_data) +            data = form.cleaned_data +            profile = None +            if data.get('pk', None): +                try: +                    profile = models.UserProfile.objects.get( +                        pk=data['pk'], person=person) +                except models.UserProfile.DoesNotExist: +                    continue +                if data.get('DELETE', None): +                    profile.delete() +                    continue + +            profile_type_id = data.get('profile_type', None) +            if not profile_type_id: +                continue +            try: +                profile_type = models.ProfileType.objects.get( +                    pk=profile_type_id +                ) +            except models.ProfileType.DoesNotExist: +                continue +            if profile: +                if profile_type == profile.profile_type: +                    # no change +                    continue +                profile.profile_type = profile_type +                profile.save() +                continue +            models.UserProfile.objects.create( +                profile_type=profile_type, person=person)          final_form = form_dict['final-account_management']          if settings.ADMINS and type(final_form.cleaned_data) == dict and \ | 
