mirror of
https://github.com/minetest/contentdb.git
synced 2025-03-14 14:22:30 +01:00
Add ability to sort outdated packages list
This commit is contained in:
@ -174,10 +174,16 @@ def view_user(username=None):
|
||||
@bp.route("/todo/outdated/")
|
||||
@login_required
|
||||
def outdated():
|
||||
outdated_packages = db.session.query(Package).select_from(PackageUpdateConfig) \
|
||||
query = db.session.query(Package).select_from(PackageUpdateConfig) \
|
||||
.filter(PackageUpdateConfig.outdated_at.isnot(None)) \
|
||||
.order_by(db.desc(PackageUpdateConfig.outdated_at)) \
|
||||
.join(PackageUpdateConfig.package) \
|
||||
.filter(Package.state == PackageState.APPROVED).all()
|
||||
.filter(Package.state == PackageState.APPROVED)
|
||||
|
||||
return render_template("todo/outdated.html", current_tab="outdated", outdated_packages=outdated_packages)
|
||||
sort_by = request.args.get("sort")
|
||||
if sort_by == "score":
|
||||
query = query.order_by(db.desc(Package.score))
|
||||
else:
|
||||
query = query.order_by(db.desc(PackageUpdateConfig.outdated_at))
|
||||
|
||||
return render_template("todo/outdated.html", current_tab="outdated",
|
||||
outdated_packages=query.all(), sort_by=sort_by)
|
||||
|
@ -5,6 +5,18 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="btn-group btn-group-sm float-right">
|
||||
<a class="btn btn-secondary {% if sort_by != 'score' %}active{% endif %}"
|
||||
href="{{ url_set_query(sort='date') }}">
|
||||
Sort by date
|
||||
</a>
|
||||
<a class="btn btn-secondary {% if sort_by == 'score' %}active{% endif %}"
|
||||
href="{{ url_set_query(sort='score') }}">
|
||||
Sort by score
|
||||
</a>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
|
||||
{% from "macros/todo.html" import render_outdated_packages %}
|
||||
{{ render_outdated_packages(outdated_packages) }}
|
||||
{% endblock %}
|
||||
|
@ -6,38 +6,37 @@ Topics to be Added
|
||||
|
||||
{% block content %}
|
||||
<div class="float-right">
|
||||
<div class="btn-group">
|
||||
<a class="btn btn-primary {% if sort_by=='date' %}active{% endif %}"
|
||||
<div class="btn-group btn-group-sm mr-2">
|
||||
<a class="btn btn-secondary {% if sort_by=='date' %}active{% endif %}"
|
||||
href="{{ url_for('todo.topics', q=query, show_discarded=show_discarded, n=n, sort='date') }}">
|
||||
Sort by date
|
||||
</a>
|
||||
<a class="btn btn-primary {% if sort_by=='name' %}active{% endif %}"
|
||||
<a class="btn btn-secondary {% if sort_by=='name' %}active{% endif %}"
|
||||
href="{{ url_for('todo.topics', q=query, show_discarded=show_discarded, n=n, sort='name') }}">
|
||||
Sort by name
|
||||
</a>
|
||||
<a class="btn btn-primary {% if sort_by=='views' %}active{% endif %}"
|
||||
<a class="btn btn-secondary {% if sort_by=='views' %}active{% endif %}"
|
||||
href="{{ url_for('todo.topics', q=query, show_discarded=show_discarded, n=n, sort='views') }}">
|
||||
Sort by views
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="btn-group">
|
||||
<div class="btn-group btn-group-sm">
|
||||
{% if current_user.rank.atLeast(current_user.rank.EDITOR) %}
|
||||
{% if n >= 10000 %}
|
||||
<a class="btn btn-primary"
|
||||
<a class="btn btn-secondary"
|
||||
href="{{ url_for('todo.topics', q=query, show_discarded=show_discarded, n=100, sort=sort_by) }}">
|
||||
Paginated list
|
||||
</a>
|
||||
{% else %}
|
||||
<a class="btn btn-primary"
|
||||
<a class="btn btn-secondary"
|
||||
href="{{ url_for('todo.topics', q=query, show_discarded=show_discarded, n=10000, sort=sort_by) }}">
|
||||
Unlimited list
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
<a class="btn btn-primary" href="{{ url_for('todo.topics', q=query, show_discarded=not show_discarded, n=n, sort=sort_by) }}">
|
||||
<a class="btn btn-secondary" href="{{ url_for('todo.topics', q=query, show_discarded=not show_discarded, n=n, sort=sort_by) }}">
|
||||
{% if not show_discarded %}
|
||||
Show
|
||||
{% else %}
|
||||
|
Reference in New Issue
Block a user