From 205c49c21f2dd384e2832d89ef69dd1a530eaa5f Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Fri, 16 Feb 2018 23:08:44 -0800 Subject: [PATCH] Rename Photo.albums -> get_containing_albums. --- etiquette/jsonify.py | 2 +- etiquette/objects.py | 20 +++++++++---------- .../etiquette_flask/templates/photo.html | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/etiquette/jsonify.py b/etiquette/jsonify.py index ffc5562..ec36447 100644 --- a/etiquette/jsonify.py +++ b/etiquette/jsonify.py @@ -55,7 +55,7 @@ def photo(p, include_albums=True, include_tags=True): 'mimetype': p.mimetype, } if include_albums: - j['albums'] = [album(a, minimal=True) for a in p.albums()] + j['albums'] = [album(a, minimal=True) for a in p.get_containing_albums()] if include_tags: j['tags'] = [tag(t) for t in tags] diff --git a/etiquette/objects.py b/etiquette/objects.py index 3b01ea2..f198ae5 100644 --- a/etiquette/objects.py +++ b/etiquette/objects.py @@ -635,16 +635,6 @@ class Photo(ObjectBase): self.photodb.commit() return tag - def albums(self): - ''' - Return the albums of which this photo is a member. - ''' - cur = self.photodb.sql.cursor() - cur.execute('SELECT albumid FROM album_photo_rel WHERE photoid == ?', [self.id]) - fetches = cur.fetchall() - albums = [self.photodb.get_album(id=fetch[0]) for fetch in fetches] - return albums - @property def author(self): ''' @@ -792,6 +782,16 @@ class Photo(ObjectBase): self.__reinit__() return self.thumbnail + def get_containing_albums(self): + ''' + Return the albums of which this photo is a member. + ''' + cur = self.photodb.sql.cursor() + cur.execute('SELECT albumid FROM album_photo_rel WHERE photoid == ?', [self.id]) + fetches = cur.fetchall() + albums = [self.photodb.get_album(id=fetch[0]) for fetch in fetches] + return albums + def get_tags(self): ''' Return the tags assigned to this Photo. diff --git a/frontends/etiquette_flask/templates/photo.html b/frontends/etiquette_flask/templates/photo.html index eb4f9c9..7050f9a 100644 --- a/frontends/etiquette_flask/templates/photo.html +++ b/frontends/etiquette_flask/templates/photo.html @@ -202,7 +202,7 @@ - {% set albums = photo.albums() %} + {% set albums = photo.get_containing_albums() %} {% if albums %}

Albums containing this photo