diff --git a/drama/__main__.py b/drama/__main__.py index a376df4d9..4f25b5422 100644 --- a/drama/__main__.py +++ b/drama/__main__.py @@ -260,9 +260,6 @@ def before_request(): g.db = db_session() - if g.db.query(IP).filter_by(addr=request.remote_addr).first(): - abort(503) - g.timestamp = int(time.time()) session.permanent = True diff --git a/drama/classes/__init__.py b/drama/classes/__init__.py index d833cadeb..e2482845c 100644 --- a/drama/classes/__init__.py +++ b/drama/classes/__init__.py @@ -4,7 +4,6 @@ from .boards import * from .board_relationships import * from .clients import * from .comment import * -from .custom_errors import * from .domains import Domain from .flags import * from .user import * @@ -16,5 +15,5 @@ from .domains import * from .subscriptions import * from .ips import * from .titles import * -from .award import * +from .lolwtf import * from .mod_logs import * \ No newline at end of file diff --git a/drama/classes/boards.py b/drama/classes/boards.py index 6945b243a..322a95c39 100644 --- a/drama/classes/boards.py +++ b/drama/classes/boards.py @@ -389,26 +389,4 @@ class Board(Base, Stndrd, Age_times): comments = comments.order_by(Comment.created_utc.desc()).offset( 25 * (page - 1)).limit(26).all() - return [x.id for x in comments] - - - def user_guild_rep(self, user): - - return user.guild_rep(self) - - def is_guildmaster(self, perm=None): - mod=self.__dict__.get('_is_guildmaster', False) - if not mod: - return False - if not perm: - return True - - return mod.__dict__[f"perm_{perm}"] - - - @property - def siege_rep_requirement(self): - - now=int(time.time()) - - return self.stored_subscriber_count//10 + min(180, (now-self.created_utc)//(60*60*24)) \ No newline at end of file + return [x.id for x in comments] \ No newline at end of file diff --git a/drama/classes/comment.py b/drama/classes/comment.py index b41585475..8f16e87d4 100644 --- a/drama/classes/comment.py +++ b/drama/classes/comment.py @@ -82,7 +82,7 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing): parent_comment = relationship("Comment", remote_side=[id]) child_comments = relationship("Comment", remote_side=[parent_comment_id]) - awards = relationship("AwardRelationship", lazy="joined") + #awards = relationship("AwardRelationship", lazy="joined") # These are virtual properties handled as postgres functions server-side # There is no difference to SQLAlchemy, but they cannot be written to @@ -266,7 +266,7 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing): 'score': self.score_fuzzed, 'upvotes': self.upvotes_fuzzed, 'downvotes': self.downvotes_fuzzed, - 'award_count': self.award_count, + #'award_count': self.award_count, 'is_bot': self.is_bot } @@ -345,10 +345,6 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing): x = 0 return x - @property - def title(self): - return self.__dict__.get("_title", self.author.title) - @property def is_blocking(self): return self.__dict__.get('_is_blocking', 0) @@ -395,9 +391,9 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing): def flag_count(self): return len(self.flags) - @property - def award_count(self): - return len(self.awards) + #@property + #def award_count(self): + #return len(self.awards) def collapse_for_user(self, v): @@ -458,18 +454,6 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing): return data - def is_guildmaster(self, perm=None): - mod=self.__dict__.get('_is_guildmaster', False) - - if not mod: - return False - elif not perm: - return True - else: - return mod.perm_full or mod.__dict__[f"perm_{perm}"] - - return output - @property def is_exiled_for(self): return self.__dict__.get('_is_exiled_for', None) diff --git a/drama/classes/custom_errors.py b/drama/classes/custom_errors.py deleted file mode 100644 index 55bf4d445..000000000 --- a/drama/classes/custom_errors.py +++ /dev/null @@ -1,5 +0,0 @@ -class PaymentRequired(Exception): - status_code=402 - def __init__(self): - Exception.__init__(self) - self.status_code=402 diff --git a/drama/classes/ips.py b/drama/classes/ips.py index c9655601f..fb0d0ad2e 100644 --- a/drama/classes/ips.py +++ b/drama/classes/ips.py @@ -1,18 +1,6 @@ from sqlalchemy import * from drama.__main__ import Base - -class IP(Base): - - __tablename__ = "ips" - - id = Column(Integer, primary_key=True) - addr = Column(String(64)) - reason = Column(String(256), default="") - banned_by = Column(Integer, ForeignKey("users.id"), default=True) - until_utc=Column(Integer, default=None) - - class Agent(Base): __tablename__ = "useragents" diff --git a/drama/classes/lolwtf.py b/drama/classes/lolwtf.py new file mode 100644 index 000000000..5e4a7a5ee --- /dev/null +++ b/drama/classes/lolwtf.py @@ -0,0 +1,2 @@ + +from drama.__main__ import Base, app \ No newline at end of file diff --git a/drama/classes/submission.py b/drama/classes/submission.py index 44ebd837e..42e12cec0 100644 --- a/drama/classes/submission.py +++ b/drama/classes/submission.py @@ -117,7 +117,7 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing): comment_count = Column(Integer, server_default=FetchedValue()) score = deferred(Column(Float, server_default=FetchedValue())) - awards = relationship("AwardRelationship", lazy="joined") + #awards = relationship("AwardRelationship", lazy="joined") rank_hot = deferred(Column(Float, server_default=FetchedValue())) rank_fiery = deferred(Column(Float, server_default=FetchedValue())) @@ -330,7 +330,7 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing): 'score': self.score_fuzzed, 'upvotes': self.upvotes_fuzzed, 'downvotes': self.downvotes_fuzzed, - 'award_count': self.award_count, + #'award_count': self.award_count, 'is_offensive': self.is_offensive, 'meta_title': self.meta_title, 'meta_description': self.meta_description, @@ -498,23 +498,6 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing): self.submission_aux.meta_description=x g.db.add(self.submission_aux) - - def is_guildmaster(self, perm=None): - mod=self.__dict__.get('_is_guildmaster', False) - - if not mod: - return False - elif not perm: - return True - else: - return mod.perm_full or mod.__dict__[f"perm_{perm}"] - - return output - - @property - def is_blocking_guild(self): - return self.__dict__.get('_is_blocking_guild', False) - @property def is_blocked(self): return self.__dict__.get('_is_blocked', False) @@ -523,10 +506,6 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing): def is_blocking(self): return self.__dict__.get('_is_blocking', False) - @property - def is_subscribed(self): - return self.__dict__.get('_is_subscribed', False) - @property def is_public(self): return self.post_public or not self.board.is_private @@ -539,9 +518,9 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing): def report_count(self): return len(self.reports) - @property - def award_count(self): - return len(self.awards) + #@property + #def award_count(self): + #return len(self.awards) @property def embed_template(self): diff --git a/drama/classes/user.py b/drama/classes/user.py index a7839d1c6..b0210f71a 100644 --- a/drama/classes/user.py +++ b/drama/classes/user.py @@ -38,7 +38,6 @@ class User(Base, Stndrd, Age_times): passhash = deferred(Column(String, default=None)) banawards = Column(Integer, default=0) created_utc = Column(Integer, default=0) - suicide_utc = Column(Integer, default=0) admin_level = Column(Integer, default=0) resized = Column(Boolean, default=True) agendaposter = Column(Boolean, default=False) @@ -89,7 +88,6 @@ class User(Base, Stndrd, Age_times): has_banner = Column(Boolean, default=False) reserved = Column(String(256), default=None) is_nsfw = Column(Boolean, default=False) - tos_agreed_utc = Column(Integer, default=0) profile_nonce = Column(Integer, default=0) banner_nonce = Column(Integer, default=0) last_siege_utc = Column(Integer, default=0) @@ -155,11 +153,6 @@ class User(Base, Stndrd, Age_times): lazy="dynamic", primaryjoin="User.id==SaveRelationship.user_id") - awards = relationship( - "AwardRelationship", - primaryjoin="User.id==AwardRelationship.user_id" - ) - # properties defined as SQL server-side functions referral_count = deferred(Column(Integer, server_default=FetchedValue())) follower_count = deferred(Column(Integer, server_default=FetchedValue())) @@ -201,11 +194,6 @@ class User(Base, Stndrd, Age_times): or_(and_(UserBlock.user_id == self.id, UserBlock.target_id == other.id), and_( UserBlock.user_id == other.id, UserBlock.target_id == self.id))).first() - def has_blocked_guild(self, board): - - return g.db.query(BoardBlock).filter_by( - user_id=self.id, board_id=board.id).first() - def validate_2fa(self, token): x = pyotp.TOTP(self.mfa_secret) @@ -388,7 +376,8 @@ class User(Base, Stndrd, Age_times): @property def formkey(self): - if "session_id" not in session: session["session_id"] = token_hex(16) + if "session_id" not in session: + session["session_id"] = token_hex(16) msg = f"{session['session_id']}+{self.id}+{self.login_nonce}" @@ -623,9 +612,6 @@ class User(Base, Stndrd, Age_times): pic = random.randint(1, 50) return f"/assets/images/defaultpictures/{pic}.png" - def has_award(self, kind): - return bool(len([x for x in self.awards if x.kind == kind])) - @property def profile_url(self): if self.has_profile and self.profileurl: @@ -784,8 +770,8 @@ class User(Base, Stndrd, Age_times): # Takes care of all functions needed for account reinstatement. - self.is_banned = 0 - self.unban_utc = 0 + self.is_banned = None + self.unban_utc = None g.db.add(self) @@ -885,6 +871,34 @@ class User(Base, Stndrd, Age_times): return [x[0] for x in comments.offset(25 * (page - 1)).limit(26).all()] + def guild_rep(self, guild, recent=0): + + posts = g.db.query(Submission.score).filter_by( + is_banned=False, + original_board_id=guild.id) + + if recent: + cutoff = int(time.time()) - 60 * 60 * 24 * recent + posts = posts.filter(Submission.created_utc > cutoff) + + posts = posts.all() + + post_rep = sum([x[0] for x in posts]) - len(list(sum([x[0] for x in posts]))) + + comments = g.db.query(Comment.score).filter_by( + is_banned=False, + original_board_id=guild.id) + + if recent: + cutoff = int(time.time()) - 60 * 60 * 24 * recent + comments = comments.filter(Comment.created_utc > cutoff) + + comments = comments.all() + + comment_rep = sum([x[0] for x in comments]) - len(list(sum([x[0] for x in comments]))) + + return int(post_rep + comment_rep) + @property def has_premium(self): @@ -1016,4 +1030,4 @@ class ViewerRelationship(Base): return f"{months}mo ago" else: years = int(months / 12) - return f"{years}yr ago" + return f"{years}yr ago" \ No newline at end of file diff --git a/drama/helpers/get.py b/drama/helpers/get.py index 0deffbf6d..7e816fe4b 100644 --- a/drama/helpers/get.py +++ b/drama/helpers/get.py @@ -46,6 +46,7 @@ def get_user(username, v=None, graceful=False): def get_account(base36id, v=None, graceful=False): + if isinstance(base36id, str): id = base36decode(base36id) else: id = base36id @@ -120,9 +121,7 @@ def get_post(pid, v=None, graceful=False, **kwargs): else: items = g.db.query( - Submission, - ).options( - joinedload(Submission.author).joinedload(User.title) + Submission ).filter(Submission.id == i).first() if not items and not graceful: @@ -133,7 +132,7 @@ def get_post(pid, v=None, graceful=False, **kwargs): return x -def get_posts(pids, sort="hot", v=None): +def get_posts(pids, v=None): if not pids: return [] @@ -166,20 +165,18 @@ def get_posts(pids, sort="hot", v=None): blocked, blocked.c.user_id == Submission.author_id, isouter=True - ) + ).all() output = [p[0] for p in query] for i in range(len(output)): output[i]._voted = query[i][1] or 0 output[i]._is_blocking = query[i][2] or 0 output[i]._is_blocked = query[i][3] or 0 - else: output = g.db.query( - Submission + Submission, ).filter(Submission.id.in_(pids) - ).order_by(Submission.id.desc()).all() - + ).all() return sorted(output, key=lambda x: pids.index(x.id)) @@ -200,8 +197,6 @@ def get_post_with_comments(pid, sort="top", v=None): votes.c.vote_type, blocking.c.id, blocked.c.id, - ).options( - joinedload(Comment.author) ) if v.admin_level >=4: comms=comms.options(joinedload(Comment.oauth_app)) @@ -252,8 +247,6 @@ def get_post_with_comments(pid, sort="top", v=None): else: comms = g.db.query( Comment - ).options( - joinedload(Comment.author).joinedload(User.title) ).filter( Comment.parent_submission == post.id ) @@ -300,13 +293,6 @@ def get_comment(cid, v=None, graceful=False, **kwargs): else: i = cid - exile = g.db.query(ModAction - ).options( - lazyload('*') - ).filter_by( - kind="exile_user" - ).subquery() - if v: blocking = v.blocking.subquery() blocked = v.blocked.subquery() @@ -314,20 +300,9 @@ def get_comment(cid, v=None, graceful=False, **kwargs): CommentVote.user_id == v.id, CommentVote.comment_id == i).subquery() - mod=g.db.query(ModRelationship - ).filter_by( - user_id=v.id, - accepted=True - ).subquery() - - items = g.db.query( Comment, vt.c.vote_type, - aliased(ModRelationship, alias=mod), - aliased(ModAction, alias=exile) - ).options( - joinedload(Comment.author).joinedload(User.title) ) if v.admin_level >=4: @@ -342,14 +317,6 @@ def get_comment(cid, v=None, graceful=False, **kwargs): ).join( Comment.post, isouter=True - ).join( - mod, - mod.c.board_id==Submission.board_id, - isouter=True - ).join( - exile, - and_(exile.c.target_comment_id==Comment.id, exile.c.board_id==Comment.original_board_id), - isouter=True ).first() if not items and not graceful: @@ -357,8 +324,6 @@ def get_comment(cid, v=None, graceful=False, **kwargs): x = items[0] x._voted = items[1] or 0 - x._is_guildmaster=items[2] or 0 - x._is_exiled_for=items[3] or 0 block = g.db.query(UserBlock).filter( or_( @@ -376,31 +341,21 @@ def get_comment(cid, v=None, graceful=False, **kwargs): x._is_blocked = block and block.target_id == v.id else: - q = g.db.query( + x = g.db.query( Comment, - aliased(ModAction, alias=exile) - ).options( - joinedload(Comment.author).joinedload(User.title) - ).join( - exile, - and_(exile.c.target_comment_id==Comment.id, exile.c.board_id==Comment.original_board_id), - isouter=True ).filter(Comment.id == i).first() - if not q and not graceful: + if not x and not graceful: abort(404) - x=q[0] - x._is_exiled_for=q[1] - return x -def get_comments(cids, v=None, sort="new", - load_parent=False, **kwargs): +def get_comments(cids, v=None, load_parent=False, **kwargs): - if not cids: return [] + if not cids: + return [] cids=tuple(cids) @@ -434,17 +389,26 @@ def get_comments(cids, v=None, sort="new", isouter=True ).filter( Comment.id.in_(cids) - ).order_by(Comment.id.desc()).all() + ) + output = [x[0] for x in query] - for i in range(len(output)): output[i]._voted = query[i][1].vote_type if query[i][1] else 0 + for i in range(len(output)): + output[i]._voted = query[i][1].vote_type if query[i][1] else 0 else: - output = g.db.query(Comment).options().filter(Comment.id.in_(cids)).order_by(Comment.id.desc()).all() + query = g.db.query( + Comment, + ).filter( + Comment.id.in_(cids) + ).all() + output=[x for x in query] - return sorted(output, key=lambda x: cids.index(x.id)) + output = sorted(output, key=lambda x: cids.index(x.id)) + + return output def get_board(bid, graceful=False): @@ -484,27 +448,6 @@ def get_domain(s): return doms[0] -def get_title(x): - - title = g.db.query(Title).filter_by(id=x).first() - - if not title: - abort(400) - - else: - return title - - -def get_mod(uid, bid): - - mod = g.db.query(ModRelationship).filter_by(board_id=bid, - user_id=uid, - accepted=True, - invite_rescinded=False).first() - - return mod - - def get_application(client_id, graceful=False): application = g.db.query(OauthApp).filter_by(client_id=client_id).first() @@ -541,57 +484,4 @@ def get_from_permalink(link, v=None): return get_comment(int(comment_id), v=v) else: - return get_post(int(post_id), v=v) - - -def get_from_fullname(fullname, v=None, graceful=False): - - parts = fullname.split('_') - - if len(parts) != 2: - if graceful: - return None - else: - abort(400) - - kind = parts[0] - b36 = parts[1] - - if kind == 't1': - return get_account(b36, v=v, graceful=graceful) - elif kind == 't2': - return get_post(b36, v=v, graceful=graceful) - elif kind == 't3': - return get_comment(b36, v=v, graceful=graceful) - elif kind == 't4': - return get_board(b36, graceful=graceful) - -def get_txn(paypal_id): - - txn= g.db.query(PayPalTxn).filter_by(paypal_id=paypal_id).first() - - if not txn: - abort(404) - - return txn - -def get_txid(txid): - - txn= g.db.query(PayPalTxn).filter_by(id=base36decode(txid)).first() - - if not txn: - abort(404) - elif txn.status==1: - abort(404) - - return txn - - -def get_promocode(code): - - code = code.replace('\\', '') - code = code.replace("_", "\_") - - code = g.db.query(PromoCode).filter(PromoCode.code.ilike(code)).first() - - return code \ No newline at end of file + return get_post(int(post_id), v=v) \ No newline at end of file diff --git a/drama/helpers/jinja2.py b/drama/helpers/jinja2.py index 7fdbba229..969a97d7a 100644 --- a/drama/helpers/jinja2.py +++ b/drama/helpers/jinja2.py @@ -47,37 +47,6 @@ def js_str_escape(s): return s -@app.template_filter("is_mod") -@cache.memoize(60) -def jinja_is_mod(uid, bid): - - return bool(get_mod(uid, bid)) - -@app.template_filter("coin_goal") -@cache.cached(timeout=600, key_prefix="premium_coin_goal") -def coin_goal(x): - - now = time.gmtime() - midnight_month_start = time.struct_time((now.tm_year, - now.tm_mon, - 1, - 0, - 0, - 0, - now.tm_wday, - now.tm_yday, - 0) - ) - cutoff = calendar.timegm(midnight_month_start) - - coins=g.db.query(func.sum(PayPalTxn.coin_count)).filter( - PayPalTxn.created_utc>cutoff, - PayPalTxn.status==3).all()[0][0] or 0 - - - return int(100*coins/1000) - - @app.template_filter("app_config") def app_config(x): return app.config.get(x) diff --git a/drama/helpers/wrappers.py b/drama/helpers/wrappers.py index 2b8801de0..3520b917e 100644 --- a/drama/helpers/wrappers.py +++ b/drama/helpers/wrappers.py @@ -221,110 +221,6 @@ def is_not_banned(f): wrapper.__name__ = f.__name__ return wrapper -# Require tos agreement - - -def tos_agreed(f): - - def wrapper(*args, **kwargs): - - v = kwargs['v'] - - cutoff = int(environ.get("tos_cutoff", 0)) - - if v.tos_agreed_utc > cutoff: - return f(*args, **kwargs) - else: - return redirect("/terms#agreebox") - - wrapper.__name__ = f.__name__ - return wrapper - -def premium_required(f): - - #decorator that enforces valid premium status - #use under auth_required or is_not_banned - - def wrapper(*args, **kwargs): - - v=kwargs["v"] - - if not v.has_premium: - abort(403) - - return f(*args, **kwargs) - - wrapper.__name__=f.__name__ - return wrapper - - -def no_negative_balance(s): - - def wrapper_maker(f): - - #decorator that enforces valid premium status - #use under auth_required or is_not_banned - - def wrapper(*args, **kwargs): - - v=kwargs["v"] - - if v.negative_balance_cents: - if s=="toast": - return jsonify({"error":"You can't do that while your account balance is negative. Visit your account settings to bring your balance up to zero."}), 402 - elif s=="html": - raise(PaymentRequired) - else: - raise(PaymentRequired) - - return f(*args, **kwargs) - - wrapper.__name__=f.__name__ - return wrapper - - return wrapper_maker - -def is_guildmaster(*perms): - # decorator that enforces guildmaster status and verifies permissions - # use under auth_required - def wrapper_maker(f): - - def wrapper(*args, **kwargs): - - v = kwargs["v"] - boardname = kwargs.get("boardname") - board_id = kwargs.get("bid") - bid=request.values.get("bid", request.values.get("board_id")) - - if boardname: - board = get_guild(boardname) - elif board_id: - board = get_board(board_id) - elif bid: - board = get_board(bid) - else: - return jsonify({"error": f"no guild specified"}), 400 - - m=board.has_mod(v) - if not m: - return jsonify({"error":f"You aren't a guildmaster of +{board.name}"}), 403 - - if perms: - for perm in perms: - if not m.__dict__.get(f"perm_{perm}") and not m.perm_full: - return jsonify({"error":f"Permission `{perm}` required"}), 403 - - - if v.is_banned and not v.unban_utc: - abort(403) - - return f(*args, board=board, **kwargs) - - wrapper.__name__ = f.__name__ - return wrapper - - return wrapper_maker - # this wrapper takes args and is a bit more complicated def admin_level_required(x): @@ -529,26 +425,4 @@ def api(*scopes, no_ban=False): wrapper.__name__ = f.__name__ return wrapper - return wrapper_maker - - -SANCTIONS=[ - "CU", #Cuba - "IR", #Iran - "KP", #North Korea - "SY", #Syria - "TR", #Turkey - "VE", #Venezuela -] - -def no_sanctions(f): - - def wrapper(*args, **kwargs): - - if request.headers.get("cf-ipcountry","") in SANCTIONS: - abort(451) - - return f(*args, **kwargs) - - wrapper.__name__=f.__name__ - return wrapper \ No newline at end of file + return wrapper_maker \ No newline at end of file diff --git a/drama/routes/boards.py b/drama/routes/boards.py index 7830e0f25..8b95a714b 100644 --- a/drama/routes/boards.py +++ b/drama/routes/boards.py @@ -9,7 +9,6 @@ valid_board_regex = re.compile("^[a-zA-Z0-9][a-zA-Z0-9_]{2,24}$") @app.route("/mod/distinguish_post//", methods=["POST"]) @app.route("/api/v1/distinguish_post//", methods=["POST"]) @auth_required -@is_guildmaster("content") @api("guildmaster") def mod_distinguish_post(bid, pid, board, v): @@ -41,7 +40,6 @@ def mod_distinguish_post(bid, pid, board, v): @app.route("/mod/invite_mod/", methods=["POST"]) @auth_required -@is_guildmaster("full") @validate_formkey def mod_invite_username(bid, board, v): @@ -99,7 +97,6 @@ def mod_invite_username(bid, board, v): @app.route("/mod//rescind/", methods=["POST"]) @auth_required -@is_guildmaster("full") @validate_formkey def mod_rescind_bid_username(bid, username, board, v): @@ -158,7 +155,6 @@ def mod_accept_board(bid, v): @app.route("/mod//step_down", methods=["POST"]) @auth_required -@is_guildmaster() @validate_formkey def mod_step_down(bid, board, v): @@ -184,7 +180,6 @@ def mod_step_down(bid, board, v): @app.route("/mod//remove/", methods=["POST"]) @auth_required -@is_guildmaster("full") @validate_formkey def mod_remove_username(bid, username, board, v): @@ -284,7 +279,6 @@ def mod_log_item(aid, v): @app.route("/mod/edit_perms", methods=["POST"]) @auth_required -@is_guildmaster("full") @validate_formkey def board_mod_perms_change(boardname, board, v): diff --git a/drama/routes/comments.py b/drama/routes/comments.py index b5d8220ef..199eb9a73 100644 --- a/drama/routes/comments.py +++ b/drama/routes/comments.py @@ -190,7 +190,6 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): comment._voted = c[1] or 0 comment._is_blocking = c[2] or 0 comment._is_blocked = c[3] or 0 - comment._is_guildmaster=top_comment._is_guildmaster comment._is_exiled_for=c[4] or 0 output.append(comment) else: @@ -247,8 +246,6 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): @app.route("/api/v1/comment", methods=["POST"]) @limiter.limit("6/minute") @is_not_banned -@no_negative_balance('toast') -@tos_agreed @validate_formkey @api("create") def api_comment(v): diff --git a/drama/routes/errors.py b/drama/routes/errors.py index dc9452eb6..b784ed453 100644 --- a/drama/routes/errors.py +++ b/drama/routes/errors.py @@ -2,12 +2,10 @@ import jinja2.exceptions from drama.helpers.wrappers import * from drama.helpers.session import * -from drama.classes.custom_errors import * from flask import * from urllib.parse import quote, urlencode import time -from drama.__main__ import app, r, cache, db_session -import gevent +from drama.__main__ import app # Errors @@ -27,14 +25,6 @@ def error_401(e): else: return redirect(output) -@app.errorhandler(PaymentRequired) -@auth_desired -@api() -def error_402(e, v): - return{"html": lambda: (render_template('errors/402.html', v=v), 402), - "api": lambda: (jsonify({"error": "402 Payment Required"}), 402) - } - @app.errorhandler(403) @auth_desired @api() diff --git a/drama/routes/front.py b/drama/routes/front.py index 5ea14e189..99afbdd14 100644 --- a/drama/routes/front.py +++ b/drama/routes/front.py @@ -211,7 +211,7 @@ def front_all(v): ids = ids[0:25] # check if ids exist - posts = get_posts(ids, sort=sort, v=v) + posts = get_posts(ids, v=v) if request.path == "/": return render_template("home.html", v=v, listing=posts, next_exists=next_exists, sort=sort, t=t, page=page) else: return jsonify({"data": [x.json for x in posts], "next_exists": next_exists}) @@ -313,7 +313,7 @@ def changelog(v): ids = ids[0:25] # check if ids exist - posts = get_posts(ids, sort=sort, v=v) + posts = get_posts(ids, v=v) return {'html': lambda: render_template("changelog.html", v=v, diff --git a/drama/routes/login.py b/drama/routes/login.py index 6b12792b8..8faedebe2 100644 --- a/drama/routes/login.py +++ b/drama/routes/login.py @@ -358,7 +358,6 @@ def sign_up_post(v): created_utc=int(time.time()), creation_ip=request.remote_addr, referred_by=ref_id or None, - tos_agreed_utc=int(time.time()), creation_region=request.headers.get("cf-ipcountry"), ban_evade = int(any([x.is_banned for x in g.db.query(User).filter(User.id.in_(tuple(session.get("history", [])))).all() if x])) ) diff --git a/drama/routes/posts.py b/drama/routes/posts.py index 95e15ae45..be124ff36 100644 --- a/drama/routes/posts.py +++ b/drama/routes/posts.py @@ -89,7 +89,6 @@ def publish(pid, v): @app.route("/submit", methods=["GET"]) @auth_required -@no_negative_balance("html") def submit_get(v): if v and v.is_banned and not v.unban_utc: return render_template("seized.html") @@ -143,7 +142,6 @@ def post_base36id(pid, anything=None, v=None): @app.route("/edit_post/", methods=["POST"]) @is_not_banned -@no_negative_balance("html") @validate_formkey def edit_post(pid, v): @@ -278,7 +276,6 @@ def edit_post(pid, v): @app.route("/submit/title", methods=['GET']) @limiter.limit("6/minute") @is_not_banned -@no_negative_balance("html") def get_post_title(v): url = request.args.get("url", None) @@ -458,8 +455,6 @@ def archiveorg(url): @app.route("/api/vue/submit", methods=["POST"]) @limiter.limit("6/minute") @is_not_banned -@no_negative_balance('html') -@tos_agreed @validate_formkey @api("create") def submit_post(v): diff --git a/drama/routes/settings.py b/drama/routes/settings.py index 5444d21a8..2ba2c3092 100644 --- a/drama/routes/settings.py +++ b/drama/routes/settings.py @@ -127,22 +127,6 @@ def settings_profile_post(v): - x = request.values.get("title_id", None) - if x: - x = int(x) - if x == 0: - v.title_id = None - updated = True - elif x > 0: - title = get_title(x) - if bool(eval(title.qualification_expr)): - v.title_id = title.id - updated = True - else: - return jsonify({"error": f"You don't meet the requirements for title `{title.text}`."}), 403 - else: - abort(400) - defaultsortingcomments = request.values.get("defaultsortingcomments") if defaultsortingcomments: if defaultsortingcomments in ["new", "old", "controversial", "top", "bottom", "random"]: diff --git a/drama/routes/users.py b/drama/routes/users.py index bef6ced03..491954f96 100644 --- a/drama/routes/users.py +++ b/drama/routes/users.py @@ -317,7 +317,7 @@ def u_username(username, v=None): for p in sticky: ids = [p.id] + ids - listing = get_posts(ids, v=v, sort="new") + listing = get_posts(ids, v=v) if u.unban_utc: unban = datetime.fromtimestamp(u.unban_utc).strftime('%c') @@ -516,7 +516,7 @@ def saved_posts(v, username): ids=ids[0:25] - listing = get_posts(ids, v=v, sort="new") + listing = get_posts(ids, v=v) return {'html': lambda: render_template("userpage.html", u=v, diff --git a/drama/routes/votes.py b/drama/routes/votes.py index 9eef957c1..f69d452d3 100644 --- a/drama/routes/votes.py +++ b/drama/routes/votes.py @@ -8,7 +8,6 @@ from .users import leaderboard @app.route("/api/v1/vote/post//", methods=["POST"]) @app.route("/api/vote/post//", methods=["POST"]) @is_not_banned -@no_negative_balance("toast") @api("vote") @validate_formkey def api_vote_post(post_id, x, v): @@ -63,7 +62,6 @@ def api_vote_post(post_id, x, v): @app.route("/api/v1/vote/comment//", methods=["POST"]) @app.route("/api/vote/comment//", methods=["POST"]) @is_not_banned -@no_negative_balance("toast") @api("vote") @validate_formkey def api_vote_comment(comment_id, x, v): diff --git a/drama/templates/errors/401.html b/drama/templates/errors/401.html index 184e59bc0..4b7c675a9 100644 --- a/drama/templates/errors/401.html +++ b/drama/templates/errors/401.html @@ -20,4 +20,4 @@ -{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/drama/templates/errors/402.html b/drama/templates/errors/402.html deleted file mode 100644 index b30072f4d..000000000 --- a/drama/templates/errors/402.html +++ /dev/null @@ -1,20 +0,0 @@ -{% extends "errors/default.html" %} - -{% block title %} -402 Payment Required -{% endblock %} - -{% block pagetype %}error-402{% endblock %} - -{% block content %} -
-
-
- -

