summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/forms_common.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py
index b28e40a5c..65d892fc9 100644
--- a/ishtar_common/forms_common.py
+++ b/ishtar_common/forms_common.py
@@ -1090,8 +1090,24 @@ class ProfileForm(ManageOldType):
]
+class ProfileFormsetBase(FormSetWithDeleteSwitches):
+ def clean(self):
+ values = []
+ for data in self.cleaned_data:
+ if not data.get("profile_type", None):
+ continue
+ value = (
+ data.get("profile_type", None),
+ data.get("name", None)
+ )
+ if value in values:
+ raise forms.ValidationError(_("Choose different name for profiles."))
+ values.append(value)
+ return self.cleaned_data
+
+
ProfileFormset = formset_factory(
- ProfileForm, can_delete=True, formset=FormSetWithDeleteSwitches
+ ProfileForm, can_delete=True, formset=ProfileFormsetBase
)
ProfileFormset.form_label = _("Profiles")
ProfileFormset.form_admin_name = _("Profiles")