mirror of
https://git.wownero.com/lza_menace/suchwow.git
synced 2024-08-15 01:03:19 +00:00
add improved user filtering and pagination
This commit is contained in:
parent
a16176cfd6
commit
998fdb730c
5 changed files with 13 additions and 9 deletions
|
@ -28,13 +28,17 @@ app.register_blueprint(leaderboard.bp)
|
||||||
def index():
|
def index():
|
||||||
itp = 20
|
itp = 20
|
||||||
page = request.args.get("page", 1)
|
page = request.args.get("page", 1)
|
||||||
|
submitter = request.args.get("submitter", None)
|
||||||
try:
|
try:
|
||||||
page = int(page)
|
page = int(page)
|
||||||
except:
|
except:
|
||||||
flash("Wow, wtf hackerman. Cool it.")
|
flash("Wow, wtf hackerman. Cool it.")
|
||||||
page = 1
|
page = 1
|
||||||
|
|
||||||
posts = Post.select().order_by(Post.timestamp.desc()).paginate(page, itp)
|
posts = Post.select().order_by(Post.timestamp.desc())
|
||||||
|
if submitter:
|
||||||
|
posts = posts.where(Post.submitter == submitter)
|
||||||
|
posts = posts.paginate(page, itp)
|
||||||
total_pages = Post.select().count() / itp
|
total_pages = Post.select().count() / itp
|
||||||
return render_template("index.html", posts=posts, page=page, total_pages=total_pages)
|
return render_template("index.html", posts=posts, page=page, total_pages=total_pages)
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
<td>{{ post.timestamp.strftime('%Y-%m-%d %H:%M') }}</td>
|
<td>{{ post.timestamp.strftime('%Y-%m-%d %H:%M') }}</td>
|
||||||
<td>{{ post.id }}</td>
|
<td>{{ post.id }}</td>
|
||||||
<td><a href="{{ url_for('post.read', id=post.id) }}">{{ post.title }}</a></td>
|
<td><a href="{{ url_for('post.read', id=post.id) }}">{{ post.title }}</a></td>
|
||||||
<td>{{ post.submitter }}</td>
|
<td><a href="/?submitter={{ post.submitter }}">{{ post.submitter }}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
@ -32,11 +32,11 @@
|
||||||
|
|
||||||
|
|
||||||
{% if page > 1 %}
|
{% if page > 1 %}
|
||||||
<a href="/?page={{ page - 1 }}" style="padding:1em;">Back</a>
|
<a href="{% if request.args.submitter %}/?submitter={{ request.args.submitter }}&{% else %}/?{% endif %}page={{ page - 1 }}" style="padding:1em;">Back</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if page < total_pages and total_pages > 0 %}
|
{% if page < total_pages and total_pages > 0 %}
|
||||||
<a href="/?page={{ page + 1 }}" style="padding:1em;">Next</a>
|
<a href="{% if request.args.submitter %}/?submitter={{ request.args.submitter }}&{% else %}/?{% endif %}page={{ page + 1 }}" style="padding:1em;">Next</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
|
@ -12,13 +12,13 @@
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Submitter</th>
|
<th>Submitter</th>
|
||||||
<th>Posts</th>
|
<th>Post Count</th>
|
||||||
<th>Amount</th>
|
<th>Amount</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for poster, data in posters.items() | sort(attribute='1.amount', reverse=True) %}
|
{% for poster, data in posters.items() | sort(attribute='1.amount', reverse=True) %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ poster }}</td>
|
<td><a href="/?submitter={{ poster }}">{{ poster }}</a></td>
|
||||||
<td>{% for post in data["posts"] %}<a href="{{ url_for('post.read', id=post.id) }}">{{ post }}</a>{{ "," if not loop.last }}{% endfor %}</td>
|
<td>{{ data["posts"] | length }}</td>
|
||||||
<td>{{ data["amount"] }} WOW</td>
|
<td>{{ data["amount"] }} WOW</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<!-- Post Info -->
|
<!-- Post Info -->
|
||||||
<h1>{{ post.title }}</h1>
|
<h1>{{ post.title }}</h1>
|
||||||
<p class="subtitle">{{ post.text }}</p>
|
<p class="subtitle">{{ post.text }}</p>
|
||||||
<p class="subtext">Submitted by <i><u>{{ post.submitter }}</u></i> at <i>{{ post.timestamp }}</i></p>
|
<p class="subtext">Submitted by <i><u><a href="/?submitter={{ post.submitter }}">{{ post.submitter }}</a></u></i> at <i>{{ post.timestamp }}</i></p>
|
||||||
<br>
|
<br>
|
||||||
<img src="{{ url_for('post.uploaded_file', filename=post.image_name) }}" width=600/ style="margin-bottom:1em;border-radius:4px;">
|
<img src="{{ url_for('post.uploaded_file', filename=post.image_name) }}" width=600/ style="margin-bottom:1em;border-radius:4px;">
|
||||||
<hr>
|
<hr>
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<td>{{ post[1].timestamp.strftime('%Y-%m-%d %H:%M') }}</td>
|
<td>{{ post[1].timestamp.strftime('%Y-%m-%d %H:%M') }}</td>
|
||||||
<td>{{ post[1].id }}</td>
|
<td>{{ post[1].id }}</td>
|
||||||
<td><a href="{{ url_for('post.read', id=post[1].id) }}">{{ post[1].title }}</a></td>
|
<td><a href="{{ url_for('post.read', id=post[1].id) }}">{{ post[1].title }}</a></td>
|
||||||
<td>{{ post[1].submitter }}</td>
|
<td><a href="/?submitter={{ post[1].submitter }}">{{ post[1].submitter }}</a></td>
|
||||||
<td>{{ post[0] }} WOW</td>
|
<td>{{ post[0] }} WOW</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
Loading…
Reference in a new issue