forked from MarseyWorld/MarseyWorld
sdffsd
parent
8790e8e26e
commit
dc04798fc2
|
@ -16,48 +16,9 @@ from flask import *
|
|||
from files.__main__ import app, cache, limiter
|
||||
from .front import frontlist
|
||||
from files.helpers.discord import add_role
|
||||
from collections import Counter
|
||||
|
||||
SITE_NAME = environ.get("SITE_NAME", "").strip()
|
||||
|
||||
@app.get("/@<username>/upvoters")
|
||||
@admin_level_required(6)
|
||||
def upvoters(v, username):
|
||||
id = g.db.query(User.id).filter(User.username==username).first()[0]
|
||||
|
||||
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()).limit(25).all()
|
||||
|
||||
votes2 = g.db.query(CommentVote.user_id, func.count(CommentVote.user_id)).join(Comment, CommentVote.comment_id==Comment.id).filter(CommentVote.vote_type==1, Comment.author_id==id).group_by(CommentVote.user_id).order_by(func.count(CommentVote.user_id).desc()).limit(25).all()
|
||||
|
||||
votes = Counter(dict(votes)) + Counter(dict(votes2))
|
||||
|
||||
users = g.db.query(User).filter(User.id.in_(votes.keys())).all()
|
||||
users2 = []
|
||||
for user in users: users2.append((user, votes[user.id]))
|
||||
|
||||
users = sorted(users2, key=lambda x: x[1], reverse=True)
|
||||
|
||||
return render_template("upvoters.html", v=v, users=users, username=username, name='Up', name2='simps')
|
||||
|
||||
@app.get("/@<username>/downvoters")
|
||||
@admin_level_required(6)
|
||||
def downvoters(v, username):
|
||||
id = g.db.query(User.id).filter(User.username==username).first()[0]
|
||||
|
||||
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()).limit(25).all()
|
||||
|
||||
votes2 = g.db.query(CommentVote.user_id, func.count(CommentVote.user_id)).join(Comment, CommentVote.comment_id==Comment.id).filter(CommentVote.vote_type==-1, Comment.author_id==id).group_by(CommentVote.user_id).order_by(func.count(CommentVote.user_id).desc()).limit(25).all()
|
||||
|
||||
votes = Counter(dict(votes)) + Counter(dict(votes2))
|
||||
|
||||
users = g.db.query(User).filter(User.id.in_(votes.keys())).all()
|
||||
users2 = []
|
||||
for user in users: users2.append((user, votes[user.id]))
|
||||
|
||||
users = sorted(users2, key=lambda x: x[1], reverse=True)
|
||||
|
||||
return render_template("upvoters.html", v=v, users=users, username=username, name='Down', name2='haters')
|
||||
|
||||
|
||||
@app.get("/name/<id>/<name>")
|
||||
@admin_level_required(6)
|
||||
|
@ -71,7 +32,6 @@ def changename(v, id, name):
|
|||
return "Username changed!"
|
||||
return "User not found!"
|
||||
|
||||
|
||||
@app.get("/coins/<id>/<coins>")
|
||||
@admin_level_required(6)
|
||||
def addcoins(v, id, coins):
|
||||
|
|
|
@ -11,13 +11,49 @@ from files.mail import *
|
|||
from flask import *
|
||||
from files.__main__ import app, limiter
|
||||
from pusher_push_notifications import PushNotifications
|
||||
from collections import Counter
|
||||
|
||||
site = environ.get("DOMAIN").strip()
|
||||
|
||||
beams_client = PushNotifications(
|
||||
instance_id=PUSHER_INSTANCE_ID,
|
||||
secret_key=PUSHER_KEY,
|
||||
)
|
||||
beams_client = PushNotifications(instance_id=PUSHER_INSTANCE_ID, secret_key=PUSHER_KEY)
|
||||
|
||||
@app.get("/@<username>/upvoters")
|
||||
@auth_desired
|
||||
def upvoters(v, username):
|
||||
id = g.db.query(User.id).filter(User.username==username).first()[0]
|
||||
|
||||
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()).limit(25).all()
|
||||
|
||||
votes2 = g.db.query(CommentVote.user_id, func.count(CommentVote.user_id)).join(Comment, CommentVote.comment_id==Comment.id).filter(CommentVote.vote_type==1, Comment.author_id==id).group_by(CommentVote.user_id).order_by(func.count(CommentVote.user_id).desc()).limit(25).all()
|
||||
|
||||
votes = Counter(dict(votes)) + Counter(dict(votes2))
|
||||
|
||||
users = g.db.query(User).filter(User.id.in_(votes.keys())).all()
|
||||
users2 = []
|
||||
for user in users: users2.append((user, votes[user.id]))
|
||||
|
||||
users = sorted(users2, key=lambda x: x[1], reverse=True)
|
||||
|
||||
return render_template("upvoters.html", v=v, users=users, username=username, name='Up', name2='simps')
|
||||
|
||||
@app.get("/@<username>/downvoters")
|
||||
@auth_desired
|
||||
def downvoters(v, username):
|
||||
id = g.db.query(User.id).filter(User.username==username).first()[0]
|
||||
|
||||
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()).limit(25).all()
|
||||
|
||||
votes2 = g.db.query(CommentVote.user_id, func.count(CommentVote.user_id)).join(Comment, CommentVote.comment_id==Comment.id).filter(CommentVote.vote_type==-1, Comment.author_id==id).group_by(CommentVote.user_id).order_by(func.count(CommentVote.user_id).desc()).limit(25).all()
|
||||
|
||||
votes = Counter(dict(votes)) + Counter(dict(votes2))
|
||||
|
||||
users = g.db.query(User).filter(User.id.in_(votes.keys())).all()
|
||||
users2 = []
|
||||
for user in users: users2.append((user, votes[user.id]))
|
||||
|
||||
users = sorted(users2, key=lambda x: x[1], reverse=True)
|
||||
|
||||
return render_template("upvoters.html", v=v, users=users, username=username, name='Down', name2='haters')
|
||||
|
||||
@app.post("/pay_rent")
|
||||
@limiter.limit("1/second")
|
||||
|
|
Loading…
Reference in New Issue