diff --git a/etiquette/jsonify.py b/etiquette/jsonify.py index f0f9d28..db7cdae 100644 --- a/etiquette/jsonify.py +++ b/etiquette/jsonify.py @@ -70,7 +70,7 @@ def tag(t, include_synonyms=False): 'qualified_name': t.qualified_name(), } if include_synonyms: - j['synonyms'] = list(t.synonyms()) + j['synonyms'] = list(t.get_synonyms()) return j def user(u): diff --git a/etiquette/objects.py b/etiquette/objects.py index 0a9bed3..86d9ba2 100644 --- a/etiquette/objects.py +++ b/etiquette/objects.py @@ -1197,6 +1197,13 @@ class Tag(ObjectBase, GroupableMixin): self.photodb.log.debug('Committing - edit tag') self.photodb.commit() + def get_synonyms(self): + cur = self.photodb.sql.cursor() + cur.execute('SELECT name FROM tag_synonyms WHERE mastername == ?', [self.name]) + fetches = [fetch[0] for fetch in cur.fetchall()] + fetches.sort() + return fetches + @decorators.required_feature('tag.edit') def join_group(self, *args, **kwargs): return super().join_group(*args, **kwargs) @@ -1307,13 +1314,6 @@ class Tag(ObjectBase, GroupableMixin): self.photodb.log.debug('Committing - rename tag') self.photodb.commit() - def synonyms(self): - cur = self.photodb.sql.cursor() - cur.execute('SELECT name FROM tag_synonyms WHERE mastername == ?', [self.name]) - fetches = [fetch[0] for fetch in cur.fetchall()] - fetches.sort() - return fetches - class User(ObjectBase): ''' diff --git a/etiquette/tag_export.py b/etiquette/tag_export.py index 7384a37..dcdd0ee 100644 --- a/etiquette/tag_export.py +++ b/etiquette/tag_export.py @@ -17,7 +17,7 @@ def easybake(tags): for tag in tags: qualname = tag.qualified_name() lines.append(qualname) - lines.extend(qualname + '+' + syn for syn in tag.synonyms()) + lines.extend(qualname + '+' + syn for syn in tag.get_synonyms()) return '\n'.join(lines) def flat_dict(tags): @@ -41,7 +41,7 @@ def flat_dict(tags): for child in tag.walk_children(): children = list(child.walk_children()) result[child] = children - for synonym in child.synonyms(): + for synonym in child.get_synonyms(): result[synonym] = children return result @@ -81,14 +81,14 @@ def qualified_names(tags): for tag in tags: qualname = tag.qualified_name() results[tag.name] = qualname - for synonym in tag.synonyms(): + for synonym in tag.get_synonyms(): results[synonym] = qualname return results def stdout(tags, depth=0): for tag in tags: children = tag.get_children() - synonyms = tag.synonyms() + synonyms = tag.get_synonyms() pad = ' ' * depth print(pad + tag.name) diff --git a/frontends/etiquette_flask/templates/tags.html b/frontends/etiquette_flask/templates/tags.html index 57e4ef0..8d1a42f 100644 --- a/frontends/etiquette_flask/templates/tags.html +++ b/frontends/etiquette_flask/templates/tags.html @@ -135,7 +135,7 @@ body --> {% if include_synonyms %} - {% for synonym in tag.synonyms() %} + {% for synonym in tag.get_synonyms() %}
  • {{tag_object.tag_object(tag, innertext='(+)', link=none)}} {{tag_object.tag_object(tag, innertext=qualified_name + '+' + synonym, link='search')}}