mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-08 22:17:34 +01:00
Add sort toggle bar to topics list
This commit is contained in:
parent
515248eb8b
commit
d09ede00fb
@ -70,17 +70,17 @@
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url_for('user_profile_page', username=current_user.username) }}">Profile</a>
|
||||
</li class="nav-item">
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url_for('user_profile_page', username=current_user.username) }}#unadded-topics">Your unadded topics</a>
|
||||
</li class="nav-item">
|
||||
</li>
|
||||
{% if current_user.canAccessTodoList() %}
|
||||
<li class="nav-item"><a class="nav-link" href="{{ url_for('todo_page') }}">Work Queue</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="{{ url_for('user_list_page') }}">User list</a></li>
|
||||
{% endif %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url_for('todo_topics_page') }}">All unadded topics</a>
|
||||
</li class="nav-item">
|
||||
</li>
|
||||
{% if current_user.rank == current_user.rank.ADMIN %}
|
||||
<li class="nav-item"><a class="nav-link" href="{{ url_for('admin_page') }}">Admin</a></li>
|
||||
{% endif %}
|
||||
|
@ -5,40 +5,48 @@ Topics to be Added
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="float-right btn-group">
|
||||
{% if current_user.rank.atLeast(current_user.rank.EDITOR) %}
|
||||
{% if n >= 10000 %}
|
||||
<a class="btn btn-primary"
|
||||
href="{{ url_for('todo_topics_page', q=query, show_discarded=show_discarded, n=100, sort=sort_by) }}">
|
||||
Paginated List
|
||||
</a>
|
||||
{% else %}
|
||||
<a class="btn btn-primary"
|
||||
href="{{ url_for('todo_topics_page', q=query, show_discarded=show_discarded, n=10000, sort=sort_by) }}">
|
||||
Unlimited List
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if sort_by == "name" %}
|
||||
<a class="btn btn-primary"
|
||||
<div class="float-right">
|
||||
<div class="btn-group">
|
||||
<a class="btn btn-primary {% if sort_by=='date' %}active{% endif %}"
|
||||
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"
|
||||
<a class="btn btn-primary {% if sort_by=='name' %}active{% endif %}"
|
||||
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 %}
|
||||
Show
|
||||
{% else %}
|
||||
Hide
|
||||
<a class="btn btn-primary {% if sort_by=='views' %}active{% endif %}"
|
||||
href="{{ url_for('todo_topics_page', q=query, show_discarded=show_discarded, n=n, sort='views') }}">
|
||||
Sort by views
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="btn-group">
|
||||
{% if current_user.rank.atLeast(current_user.rank.EDITOR) %}
|
||||
{% if n >= 10000 %}
|
||||
<a class="btn btn-primary"
|
||||
href="{{ url_for('todo_topics_page', q=query, show_discarded=show_discarded, n=100, sort=sort_by) }}">
|
||||
Paginated list
|
||||
</a>
|
||||
{% else %}
|
||||
<a class="btn btn-primary"
|
||||
href="{{ url_for('todo_topics_page', q=query, show_discarded=show_discarded, n=10000, sort=sort_by) }}">
|
||||
Unlimited list
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
Discarded Topics
|
||||
</a>
|
||||
<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 %}
|
||||
Show
|
||||
{% else %}
|
||||
Hide
|
||||
{% endif %}
|
||||
|
||||
discarded topics
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h1>Topics to be Added</h1>
|
||||
|
@ -68,8 +68,11 @@ def todo_topics_page():
|
||||
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 == "views":
|
||||
query = query.order_by(db.desc(ForumTopic.views))
|
||||
elif sort_by is None or sort_by == "date":
|
||||
query = query.order_by(db.asc(ForumTopic.created_at))
|
||||
sort_by = "date"
|
||||
|
||||
topic_count = query.count()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user