Don't allow Groupable to add itself as a child.
omg what an oversight
This commit is contained in:
		
							parent
							
								
									3db5c77c2c
								
							
						
					
					
						commit
						e9f567ffc9
					
				
					 2 changed files with 6 additions and 0 deletions
				
			
		|  | @ -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.' | ||||
| 
 | ||||
|  |  | |||
|  | @ -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 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue