From bff5ee99860197b5e55c878f87075f044d479ac2 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Fri, 10 Mar 2017 15:27:40 -0800 Subject: [PATCH] Don't raise GroupExists when adding to the same group anyway. --- etiquette/objects.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/etiquette/objects.py b/etiquette/objects.py index dcca034..7cf6bb1 100644 --- a/etiquette/objects.py +++ b/etiquette/objects.py @@ -47,6 +47,7 @@ class GroupableMixin: raise TypeError('Member must be of type %s' % type(self)) self.photodb.log.debug('Adding child %s to %s' % (member, self)) + # Groupables are only allowed to have 1 parent. # Unlike photos which can exist in multiple albums. cur = self.photodb.sql.cursor() @@ -58,13 +59,12 @@ class GroupableMixin: if fetch is not None: parent_id = fetch[self.group_sql_index['parentid']] if parent_id == self.id: - that_group = self - else: - that_group = self.group_getter(id=parent_id) + return + that_group = self.group_getter(id=parent_id) raise exceptions.GroupExists(member=member, group=that_group) - for parent in self.walk_parents(): - if parent == member: + for my_ancestor in self.walk_parents(): + if my_ancestor == member: raise exceptions.RecursiveGrouping(member=member, group=self) self.photodb._cached_frozen_children = None