mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-23 06:22:24 +01:00
Add sort by option to topic list
This commit is contained in:
parent
b0a5980833
commit
daded6d193
@ -9,17 +9,28 @@ Topics to be Added
|
|||||||
{% 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-primary"
|
||||||
href="{{ url_for('todo_topics_page', q=query, show_discarded=show_discarded, n=100) }}">
|
href="{{ url_for('todo_topics_page', q=query, show_discarded=show_discarded, n=100, sort=sort_by) }}">
|
||||||
Paginiated List
|
Paginiated List
|
||||||
</a>
|
</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a class="btn btn-primary"
|
<a class="btn btn-primary"
|
||||||
href="{{ url_for('todo_topics_page', q=query, show_discarded=show_discarded, n=10000) }}">
|
href="{{ url_for('todo_topics_page', 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_page', q=query, show_discarded=not show_discarded) }}">
|
{% if sort_by == "name" %}
|
||||||
|
<a class="btn btn-primary"
|
||||||
|
href="{{ url_for('todo_topics_page', q=query, show_discarded=show_discarded, n=n, sort='date') }}">
|
||||||
|
Sort by date
|
||||||
|
</a>
|
||||||
|
{% else %}
|
||||||
|
<a class="btn btn-primary"
|
||||||
|
href="{{ url_for('todo_topics_page', q=query, show_discarded=show_discarded, n=n, sort='name') }}">
|
||||||
|
Sort by name
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
<a class="btn btn-primary" href="{{ url_for('todo_topics_page', q=query, show_discarded=not show_discarded, n=n, sort=sort_by) }}">
|
||||||
{% if not show_discarded %}
|
{% if not show_discarded %}
|
||||||
Show
|
Show
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@ -63,7 +63,12 @@ def todo_topics_page():
|
|||||||
total = query.count()
|
total = query.count()
|
||||||
|
|
||||||
query = query.filter(~ db.exists().where(Package.forums==ForumTopic.topic_id)) \
|
query = query.filter(~ db.exists().where(Package.forums==ForumTopic.topic_id)) \
|
||||||
.order_by(db.asc(ForumTopic.wip), db.asc(ForumTopic.name), db.asc(ForumTopic.title))
|
|
||||||
|
sort_by = request.args.get("sort")
|
||||||
|
if sort_by == "name":
|
||||||
|
query = query.order_by(db.asc(ForumTopic.wip), db.asc(ForumTopic.name), db.asc(ForumTopic.title))
|
||||||
|
elif sort_by is None or sort_by == "date":
|
||||||
|
query = query.order_by(db.asc(ForumTopic.created_at))
|
||||||
|
|
||||||
topic_count = query.count()
|
topic_count = query.count()
|
||||||
|
|
||||||
@ -85,4 +90,4 @@ def todo_topics_page():
|
|||||||
return render_template("todo/topics.html", topics=query.items, total=total, \
|
return render_template("todo/topics.html", topics=query.items, total=total, \
|
||||||
topic_count=topic_count, query=search, show_discarded=show_discarded, \
|
topic_count=topic_count, query=search, show_discarded=show_discarded, \
|
||||||
next_url=next_url, prev_url=prev_url, page=page, page_max=query.pages, \
|
next_url=next_url, prev_url=prev_url, page=page, page_max=query.pages, \
|
||||||
n=num)
|
n=num, sort_by=sort_by)
|
||||||
|
Loading…
Reference in New Issue
Block a user