move circular group association validation to view

This commit is contained in:
AlanCoding
2017-07-10 09:12:02 -04:00
parent b79600d2e5
commit fed2eddf07
3 changed files with 25 additions and 8 deletions

View File

@@ -730,14 +730,6 @@ class GroupAccess(BaseAccess):
# Prevent assignments between different inventories.
if obj.inventory != sub_obj.inventory:
raise ParseError(_('Cannot associate two items from different inventories.'))
# Prevent group from being assigned as its own (grand)child.
if type(obj) == type(sub_obj):
parent_pks = set(obj.all_parents.values_list('pk', flat=True))
parent_pks.add(obj.pk)
child_pks = set(sub_obj.all_children.values_list('pk', flat=True))
child_pks.add(sub_obj.pk)
if parent_pks & child_pks:
return False
return True
def can_delete(self, obj):