Don't allow Groupable to add itself as a child.

omg what an oversight
This commit is contained in:
voussoir 2018-09-22 23:10:18 -07:00
parent 3db5c77c2c
commit e9f567ffc9
2 changed files with 6 additions and 0 deletions

View file

@ -109,6 +109,9 @@ class UserExists(Exists):
# TAG ERRORS
class CantGroupSelf(EtiquetteException):
error_message = 'Cannot group {} into itself.'
class CantSynonymSelf(EtiquetteException):
error_message = 'Cannot apply synonym to self.'

View file

@ -87,6 +87,9 @@ class GroupableMixin:
def add_child(self, member, *, commit=True):
self.assert_same_type(member)
if member == self:
raise exceptions.CantGroupSelf(self)
if self.has_child(member):
return