aboutsummaryrefslogtreecommitdiff
path: root/app/blueprints/admin
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2020-07-17 23:17:25 +0100
committerrubenwardy <rw@rubenwardy.com>2020-07-17 23:17:25 +0100
commit980e1c9eb1a6e15ad4471eba140ed30107ba4c80 (patch)
treed067498a8342a5ecc992e1def14cc84d6f641934 /app/blueprints/admin
parente2a9ea91cfae79dded1f223bd288af40bd657863 (diff)
downloadcheatdb-980e1c9eb1a6e15ad4471eba140ed30107ba4c80.tar.xz
Add ability to search admin tag list by views
Diffstat (limited to 'app/blueprints/admin')
-rw-r--r--app/blueprints/admin/tagseditor.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/app/blueprints/admin/tagseditor.py b/app/blueprints/admin/tagseditor.py
index d9cc913..f6dcc19 100644
--- a/app/blueprints/admin/tagseditor.py
+++ b/app/blueprints/admin/tagseditor.py
@@ -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)])