From 15bbc35e656421d415cd6cba8accb83a77e7d84f Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Wed, 15 Jul 2020 00:21:20 +0100 Subject: [PATCH] Use query builder in tag list, add link to todo page --- app/blueprints/todo/__init__.py | 13 ++++++++++--- app/querybuilder.py | 5 +++-- app/templates/todo/list.html | 17 ++++++++++++++++- app/templates/todo/tags.html | 4 ++-- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/app/blueprints/todo/__init__.py b/app/blueprints/todo/__init__.py index 89e24b88..ba370a6f 100644 --- a/app/blueprints/todo/__init__.py +++ b/app/blueprints/todo/__init__.py @@ -64,10 +64,14 @@ def view(): .filter(~ db.exists().where(Package.forums==ForumTopic.topic_id)) \ .count() + total_packages = Package.query.filter_by(approved=True, soft_deleted=False).count() + total_to_tag = Package.query.filter_by(approved=True, soft_deleted=False, tags=None).count() + return render_template("todo/list.html", title="Reports and Work Queue", packages=packages, releases=releases, screenshots=screenshots, canApproveNew=canApproveNew, canApproveRel=canApproveRel, canApproveScn=canApproveScn, - topics_to_add=topics_to_add, total_topics=total_topics) + topics_to_add=topics_to_add, total_topics=total_topics, \ + total_packages=total_packages, total_to_tag=total_to_tag) @bp.route("/todo/topics/") @@ -105,7 +109,10 @@ def topics(): @bp.route("/todo/tags/") @login_required def tags(): - packages = Package.query.filter_by(approved=True, soft_deleted=False).all() + qb = QueryBuilder(request.args) + qb.setSortIfNone("score", "desc") + query = qb.buildPackageQuery() + tags = Tag.query.order_by(db.asc(Tag.title)).all() - return render_template("todo/tags.html", packages=packages, tags=tags) + return render_template("todo/tags.html", packages=query.all(), tags=tags) diff --git a/app/querybuilder.py b/app/querybuilder.py index 26c0b841..0333c24f 100644 --- a/app/querybuilder.py +++ b/app/querybuilder.py @@ -36,7 +36,7 @@ class QueryBuilder: self.hide_nonfree = "nonfree" in hide_flags self.limit = 1 if self.lucky else None self.order_by = args.get("sort") - self.order_dir = args.get("order") or "desc" + self.order_dir = args.get("order") or "asc" # Filters @@ -53,9 +53,10 @@ class QueryBuilder: if self.search is not None and self.search.strip() == "": self.search = None - def setSortIfNone(self, name): + def setSortIfNone(self, name, dir="asc"): if self.order_by is None: self.order_by = name + self.order_dir = dir def getMinetestVersion(self): if not self.protocol_version and not self.minetest_version: diff --git a/app/templates/todo/list.html b/app/templates/todo/list.html index ef5025eb..4d0b75cc 100644 --- a/app/templates/todo/list.html +++ b/app/templates/todo/list.html @@ -99,6 +99,22 @@

{% endif %} + +

Tag Packages

+ +

+ {{ total_to_tag }} / {{ total_packages }} packages don't have any tags. +

+ +
+ {% set perc = 100 * (total_packages - total_to_tag) / total_packages %} +
+
+ + View Tags + +

Unadded Topic List

{% if total_topics > 0 %} @@ -119,5 +135,4 @@ The forum topic crawler needs to run at least once for this section to work.

{% endif %} - {% endblock %} diff --git a/app/templates/todo/tags.html b/app/templates/todo/tags.html index e7675f8d..04f270ad 100644 --- a/app/templates/todo/tags.html +++ b/app/templates/todo/tags.html @@ -36,9 +36,9 @@ {% for tag in package.tags %} {{ tag.title }} {% endfor %} - + {% endfor %}