Add ability to sort outdated packages list
This commit is contained in:
parent
9acb7698ef
commit
60a33a6492
|
@ -174,10 +174,16 @@ def view_user(username=None):
|
||||||
@bp.route("/todo/outdated/")
|
@bp.route("/todo/outdated/")
|
||||||
@login_required
|
@login_required
|
||||||
def outdated():
|
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)) \
|
.filter(PackageUpdateConfig.outdated_at.isnot(None)) \
|
||||||
.order_by(db.desc(PackageUpdateConfig.outdated_at)) \
|
|
||||||
.join(PackageUpdateConfig.package) \
|
.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 %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% 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 %}
|
{% from "macros/todo.html" import render_outdated_packages %}
|
||||||
{{ render_outdated_packages(outdated_packages) }}
|
{{ render_outdated_packages(outdated_packages) }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -6,38 +6,37 @@ Topics to be Added
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="float-right">
|
<div class="float-right">
|
||||||
<div class="btn-group">
|
<div class="btn-group btn-group-sm mr-2">
|
||||||
<a class="btn btn-primary {% if sort_by=='date' %}active{% endif %}"
|
<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') }}">
|
href="{{ url_for('todo.topics', q=query, show_discarded=show_discarded, n=n, sort='date') }}">
|
||||||
Sort by date
|
Sort by date
|
||||||
</a>
|
</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') }}">
|
href="{{ url_for('todo.topics', q=query, show_discarded=show_discarded, n=n, sort='name') }}">
|
||||||
Sort by name
|
Sort by name
|
||||||
</a>
|
</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') }}">
|
href="{{ url_for('todo.topics', q=query, show_discarded=show_discarded, n=n, sort='views') }}">
|
||||||
Sort by views
|
Sort by views
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="btn-group btn-group-sm">
|
||||||
<div class="btn-group">
|
|
||||||
{% if current_user.rank.atLeast(current_user.rank.EDITOR) %}
|
{% if current_user.rank.atLeast(current_user.rank.EDITOR) %}
|
||||||
{% if n >= 10000 %}
|
{% 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) }}">
|
href="{{ url_for('todo.topics', q=query, show_discarded=show_discarded, n=100, sort=sort_by) }}">
|
||||||
Paginated list
|
Paginated list
|
||||||
</a>
|
</a>
|
||||||
{% else %}
|
{% 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) }}">
|
href="{{ url_for('todo.topics', q=query, show_discarded=show_discarded, n=10000, sort=sort_by) }}">
|
||||||
Unlimited list
|
Unlimited list
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% 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 %}
|
{% if not show_discarded %}
|
||||||
Show
|
Show
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
Loading…
Reference in New Issue