Rename Tag.synonyms -> get_synonyms.

This commit is contained in:
voussoir 2018-02-16 23:01:07 -08:00
parent fdcf07940a
commit 6574450ad1
4 changed files with 13 additions and 13 deletions

View file

@ -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):

View file

@ -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):
'''

View file

@ -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)

View file

@ -135,7 +135,7 @@ body
--><button class="remove_tag_button red_button" onclick="delete_tag('{{tag.name}}', receive_callback);"></button>
</li>
{% if include_synonyms %}
{% for synonym in tag.synonyms() %}
{% for synonym in tag.get_synonyms() %}
<li>
{{tag_object.tag_object(tag, innertext='(+)', link=none)}}
{{tag_object.tag_object(tag, innertext=qualified_name + '+' + synonym, link='search')}}<!--