From f5634457ef7882cbc9fcb30d0e12a61d4f13498a Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 28 May 2018 16:58:42 +0200 Subject: User profile form: duplicate, delete and edit --- ishtar_common/wizards.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'ishtar_common/wizards.py') diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index a6d0befd5..3e153c9dd 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -1619,7 +1619,6 @@ class AccountWizard(Wizard): model = models.Person formset_pop_deleted = False wizard_done_window = reverse_lazy('show-person') - modification = True def get_formated_datas(self, forms): datas = super(AccountWizard, self).get_formated_datas(forms) @@ -1695,6 +1694,8 @@ class AccountWizard(Wizard): profile.delete() continue + name = data.get('name', None) + profile_type_id = data.get('profile_type', None) if not profile_type_id: continue @@ -1704,13 +1705,17 @@ class AccountWizard(Wizard): ) except models.ProfileType.DoesNotExist: continue + + if not name: + name = profile_type.label + if profile: - if profile_type != profile.profile_type: - profile.profile_type = profile_type - profile.save() + profile.name = name + profile.profile_type = profile_type + profile.save() else: profile = models.UserProfile.objects.create( - profile_type=profile_type, person=person) + profile_type=profile_type, person=person, name=name) area_pks = data.get('area', None) areas = [] if area_pks: -- cgit v1.2.3