forked from rDrama/rDrama
Merge branch 'master' into mistletoe
commit
b4940f8b96
|
@ -7,7 +7,7 @@ from sqlalchemy import *
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
from files.__main__ import Base
|
from files.__main__ import Base
|
||||||
from files.classes.votes import CommentVote
|
from files.classes.votes import CommentVote
|
||||||
from files.helpers.const import AUTOPOLLER_ID, censor_slurs
|
from files.helpers.const import AUTOPOLLER_ID, AUTOBETTER_ID, censor_slurs
|
||||||
from files.helpers.lazy import lazy
|
from files.helpers.lazy import lazy
|
||||||
from .flags import CommentFlag
|
from .flags import CommentFlag
|
||||||
from random import randint
|
from random import randint
|
||||||
|
@ -187,7 +187,7 @@ class Comment(Base):
|
||||||
def replies(self):
|
def replies(self):
|
||||||
r = self.__dict__.get("replies", None)
|
r = self.__dict__.get("replies", None)
|
||||||
if r: r = [x for x in r if not x.author.shadowbanned]
|
if r: r = [x for x in r if not x.author.shadowbanned]
|
||||||
if not r and r != []: r = sorted([x for x in self.child_comments if not x.author.shadowbanned and x.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID))], key=lambda x: x.score, reverse=True)
|
if not r and r != []: r = sorted([x for x in self.child_comments if not x.author.shadowbanned and x.author_id not in (AUTOPOLLER_ID, AUTOBETTER_ID)], key=lambda x: x.score, reverse=True)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
@replies.setter
|
@replies.setter
|
||||||
|
@ -205,7 +205,7 @@ class Comment(Base):
|
||||||
@property
|
@property
|
||||||
def replies3(self):
|
def replies3(self):
|
||||||
r = self.__dict__.get("replies", None)
|
r = self.__dict__.get("replies", None)
|
||||||
if not r and r != []: r = sorted([x for x in self.child_comments if x.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID))], key=lambda x: x.score, reverse=True)
|
if not r and r != []: r = sorted([x for x in self.child_comments if x.author_id not in (AUTOPOLLER_ID, AUTOBETTER_ID)], key=lambda x: x.score, reverse=True)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -87,11 +87,11 @@ class Submission(Base):
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def bet_options(self):
|
def bet_options(self):
|
||||||
return g.db.query(Comment).filter_by(parent_submission = self.id, author_id = AUTOBETTER_ID, level=1).order_by(Comment.upvotes.desc())
|
return g.db.query(Comment).filter_by(parent_submission = self.id, author_id = AUTOBETTER_ID, level=1)
|
||||||
|
|
||||||
def total_poll_voted(self, v):
|
def total_poll_voted(self, v):
|
||||||
if v:
|
if v:
|
||||||
for option in self.options + self.bet_options:
|
for option in self.options:
|
||||||
if option.poll_voted(v): return True
|
if option.poll_voted(v): return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ class CommentVote(Base):
|
||||||
app_id = Column(Integer, ForeignKey("oauth_apps.id"))
|
app_id = Column(Integer, ForeignKey("oauth_apps.id"))
|
||||||
real = Column(Boolean, default=True)
|
real = Column(Boolean, default=True)
|
||||||
|
|
||||||
user = relationship("User", lazy="subquery", viewonly=True)
|
user = relationship("User", lazy="subquery")
|
||||||
comment = relationship("Comment", lazy="subquery", viewonly=True)
|
comment = relationship("Comment", lazy="subquery", viewonly=True)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
|
|
@ -21,6 +21,24 @@ SITE_NAME = environ.get("SITE_NAME", "").strip()
|
||||||
if SITE_NAME == 'PCM': cc = "splash mountain"
|
if SITE_NAME == 'PCM': cc = "splash mountain"
|
||||||
else: cc = "country club"
|
else: cc = "country club"
|
||||||
|
|
||||||
|
@app.get("/distribute/<cid>")
|
||||||
|
@admin_level_required(2)
|
||||||
|
def distribute(v, cid):
|
||||||
|
try: int(cid)
|
||||||
|
except: abort(400)
|
||||||
|
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")
|
@app.get("/marseys")
|
||||||
@auth_desired
|
@auth_desired
|
||||||
def marseys(v):
|
def marseys(v):
|
||||||
|
|
Loading…
Reference in New Issue