From 51d2b82acfec935bad701e5062780995859dc918 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Sat, 15 Oct 2022 12:53:17 +0100 Subject: [PATCH] Add page to list mods that don't support current version --- app/blueprints/todo/__init__.py | 26 +++++++++++++ app/templates/macros/todo.html | 56 ++++++++++++++++++++------- app/templates/todo/mtver_support.html | 38 ++++++++++++++++++ 3 files changed, 106 insertions(+), 14 deletions(-) create mode 100644 app/templates/todo/mtver_support.html diff --git a/app/blueprints/todo/__init__.py b/app/blueprints/todo/__init__.py index cb3d5a92..00ae937d 100644 --- a/app/blueprints/todo/__init__.py +++ b/app/blueprints/todo/__init__.py @@ -13,6 +13,7 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +import sys from celery import uuid from flask import * @@ -295,3 +296,28 @@ def screenshots(): return render_template("todo/screenshots.html", current_tab="screenshots", packages=query.all(), sort_by=sort_by, is_mtm_only=is_mtm_only) + + +@bp.route("/todo/mtver_support/") +@login_required +def mtver_support(): + is_mtm_only = isYes(request.args.get("mtm")) + + current_stable = MinetestRelease.query.filter(~MinetestRelease.name.like("%-dev")).order_by(db.desc(MinetestRelease.id)).first() + + query = db.session.query(Package) \ + .filter(~Package.releases.any(or_(PackageRelease.max_rel==None, PackageRelease.max_rel == current_stable))) \ + .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(Package.approved_at)) + else: + sort_by = "score" + query = query.order_by(db.desc(Package.score)) + + return render_template("todo/mtver_support.html", current_tab="screenshots", + packages=query.all(), sort_by=sort_by, is_mtm_only=is_mtm_only, current_stable=current_stable) diff --git a/app/templates/macros/todo.html b/app/templates/macros/todo.html index f714ddc8..f98454ff 100644 --- a/app/templates/macros/todo.html +++ b/app/templates/macros/todo.html @@ -1,21 +1,19 @@ -{% macro render_outdated_packages(outdated_packages, current_player, show_config=False) -%} +{% macro render_outdated_packages(outdated_packages, current_user, show_config=False) -%} {% endmacro %} + +{% macro render_mtsupport_packages(packages, current_user, show_config=False) -%} + +{% endmacro %} diff --git a/app/templates/todo/mtver_support.html b/app/templates/todo/mtver_support.html new file mode 100644 index 00000000..f2955fbf --- /dev/null +++ b/app/templates/todo/mtver_support.html @@ -0,0 +1,38 @@ +{% extends "base.html" %} + +{% block title %} + {{ _("Packages not supporting %(rel)s", rel=current_stable.name) }} +{% endblock %} + +{% block content %} +

{{ self.title() }}

+ +
+ + + {% from "macros/todo.html" import render_mtsupport_packages %} + {{ render_mtsupport_packages(packages, current_user) }} +{% endblock %}