From 698981dd294996e9ce1c67c85a9195aa2df21239 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Tue, 1 May 2018 17:48:56 -0700 Subject: [PATCH] Move _uncache_sums call out of _add_photo, into callers. --- etiquette/objects.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/etiquette/objects.py b/etiquette/objects.py index 917010c..127a304 100644 --- a/etiquette/objects.py +++ b/etiquette/objects.py @@ -330,22 +330,17 @@ class Album(ObjectBase, GroupableMixin): def _add_photo(self, photo): self.photodb.log.debug('Adding photo %s to %s', photo, self) - data = { - 'albumid': self.id, - 'photoid': photo.id, - } + data = {'albumid': self.id, 'photoid': photo.id} self.photodb.sql_insert(table='album_photo_rel', data=data) - self._uncache_sums() @decorators.required_feature('album.edit') @decorators.transaction def add_photo(self, photo, *, commit=True): - if self.photodb != photo.photodb: - raise ValueError('Not the same PhotoDB') if self.has_photo(photo): return self._add_photo(photo) + self._uncache_sums() if commit: self.photodb.log.debug('Committing - add photo to album') @@ -360,6 +355,7 @@ class Album(ObjectBase, GroupableMixin): for photo in photos: self._add_photo(photo) + self._uncache_sums() if commit: self.photodb.log.debug('Committing - add photos to album')