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