From 511b74998e907d633b7a3ee59214803a0f03cb11 Mon Sep 17 00:00:00 2001 From: lza_menace Date: Mon, 10 Aug 2020 15:58:39 -0700 Subject: [PATCH] adding top posts --- suchwow/routes/post.py | 13 +++++++++++++ suchwow/templates/index.html | 5 ++++- suchwow/templates/post/top.html | 24 ++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 suchwow/templates/post/top.html diff --git a/suchwow/routes/post.py b/suchwow/routes/post.py index e5dd803..6c8ddd5 100644 --- a/suchwow/routes/post.py +++ b/suchwow/routes/post.py @@ -10,6 +10,19 @@ from suchwow.utils.helpers import allowed_file bp = Blueprint("post", "post") +@bp.route("/posts/top") +def top(): + top_posts = {} + posts = Post.select() + for post in posts: + balance = float(wownero.Wallet().balances(post.account_index)[1]) + if balance > 0: + top_posts[post.id] = { + "post": post, + "balance": balance + } + return render_template("post/top.html", posts=top_posts) + @bp.route("/post/") def read(id): if Post.filter(id=id): diff --git a/suchwow/templates/index.html b/suchwow/templates/index.html index c86b057..7891cc5 100644 --- a/suchwow/templates/index.html +++ b/suchwow/templates/index.html @@ -5,7 +5,7 @@
-

{% block title %}Latest Submissions{% endblock %}

+

{% block title %}Latest Posts{% endblock %}

{% if posts %} @@ -28,6 +28,9 @@ Next {% endif %} +
+ +
{% endblock %} diff --git a/suchwow/templates/post/top.html b/suchwow/templates/post/top.html new file mode 100644 index 0000000..3957174 --- /dev/null +++ b/suchwow/templates/post/top.html @@ -0,0 +1,24 @@ +{% extends 'base.html' %} + +{% block content %} + +
+ +
+

{% block title %}Top Posts{% endblock %}

+
+ + {% if posts %} +
    + {% for post in posts | sort(attribute='balance') %} +
  • #{{ posts[post].post.id }} - {{ posts[post].post.title }} - {{ posts[post].post.submitter }} - {{ posts[post].balance }} WOW received
  • + {% endfor %} +
+ {% else %} +

No posts yet!

+ {% endif %} + + +
+ +{% endblock %}