Add ability to search admin tag list by views

This commit is contained in:
rubenwardy 2020-07-17 23:17:25 +01:00
parent e2a9ea91cf
commit 980e1c9eb1
2 changed files with 14 additions and 1 deletions

@ -30,7 +30,14 @@ def tag_list():
if not Permission.EDIT_TAGS.check(current_user):
abort(403)
return render_template("admin/tags/list.html", tags=Tag.query.order_by(db.asc(Tag.title)).all())
query = Tag.query
if request.args.get("sort") == "views":
query = query.order_by(db.desc(Tag.views))
else:
query = query.order_by(db.asc(Tag.title))
return render_template("admin/tags/list.html", tags=query.all())
class TagForm(FlaskForm):
title = StringField("Title", [InputRequired(), Length(3,100)])

@ -9,6 +9,12 @@
<h1>{{ _("Tags") }}</h1>
<p class="float-right">
Sort by:
<a href="{{ url_set_query(sort='name') }}">Name</a> |
<a href="{{ url_set_query(sort='views') }}">Views</a>
</p>
<p>
Also see <a href="/help/package_tags/">Package Tags</a>.
</p>