From 2f9b51b6364dfe6b2b63f76efd066ecd215531b9 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Fri, 16 Feb 2018 23:07:21 -0800 Subject: [PATCH] Rename Photo.tags -> get_tags. --- etiquette/jsonify.py | 2 +- etiquette/objects.py | 28 +++++++++---------- etiquette/photodb.py | 2 +- .../endpoints/photo_endpoints.py | 2 +- .../etiquette_flask/templates/photo_card.html | 2 +- .../etiquette_repl/etiquette_repl_launch.py | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/etiquette/jsonify.py b/etiquette/jsonify.py index d5aa263..ffc5562 100644 --- a/etiquette/jsonify.py +++ b/etiquette/jsonify.py @@ -36,7 +36,7 @@ def exception(e): return j def photo(p, include_albums=True, include_tags=True): - tags = p.tags() + tags = p.get_tags() tags.sort(key=lambda x: x.name) j = { 'id': p.id, diff --git a/etiquette/objects.py b/etiquette/objects.py index 7aeb7b3..3b01ea2 100644 --- a/etiquette/objects.py +++ b/etiquette/objects.py @@ -664,7 +664,7 @@ class Photo(ObjectBase): ''' Take all of the tags owned by other_photo and apply them to this photo. ''' - for tag in other_photo.tags(): + for tag in other_photo.get_tags(): self.add_tag(tag) @decorators.required_feature('photo.edit') @@ -792,6 +792,18 @@ class Photo(ObjectBase): self.__reinit__() return self.thumbnail + def get_tags(self): + ''' + Return the tags assigned to this Photo. + ''' + generator = helpers.select_generator( + self.photodb.sql, + 'SELECT tagid FROM photo_tag_rel WHERE photoid == ?', + [self.id] + ) + tags = [self.photodb.get_tag(id=fetch[0]) for fetch in generator] + return tags + def has_tag(self, tag, *, check_children=True): ''' Return the Tag object if this photo contains that tag. @@ -1024,22 +1036,10 @@ class Photo(ObjectBase): self.__reinit__() def sorted_tags(self): - tags = self.tags() + tags = self.get_tags() tags.sort(key=lambda x: x.qualified_name()) return tags - def tags(self): - ''' - Return the tags assigned to this Photo. - ''' - generator = helpers.select_generator( - self.photodb.sql, - 'SELECT tagid FROM photo_tag_rel WHERE photoid == ?', - [self.id] - ) - tags = [self.photodb.get_tag(id=fetch[0]) for fetch in generator] - return tags - class Tag(ObjectBase, GroupableMixin): ''' diff --git a/etiquette/photodb.py b/etiquette/photodb.py index d3efadc..0515cdd 100644 --- a/etiquette/photodb.py +++ b/etiquette/photodb.py @@ -634,7 +634,7 @@ class PDBPhotoMixin: continue if (has_tags is not None) or is_tagsearch: - photo_tags = set(photo.tags()) + photo_tags = set(photo.get_tags()) if has_tags is False and len(photo_tags) > 0: continue diff --git a/frontends/etiquette_flask/etiquette_flask/endpoints/photo_endpoints.py b/frontends/etiquette_flask/etiquette_flask/endpoints/photo_endpoints.py index ce0f5fc..83d276c 100644 --- a/frontends/etiquette_flask/etiquette_flask/endpoints/photo_endpoints.py +++ b/frontends/etiquette_flask/etiquette_flask/endpoints/photo_endpoints.py @@ -211,7 +211,7 @@ def get_search_core(): # TAGS ON THIS PAGE total_tags = set() for photo in photos: - for tag in photo.tags(): + for tag in photo.get_tags(): total_tags.add(tag) total_tags = sorted(total_tags, key=lambda t: t.qualified_name()) diff --git a/frontends/etiquette_flask/templates/photo_card.html b/frontends/etiquette_flask/templates/photo_card.html index d7af0a2..39581ba 100644 --- a/frontends/etiquette_flask/templates/photo_card.html +++ b/frontends/etiquette_flask/templates/photo_card.html @@ -37,7 +37,7 @@ {% endif %} {% set tag_names_title = [] %} -{% for tag in photo.tags() %} +{% for tag in photo.get_tags() %} {% do tag_names_title.append(tag.name) %} {% endfor %} diff --git a/frontends/etiquette_repl/etiquette_repl_launch.py b/frontends/etiquette_repl/etiquette_repl_launch.py index ac3f5a6..4335f71 100644 --- a/frontends/etiquette_repl/etiquette_repl_launch.py +++ b/frontends/etiquette_repl/etiquette_repl_launch.py @@ -30,7 +30,7 @@ def easytagger(): def photag(photo_id): photo = P.get_photo_by_id(photo_id) - print(photo.tags()) + print(photo.get_tags()) while True: photo.add_tag(input('> ')) get = P.get_tag