mirror of
https://git.wownero.com/lza_menace/suchwow.git
synced 2024-08-15 01:03:19 +00:00
adding top posts
This commit is contained in:
parent
75613c4202
commit
511b74998e
3 changed files with 41 additions and 1 deletions
|
@ -10,6 +10,19 @@ from suchwow.utils.helpers import allowed_file
|
||||||
|
|
||||||
bp = Blueprint("post", "post")
|
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>")
|
@bp.route("/post/<id>")
|
||||||
def read(id):
|
def read(id):
|
||||||
if Post.filter(id=id):
|
if Post.filter(id=id):
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<div class="container" style="text-align:center;">
|
<div class="container" style="text-align:center;">
|
||||||
|
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<h3>{% block title %}Latest Submissions{% endblock %}</h3>
|
<h3>{% block title %}Latest Posts{% endblock %}</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if posts %}
|
{% if posts %}
|
||||||
|
@ -28,6 +28,9 @@
|
||||||
<a href="/?page={{ page + 1 }}" style="padding:1em;">Next</a>
|
<a href="/?page={{ page + 1 }}" style="padding:1em;">Next</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<a href="{{ url_for('post.top') }}"><button class="btn btn-warning">See Top Posts</button></a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
24
suchwow/templates/post/top.html
Normal file
24
suchwow/templates/post/top.html
Normal file
|
@ -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…
Reference in a new issue