Don't raise GroupExists when adding to the same group anyway.

This commit is contained in:
voussoir 2017-03-10 15:27:40 -08:00
parent afe7085702
commit bff5ee9986

View file

@ -47,6 +47,7 @@ class GroupableMixin:
raise TypeError('Member must be of type %s' % type(self)) raise TypeError('Member must be of type %s' % type(self))
self.photodb.log.debug('Adding child %s to %s' % (member, self)) self.photodb.log.debug('Adding child %s to %s' % (member, self))
# Groupables are only allowed to have 1 parent. # Groupables are only allowed to have 1 parent.
# Unlike photos which can exist in multiple albums. # Unlike photos which can exist in multiple albums.
cur = self.photodb.sql.cursor() cur = self.photodb.sql.cursor()
@ -58,13 +59,12 @@ class GroupableMixin:
if fetch is not None: if fetch is not None:
parent_id = fetch[self.group_sql_index['parentid']] parent_id = fetch[self.group_sql_index['parentid']]
if parent_id == self.id: if parent_id == self.id:
that_group = self return
else: that_group = self.group_getter(id=parent_id)
that_group = self.group_getter(id=parent_id)
raise exceptions.GroupExists(member=member, group=that_group) raise exceptions.GroupExists(member=member, group=that_group)
for parent in self.walk_parents(): for my_ancestor in self.walk_parents():
if parent == member: if my_ancestor == member:
raise exceptions.RecursiveGrouping(member=member, group=self) raise exceptions.RecursiveGrouping(member=member, group=self)
self.photodb._cached_frozen_children = None self.photodb._cached_frozen_children = None