From d91f537bdd4915448a189b238051905975324d71 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Fri, 10 Jul 2020 19:46:14 +0100 Subject: Improve thread list style --- app/blueprints/threads/__init__.py | 2 ++ app/templates/macros/threads.html | 47 ++++++++++++++++++++++---------------- app/templates/packages/view.html | 2 +- app/templates/threads/list.html | 4 +++- 4 files changed, 33 insertions(+), 22 deletions(-) diff --git a/app/blueprints/threads/__init__.py b/app/blueprints/threads/__init__.py index 09b5eb7..1455c5d 100644 --- a/app/blueprints/threads/__init__.py +++ b/app/blueprints/threads/__init__.py @@ -41,6 +41,8 @@ def list_all(): pid = get_int_or_abort(pid) query = query.filter_by(package_id=pid) + query = query.order_by(db.desc(Thread.created_at)) + return render_template("threads/list.html", threads=query.all()) diff --git a/app/templates/macros/threads.html b/app/templates/macros/threads.html index 16b67a0..50be4fd 100644 --- a/app/templates/macros/threads.html +++ b/app/templates/macros/threads.html @@ -60,24 +60,31 @@ {% endif %} {% endmacro %} -{% macro render_threadlist(threads, list_group=False) -%} - {% if not list_group %}{% endif %} +{% macro render_threadlist(threads, compact=False) -%} + {% for t in threads %} + + {% if not compact %} + + {{ t.created_at | datetime }} + + + + {% if not t.review %} + + {% elif t.review.recommends %} + + {% else %} + + {% endif %} + + {% endif %} + + {% if t.private %}🔒 {% endif %} + {{ t.title }} + by {{ t.author.display_name }} + + {% else %} +

{% if list_group %}class="list-group-item"{% endif %}>No threads found

+ {% endfor %} {% endmacro %} diff --git a/app/templates/packages/view.html b/app/templates/packages/view.html index 53c7d74..dbac31e 100644 --- a/app/templates/packages/view.html +++ b/app/templates/packages/view.html @@ -409,7 +409,7 @@ diff --git a/app/templates/threads/list.html b/app/templates/threads/list.html index 7e27325..2d86190 100644 --- a/app/templates/threads/list.html +++ b/app/templates/threads/list.html @@ -8,5 +8,7 @@ Threads

Threads

{% from "macros/threads.html" import render_threadlist %} - {{ render_threadlist(threads) }} +
+ {{ render_threadlist(threads) }} +
{% endblock %} -- cgit v1.2.3