Skip to content
Snippets Groups Projects
Commit 44b2cbd9 authored by Steven H Johnson's avatar Steven H Johnson
Browse files

Do not allow self-referencing nav nodes

parent fbc18d41
Branches
No related merge requests found
......@@ -88,6 +88,17 @@ class NavigationNodeAdminForm(forms.ModelForm):
return name
def clean_parent(self):
"""Do not allow self-referencing nodes"""
parent = self.cleaned_data['parent']
error_msg = "You can't have a node be its own parent."
if self.instance == parent:
raise forms.ValidationError(error_msg)
return parent
def clean(self):
"Check to make sure path is unique to prevent IntegrityError"
cleaned_data = super(NavigationNodeAdminForm, self).clean()
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment