From 519bcf32e6e6274cf727e6051ecc3b2382c55052 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Fri, 11 Sep 2020 15:02:15 -0700 Subject: [PATCH] Add separate plural method Album.add_associated_directories. --- etiquette/objects.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/etiquette/objects.py b/etiquette/objects.py index 8bdcbe5..f694a0e 100644 --- a/etiquette/objects.py +++ b/etiquette/objects.py @@ -285,14 +285,7 @@ class Album(ObjectBase, GroupableMixin): def add_children(self, *args, **kwargs): return super().add_children(*args, **kwargs) - @decorators.required_feature('album.edit') - @decorators.transaction - def add_associated_directory(self, path): - ''' - Add a directory from which this album will pull files during rescans. - These relationships are not unique and multiple albums - can associate with the same directory if desired. - ''' + def _add_associated_directory(self, path): path = pathclass.Path(path) if not path.is_dir: @@ -305,6 +298,22 @@ class Album(ObjectBase, GroupableMixin): data = {'albumid': self.id, 'directory': path.absolute_path} self.photodb.sql_insert(table='album_associated_directories', data=data) + @decorators.required_feature('album.edit') + @decorators.transaction + def add_associated_directory(self, path): + ''' + Add a directory from which this album will pull files during rescans. + These relationships are not unique and multiple albums can associate + with the same directory if desired. + ''' + self._add_associated_directory(path) + + @decorators.required_feature('album.edit') + @decorators.transaction + def add_associated_directories(self, paths): + for path in paths: + self._add_associated_directory(path) + def _add_photo(self, photo): self.photodb.log.debug('Adding photo %s to %s', photo, self) data = {'albumid': self.id, 'photoid': photo.id}