adding top posts

graphs-n-shit
lza_menace 4 years ago
parent 75613c4202
commit 511b74998e

@ -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/<id>")
def read(id):
if Post.filter(id=id):

@ -5,7 +5,7 @@
<div class="container" style="text-align:center;">
<div class="title">
<h3>{% block title %}Latest Submissions{% endblock %}</h3>
<h3>{% block title %}Latest Posts{% endblock %}</h3>
</div>
{% if posts %}
@ -28,6 +28,9 @@
<a href="/?page={{ page + 1 }}" style="padding:1em;">Next</a>
{% endif %}
<hr>
<a href="{{ url_for('post.top') }}"><button class="btn btn-warning">See Top Posts</button></a>
</div>
{% endblock %}

@ -0,0 +1,24 @@
{% extends 'base.html' %}
{% block content %}
<div class="container" style="text-align:center;">
<div class="title">
<h3>{% block title %}Top Posts{% endblock %}</h3>
</div>
{% if posts %}
<ul style="list-style-type:none;">
{% for post in posts | sort(attribute='balance') %}
<li>#{{ posts[post].post.id }} - <a href="{{ url_for('post.read', id=posts[post].post.id) }}">{{ posts[post].post.title }}</a> - {{ posts[post].post.submitter }} - {{ posts[post].balance }} WOW received</li>
{% endfor %}
</ul>
{% else %}
<p>No posts yet!</p>
{% endif %}
</div>
{% endblock %}
Loading…
Cancel
Save