commit bbda33a6f04cda956d93fee15c90b5a66b655c76
parent 9be8a1f54657852b316ae536a75bfd0a8c808aa2
Author: parazyd <parazyd@dyne.org>
Date: Sun, 20 Jan 2019 19:07:29 +0100
Add sorting per country to dashboard.
Diffstat:
4 files changed, 37 insertions(+), 9 deletions(-)
diff --git a/diaspora.py b/diaspora.py
@@ -284,7 +284,7 @@ def dashboard():
if not current_user.is_admin:
return render_template('fail_permissions.html')
- fparam = {'pending': 0, 'posted': 1}
+ fparam = {'pending': 0, 'published': 1}
add_id = request.args.get('approveid')
if add_id:
@@ -296,10 +296,19 @@ def dashboard():
sql_update_row_where([('visible', 0)], 'id', hide_id)
return render_template('success_hide.html')
-
act = request.args.get('list', 'pending')
+
+ ccto = request.args.get('to')
+ filtered = None
+ if ccto:
+ filtered = get_multiple_stories_filtered('visible', fparam[act], ('disembark', ccto))
+
stories = get_multiple_stories('visible', fparam[act])
- return render_template('dashboard.html', stories=stories)
+ clist = [(i['disembark'], i['disembarkname']) for i in stories]
+ clist = list(set(clist))
+ return render_template('dashboard.html', stories=stories,
+ filtered_stories=filtered,
+ listtype=act, clist=clist, ccto=ccto)
@app.route('/users', methods=['GET', 'POST'])
diff --git a/templates/dashboard.html b/templates/dashboard.html
@@ -6,16 +6,21 @@
<main role="main" class="container cover">
- <h1 class="cover-heading">Dashboard</h1>
+ <h1 class="cover-heading">Dashboard - {{ listtype }} stories</h1>
<div class="album py-5 bg-light">
<div class="container">
+ {% if filtered_stories %}
+ {% set stor = filtered_stories %}
+ {% else %}
+ {% set stor = stories %}
+ {% endif %}
- {% if not stories %}
+ {% if not stor %}
<p>No stories to list.</p>
{% endif %}
- {% for i in stories %}
+ {% for i in stor %}
{% if loop.index % 3 == 1 %}
<div class="row">
{% endif %}
@@ -58,6 +63,20 @@
</div>
</div>
+ <div class="container">
+ <div class="countrylist-bottom">
+ <p class="lead">List by country of disembarkment:</p>
+ <a href="/dashboard?list={{ listtype }}">
+ <img style="height: 2em;" src="/static/img/flags/globe.png" alt="All around the globe" title="All around the globe">
+ </a>
+ {% for j in clist %}
+ <!-- LIST ONLY FROM J TO I -->
+ <a href="/dashboard?list={{ listtype}}&to={{ j[0] }}">
+ <img style="height: 2em;" src="/static/img/flags/{{ j[0] }}.png" alt="{{ j[1] }}" title="{{ j[1] }}">
+ </a>
+ {% endfor %}
+ </div>
+
</main>
{% include 'footer.html' %}
diff --git a/templates/nav.html b/templates/nav.html
@@ -46,8 +46,8 @@
<a class="dropdown-item" href="/dashboard?list=pending">
<span class="fa fa-envelope"></span> Pending stories
</a>
- <a class="dropdown-item" href="/dashboard?list=posted">
- <span class="fa fa-envelope-open"></span> Posted stories
+ <a class="dropdown-item" href="/dashboard?list=published">
+ <span class="fa fa-envelope-open"></span> Published stories
</a>
<a class="dropdown-item" href="/users">
<span class="fa fa-user-circle"></span> Users
diff --git a/templates/success_hide.html b/templates/success_hide.html
@@ -8,7 +8,7 @@
<h1 class="cover-heading">Story hidden.</h1>
- <p class="lead">You can return to the <a href="/dashboard?list=posted">dashboard</a> now.</p>
+ <p class="lead">You can return to the <a href="/dashboard?list=published">dashboard</a> now.</p>
</main>