diff --git a/etiquette/objects.py b/etiquette/objects.py index 43d766e..d2ca3ef 100644 --- a/etiquette/objects.py +++ b/etiquette/objects.py @@ -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): ''' diff --git a/frontends/etiquette_flask/etiquette_flask/common.py b/frontends/etiquette_flask/etiquette_flask/common.py index d3e5bf3..b6aa751 100644 --- a/frontends/etiquette_flask/etiquette_flask/common.py +++ b/frontends/etiquette_flask/etiquette_flask/common.py @@ -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() diff --git a/frontends/etiquette_flask/etiquette_flask/jinja_filters.py b/frontends/etiquette_flask/etiquette_flask/jinja_filters.py index 63deaa6..15d0465 100644 --- a/frontends/etiquette_flask/etiquette_flask/jinja_filters.py +++ b/frontends/etiquette_flask/etiquette_flask/jinja_filters.py @@ -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 diff --git a/frontends/etiquette_flask/templates/photo.html b/frontends/etiquette_flask/templates/photo.html index 6d7b197..1e9c73c 100644 --- a/frontends/etiquette_flask/templates/photo.html +++ b/frontends/etiquette_flask/templates/photo.html @@ -163,7 +163,7 @@ - {% set tags = photo.sorted_tags() %} + {% set tags = photo.get_tags()|sort_by_qualname %} {% for tag in tags %}
  • {{tag_object.tag_object(tag, qualified_name=True, max_len=30, with_alt_description=True, with_alt_qualified_name=True)}}