Add page to list mods that don't support current version

This commit is contained in:
rubenwardy 2022-10-15 12:53:17 +01:00
parent 5f42e35231
commit 51d2b82acf
3 changed files with 106 additions and 14 deletions

@ -13,6 +13,7 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
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)

@ -1,10 +1,9 @@
{% macro render_outdated_packages(outdated_packages, current_player, show_config=False) -%}
{% macro render_outdated_packages(outdated_packages, current_user, show_config=False) -%}
<ul class="list-group mt-3">
{% for package in outdated_packages %}
{% set config = package.update_config %}
<li class="list-group-item">
<div class="row">
{% if package %}
<a class="col-sm-auto text-muted" style="min-width: 200px;" href="{{ package.getURL("packages.view") }}">
<img
class="img-fluid"
@ -15,7 +14,6 @@
{{ package.title }}
</span>
</a>
{% endif %}
<div class="col-sm">
{% if show_config %}
@ -31,7 +29,7 @@
<div class="col-sm-auto">
{% if not show_config %}
{% if package.checkPerm(current_player, "MAKE_RELEASE") %}
{% if package.checkPerm(current_user, "MAKE_RELEASE") %}
<a class="btn btn-sm btn-primary mr-2" href="{{ config.get_create_release_url() }}">
<i class="fas fa-plus mr-1"></i>
{{ _("Release") }}
@ -44,7 +42,7 @@
{{ _("Repo") }}
</a>
{% if package.checkPerm(current_player, "MAKE_RELEASE") %}
{% if package.checkPerm(current_user, "MAKE_RELEASE") %}
<a class="btn btn-sm btn-secondary" href="{{ package.getURL("packages.update_config") }}">
<i class="fas fa-cog mr-1"></i>
{{ _("Update settings") }}
@ -58,3 +56,33 @@
{% endfor %}
</ul>
{% endmacro %}
{% macro render_mtsupport_packages(packages, current_user, show_config=False) -%}
<div class="list-group mt-3">
{% for package in packages %}
<a class="list-group-item list-group-item-action" href="{{ package.getURL('packages.list_releases') }}">
<div class="row">
<div class="col-sm-auto text-muted" style="min-width: 200px;">
<img
class="img-fluid"
style="max-height: 22px; max-width: 22px;"
src="{{ package.getThumbnailOrPlaceholder() }}" />
<span class="pl-2">
{{ package.title }}
</span>
</div>
<div class="col-sm">
{% set release = package.getDownloadRelease() %}
{% if release %}
{{ release.min_rel.name }} - {{ release.max_rel.name }}
{% endif %}
</div>
</div>
</a>
{% else %}
<p class="list-group-item"><i>{{ _("No outdated packages.") }}</i></p>
{% endfor %}
</div>
{% endmacro %}

@ -0,0 +1,38 @@
{% extends "base.html" %}
{% block title %}
{{ _("Packages not supporting %(rel)s", rel=current_stable.name) }}
{% endblock %}
{% block content %}
<h1>{{ self.title() }}</h1>
<div class="btn-toolbar float-right">
<div class="btn-group btn-group-sm mr-2">
{% if is_mtm_only %}
<a class="btn btn-sm btn-primary active" href="{{ url_set_query(mtm=0) }}">
{{ _("Minetest-Mods org only") }}
</a>
{% else %}
<a class="btn btn-sm btn-secondary" href="{{ url_set_query(mtm=1) }}">
{{ _("Minetest-Mods org only") }}
</a>
{% endif %}
</div>
<div class="btn-group btn-group-sm">
<a class="btn {% if sort_by == 'date' %}btn-primary active{% else %}btn-secondary{% endif %}"
href="{{ url_set_query(sort='date') }}">
{{ _("Sort by date") }}
</a>
<a class="btn {% if sort_by == 'score' %}btn-primary active{% else %}btn-secondary{% endif %}"
href="{{ url_set_query(sort='score') }}">
{{ _("Sort by score") }}
</a>
</div>
</div>
<div class="clearfix"></div>
{% from "macros/todo.html" import render_mtsupport_packages %}
{{ render_mtsupport_packages(packages, current_user) }}
{% endblock %}