Replace Photo.sorted_tags with jinja filter.
This commit is contained in:
parent
50592f0ab4
commit
b19682d1a5
4 changed files with 6 additions and 6 deletions
|
@ -1155,11 +1155,6 @@ class Photo(ObjectBase):
|
|||
|
||||
self.__reinit__()
|
||||
|
||||
def sorted_tags(self):
|
||||
tags = self.get_tags()
|
||||
tags.sort(key=lambda x: x.qualified_name())
|
||||
return tags
|
||||
|
||||
|
||||
class Tag(ObjectBase, GroupableMixin):
|
||||
'''
|
||||
|
|
|
@ -34,6 +34,7 @@ site.jinja_env.trim_blocks = True
|
|||
site.jinja_env.lstrip_blocks = True
|
||||
site.jinja_env.filters['bytestring'] = jinja_filters.bytestring
|
||||
site.jinja_env.filters['file_link'] = jinja_filters.file_link
|
||||
site.jinja_env.filters['sort_by_qualname'] = jinja_filters.sort_by_qualname
|
||||
site.debug = True
|
||||
|
||||
P = etiquette.photodb.PhotoDB()
|
||||
|
|
|
@ -14,3 +14,7 @@ def file_link(photo, short=False):
|
|||
return f'/file/{photo.id}{photo.dot_extension}'
|
||||
basename = jinja2.filters.do_urlencode(photo.basename)
|
||||
return f'/file/{photo.id}/{basename}'
|
||||
|
||||
def sort_by_qualname(tags):
|
||||
tags = sorted(tags, key=lambda x: x.qualified_name())
|
||||
return tags
|
||||
|
|
|
@ -163,7 +163,7 @@
|
|||
<input id="add_tag_textbox" type="text" autofocus>
|
||||
<button id="add_tag_button" class="green_button" onclick="submit_tag(receive_callback);">add</button>
|
||||
</li>
|
||||
{% set tags = photo.sorted_tags() %}
|
||||
{% set tags = photo.get_tags()|sort_by_qualname %}
|
||||
{% for tag in tags %}
|
||||
<li>
|
||||
{{tag_object.tag_object(tag, qualified_name=True, max_len=30, with_alt_description=True, with_alt_qualified_name=True)}}<!--
|
||||
|
|
Loading…
Reference in a new issue