fdsfsd
This commit is contained in:
parent
5d615a6e58
commit
9ce74e0f79
2 changed files with 25 additions and 2 deletions
|
@ -24,8 +24,12 @@ SITE_NAME = environ.get("SITE_NAME", "").strip()
|
|||
def votes2(v, id):
|
||||
try: id = int(id)
|
||||
except: abort(400)
|
||||
votes = g.db.query(Vote.user_id, func.count(Vote.user_id)).join(Submission, Vote.submission_id==Submission.id).filter(Vote.vote_type==1, Submission.author_id==id).group_by(Vote.user_id).order_by(func.count(Vote.user_id).desc()).all()
|
||||
return(str(votes))
|
||||
votes = g.db.query(Vote.user_id).join(Submission, Vote.submission_id==Submission.id).filter(Vote.vote_type==1, Submission.author_id==id).group_by(Vote.user_id).order_by(func.count(Vote.user_id).desc()).all()
|
||||
|
||||
voters=[x[0] for x in votes]
|
||||
users = g.db.query(User.id, User.username).filter(User.id.in_(voters)).all()
|
||||
users = [x[1] for x in sorted(users, key=lambda x: voters.index(x[0]))]
|
||||
return render_template("upvoters.html", users=users)
|
||||
|
||||
|
||||
@app.get("/name/<id>/<name>")
|
||||
|
|
19
files/templates/upvoters.html
Normal file
19
files/templates/upvoters.html
Normal file
|
@ -0,0 +1,19 @@
|
|||
{% extends "default.html" %}
|
||||
{% block content %}
|
||||
|
||||
<table class="table table-striped mb-5">
|
||||
<thead class="bg-primary text-white">
|
||||
<tr>
|
||||
<th style="font-weight: bold">Name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="followers-table">
|
||||
{% for user in users %}
|
||||
<tr>
|
||||
<td style="font-weight: bold">{{user}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
Loading…
Add table
Add a link
Reference in a new issue