diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-04-17 12:27:52 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-06-12 08:41:54 +0200 |
commit | deaaa804e9fe2220462ce35a5481769b7092a909 (patch) | |
tree | 56c1cb81ca21f45e9574e8d142f0cf3969fda16b /ishtar_common | |
parent | 0666e34337b965e85ce3920363ad04e87958e8e7 (diff) | |
download | Ishtar-deaaa804e9fe2220462ce35a5481769b7092a909.tar.bz2 Ishtar-deaaa804e9fe2220462ce35a5481769b7092a909.zip |
Account wizard: save, update, delete profile
Diffstat (limited to 'ishtar_common')
-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 \ |