From c6a973f7e1187289725ad2e176d9e1e44051f74e Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Mon, 1 Feb 2021 21:18:27 +0000 Subject: [PATCH] Add ability to filter by minetest-mods in outdated page --- app/blueprints/todo/__init__.py | 9 +++++++-- app/templates/todo/outdated.html | 32 +++++++++++++++++++++++--------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/app/blueprints/todo/__init__.py b/app/blueprints/todo/__init__.py index be972593..382b01c1 100644 --- a/app/blueprints/todo/__init__.py +++ b/app/blueprints/todo/__init__.py @@ -21,7 +21,7 @@ from sqlalchemy import or_ from app.models import * from app.querybuilder import QueryBuilder -from app.utils import get_int_or_abort, addNotification, addAuditLog +from app.utils import get_int_or_abort, addNotification, addAuditLog, isYes from app.tasks.importtasks import makeVCSRelease bp = Blueprint("todo", __name__) @@ -226,11 +226,16 @@ def apply_all_updates(username): @bp.route("/todo/outdated/") @login_required def outdated(): + is_mtm_only = isYes(request.args.get("mtm")) + query = db.session.query(Package).select_from(PackageUpdateConfig) \ .filter(PackageUpdateConfig.outdated_at.isnot(None)) \ .join(PackageUpdateConfig.package) \ .filter(Package.state == PackageState.APPROVED) + if is_mtm_only: + query = query.filter(Package.repo.ilike("%github.com/minetest-mods/%")) + sort_by = request.args.get("sort") if sort_by == "date": query = query.order_by(db.desc(PackageUpdateConfig.outdated_at)) @@ -239,4 +244,4 @@ def outdated(): query = query.order_by(db.desc(Package.score)) return render_template("todo/outdated.html", current_tab="outdated", - outdated_packages=query.all(), sort_by=sort_by) + outdated_packages=query.all(), sort_by=sort_by, is_mtm_only=is_mtm_only) diff --git a/app/templates/todo/outdated.html b/app/templates/todo/outdated.html index 0986ab28..870d0ceb 100644 --- a/app/templates/todo/outdated.html +++ b/app/templates/todo/outdated.html @@ -5,15 +5,29 @@ {% endblock %} {% block content %} -
- - Sort by date - - - Sort by score - +
+
+ {% if is_mtm_only %} + + Minetest Mods only + + {% else %} + + Minetest Mods only + + {% endif %} +
+ +