Add ability to filter by minetest-mods in outdated page
This commit is contained in:
parent
d7647520c8
commit
c6a973f7e1
|
@ -21,7 +21,7 @@ from sqlalchemy import or_
|
||||||
|
|
||||||
from app.models import *
|
from app.models import *
|
||||||
from app.querybuilder import QueryBuilder
|
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
|
from app.tasks.importtasks import makeVCSRelease
|
||||||
|
|
||||||
bp = Blueprint("todo", __name__)
|
bp = Blueprint("todo", __name__)
|
||||||
|
@ -226,11 +226,16 @@ def apply_all_updates(username):
|
||||||
@bp.route("/todo/outdated/")
|
@bp.route("/todo/outdated/")
|
||||||
@login_required
|
@login_required
|
||||||
def outdated():
|
def outdated():
|
||||||
|
is_mtm_only = isYes(request.args.get("mtm"))
|
||||||
|
|
||||||
query = db.session.query(Package).select_from(PackageUpdateConfig) \
|
query = db.session.query(Package).select_from(PackageUpdateConfig) \
|
||||||
.filter(PackageUpdateConfig.outdated_at.isnot(None)) \
|
.filter(PackageUpdateConfig.outdated_at.isnot(None)) \
|
||||||
.join(PackageUpdateConfig.package) \
|
.join(PackageUpdateConfig.package) \
|
||||||
.filter(Package.state == PackageState.APPROVED)
|
.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")
|
sort_by = request.args.get("sort")
|
||||||
if sort_by == "date":
|
if sort_by == "date":
|
||||||
query = query.order_by(db.desc(PackageUpdateConfig.outdated_at))
|
query = query.order_by(db.desc(PackageUpdateConfig.outdated_at))
|
||||||
|
@ -239,4 +244,4 @@ def outdated():
|
||||||
query = query.order_by(db.desc(Package.score))
|
query = query.order_by(db.desc(Package.score))
|
||||||
|
|
||||||
return render_template("todo/outdated.html", current_tab="outdated",
|
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)
|
||||||
|
|
|
@ -5,15 +5,29 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="btn-group btn-group-sm float-right">
|
<div class="btn-toolbar float-right">
|
||||||
<a class="btn btn-secondary {% if sort_by == 'date' %}active{% endif %}"
|
<div class="btn-group btn-group-sm mr-2">
|
||||||
href="{{ url_set_query(sort='date') }}">
|
{% if is_mtm_only %}
|
||||||
Sort by date
|
<a class="btn btn-sm btn-primary active" href="{{ url_set_query(mtm=0) }}">
|
||||||
</a>
|
Minetest Mods only
|
||||||
<a class="btn btn-secondary {% if sort_by == 'score' %}active{% endif %}"
|
</a>
|
||||||
href="{{ url_set_query(sort='score') }}">
|
{% else %}
|
||||||
Sort by score
|
<a class="btn btn-sm btn-secondary" href="{{ url_set_query(mtm=1) }}">
|
||||||
</a>
|
Minetest Mods 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>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue