summaryrefslogtreecommitdiff
path: root/ishtar_common/wizards.py
diff options
context:
space:
mode:
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
commitc22482bbff62c8cf0dfdac898bb8613005bda877 (patch)
tree56c1cb81ca21f45e9574e8d142f0cf3969fda16b /ishtar_common/wizards.py
parent6c57e2b6974a7acffff684279ab2c2b74edd1676 (diff)
downloadIshtar-c22482bbff62c8cf0dfdac898bb8613005bda877.tar.bz2
Ishtar-c22482bbff62c8cf0dfdac898bb8613005bda877.zip
Account wizard: save, update, delete profile
Diffstat (limited to 'ishtar_common/wizards.py')
-rw-r--r--ishtar_common/wizards.py31
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 \