402 Payment Required

-

You should NEVER SEE THIS PAGE. It's about Ruqqus microtransactions. But no one deleted it from the github thing so I assume it has to continue existing for a reason. If you do see this page, you did something wrong.

- -
-
-
-{% endblock %} diff --git a/drama/templates/errors/451.html b/drama/templates/errors/451.html index 5cf4a046f..95637755b 100644 --- a/drama/templates/errors/451.html +++ b/drama/templates/errors/451.html @@ -13,8 +13,8 @@

451 Unavailable For Legal Reasons

-



fool.

+



fool.

-{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/drama/templates/errors/503.html b/drama/templates/errors/503.html index dd53d05cd..d06954eee 100644 --- a/drama/templates/errors/503.html +++ b/drama/templates/errors/503.html @@ -123,4 +123,4 @@ - + \ No newline at end of file diff --git a/drama/templates/errors/patron.html b/drama/templates/errors/patron.html index faa434b1a..bdf323896 100644 --- a/drama/templates/errors/patron.html +++ b/drama/templates/errors/patron.html @@ -4,7 +4,7 @@ 403 Unauthorized {% endblock %} -{% block pagetype %}error-405{% endblock %} +{% block pagetype %}error-403{% endblock %} {% block content %}
diff --git a/drama/templates/flag_comment_modal.html b/drama/templates/flag_comment_modal.html index cbc18d81a..e8f946659 100644 --- a/drama/templates/flag_comment_modal.html +++ b/drama/templates/flag_comment_modal.html @@ -35,4 +35,4 @@
- + \ No newline at end of file diff --git a/drama/templates/flag_post_modal.html b/drama/templates/flag_post_modal.html index ba916b3a5..8a143491f 100644 --- a/drama/templates/flag_post_modal.html +++ b/drama/templates/flag_post_modal.html @@ -35,4 +35,4 @@ - + \ No newline at end of file diff --git a/drama/templates/submission.html b/drama/templates/submission.html index 117598175..7b0baedd1 100644 --- a/drama/templates/submission.html +++ b/drama/templates/submission.html @@ -150,7 +150,7 @@ {% endif %} - {% if v and (v.id==p.author_id or v.admin_level>=3 or p.is_guildmaster('content')) %} + {% if v and (v.id==p.author_id or v.admin_level>=3) %} {% if not p.board.over_18 %} {% endif %} @@ -361,7 +361,7 @@ {% endif %} {% endif %} - {% if v and (v.id==p.author_id or v.admin_level>=3 or p.is_guildmaster('content')) %} + {% if v and (v.id==p.author_id or v.admin_level>=3) %} {% if not p.board.over_18 %}
  • Toggle +18
  • diff --git a/drama/templates/submission_listing.html b/drama/templates/submission_listing.html index 968c66403..79c30e672 100644 --- a/drama/templates/submission_listing.html +++ b/drama/templates/submission_listing.html @@ -203,7 +203,7 @@ {% endif %} {% endif %} - {% if v and (v.id==p.author_id or v.admin_level>=3 or p.is_guildmaster('content')) %} + {% if v and (v.id==p.author_id or v.admin_level>=3) %}
  • Toggle +18
  • @@ -386,7 +386,7 @@ {% endif %} {% endif %} - {% if v and (v.id==p.author_id or v.admin_level>=3 or p.is_guildmaster('content')) %} + {% if v and (v.id==p.author_id or v.admin_level>=3) %} {% if not p.board.over_18 %} {% endif %}