forked from rDrama/rDrama
1
0
Fork 0
master
Aevann1 2021-12-11 05:07:51 +02:00
parent 4a881347ad
commit e8c0ce18a2
2 changed files with 17 additions and 1 deletions

View File

@ -56,7 +56,7 @@ class CommentVote(Base):
app_id = Column(Integer, ForeignKey("oauth_apps.id"))
real = Column(Boolean, default=True)
user = relationship("User", lazy="subquery", viewonly=True)
user = relationship("User", lazy="subquery")
comment = relationship("Comment", lazy="subquery", viewonly=True)
def __init__(self, *args, **kwargs):

View File

@ -21,6 +21,22 @@ SITE_NAME = environ.get("SITE_NAME", "").strip()
if SITE_NAME == 'PCM': cc = "splash mountain"
else: cc = "country club"
@app.get("/distribute/<cid>")
@admin_level_required(2)
def distribute(v, cid):
votes = g.db.query(CommentVote).filter_by(comment_id=cid)
autobetter = g.db.query(User).filter_by(id=AUTOBETTER_ID).first()
coinsperperson = int(autobetter.coins / votes.count())
for vote in votes:
u = vote.user
u.coins += coinsperperson
g.db.add(u)
autobetter.coins = 0
g.db.add(autobetter)
g.db.commit()
return str(coinsperperson)
@app.get("/marseys")
@auth_desired
def marseys(v):