diff --git a/drama/__main__.py b/drama/__main__.py index 4f25b5422a..8467e3adf2 100644 --- a/drama/__main__.py +++ b/drama/__main__.py @@ -24,9 +24,6 @@ from redis import ConnectionPool from werkzeug.middleware.proxy_fix import ProxyFix - -_version = "2.37.4" - app = Flask(__name__, template_folder='./templates', static_folder='./static' @@ -56,7 +53,7 @@ app.config["SERVER_NAME"] = environ.get("domain", environ.get("SERVER_NAME", "") app.config["SHORT_DOMAIN"]=environ.get("SHORT_DOMAIN","").strip() app.config["SESSION_COOKIE_NAME"] = "session_drama" -app.config["VERSION"] = _version +app.config["VERSION"] = "1.0.0" app.config['MAX_CONTENT_LENGTH'] = 64 * 1024 * 1024 app.config["SESSION_COOKIE_SECURE"] = bool(int(environ.get("FORCE_HTTPS", 1))) app.config["SESSION_COOKIE_SAMESITE"] = "Lax" @@ -69,7 +66,7 @@ app.config["DISABLE_SIGNUPS"]=int(environ.get("DISABLE_SIGNUPS",0)) app.jinja_env.cache = {} -app.config["UserAgent"] = f"Content Aquisition for Pink message board v{_version}." +app.config["UserAgent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36" if "localhost" in app.config["SERVER_NAME"]: app.config["CACHE_TYPE"] = "null" diff --git a/drama/classes/__init__.py b/drama/classes/__init__.py index e2482845c6..e0cd59c2ce 100644 --- a/drama/classes/__init__.py +++ b/drama/classes/__init__.py @@ -1,7 +1,5 @@ from .alts import * from .badges import * -from .boards import * -from .board_relationships import * from .clients import * from .comment import * from .domains import Domain diff --git a/drama/classes/award.py b/drama/classes/award.py index 40e93c4bbb..dfe3b5ec24 100644 --- a/drama/classes/award.py +++ b/drama/classes/award.py @@ -28,8 +28,8 @@ class AwardRelationship(Base): id = Column(Integer, primary_key=True) user_id = Column(Integer, ForeignKey("users.id")) - submission_id = Column(Integer, ForeignKey("submissions.id"), default=None) - comment_id = Column(Integer, ForeignKey("comments.id"), default=None) + submission_id = Column(Integer, ForeignKey("submissions.id")) + comment_id = Column(Integer, ForeignKey("comments.id")) kind = Column(String(20)) user = relationship("User", primaryjoin="AwardRelationship.user_id==User.id", lazy="joined") diff --git a/drama/classes/badges.py b/drama/classes/badges.py index 6936760611..89db377514 100644 --- a/drama/classes/badges.py +++ b/drama/classes/badges.py @@ -15,7 +15,7 @@ class BadgeDef(Base): icon = Column(String(64)) kind = Column(Integer, default=1) rank = Column(Integer, default=1) - qualification_expr = Column(String(128), default=None) + qualification_expr = Column(String(128)) def __repr__(self): diff --git a/drama/classes/board_relationships.py b/drama/classes/board_relationships.py deleted file mode 100644 index 56059b6d76..0000000000 --- a/drama/classes/board_relationships.py +++ /dev/null @@ -1,198 +0,0 @@ -from sqlalchemy import * -from sqlalchemy.orm import relationship -from drama.__main__ import Base, cache -from .mix_ins import * -import time - - -class ModRelationship(Base, Age_times): - __tablename__ = "mods" - id = Column(BigInteger, primary_key=True) - user_id = Column(Integer, ForeignKey("users.id")) - board_id = Column(Integer, ForeignKey("boards.id")) - created_utc = Column(Integer, default=0) - accepted = Column(Boolean, default=False) - invite_rescinded = Column(Boolean, default=False) - - perm_content = Column(Boolean, default=False) - perm_appearance = Column(Boolean, default=False) - perm_config = Column(Boolean, default=False) - perm_access = Column(Boolean, default=False) - perm_full = Column(Boolean, default=False) - #permRules = Column(Boolean, default=False) - #permTitles = Column(Boolean, default=False) - #permLodges = Column(Boolean, default=False) - - user = relationship("User", lazy="joined") - board = relationship("Board", lazy="joined") - - def __init__(self, *args, **kwargs): - if "created_utc" not in kwargs: - kwargs["created_utc"] = int(time.time()) - - super().__init__(*args, **kwargs) - - def __repr__(self): - return f"" - - @property - def permlist(self): - if self.perm_full: - return "full" - - output=[] - for p in ["access","appearance", "config","content"]: - if self.__dict__[f"perm_{p}"]: - output.append(p) - - - return ", ".join(output) if output else "none" - - @property - def permchangelist(self): - output=[] - for p in ["full", "access","appearance", "config","content"]: - if self.__dict__.get(f"perm_{p}"): - output.append(f"+{p}") - else: - output.append(f"-{p}") - - return ", ".join(output) - - - @property - def json_core(self): - return { - 'user_id':self.user_id, - 'board_id':self.board_id, - 'created_utc':self.created_utc, - 'accepted':self.accepted, - 'invite_rescinded':self.invite_rescinded, - 'perm_content':self.perm_full or self.perm_content, - 'perm_config':self.perm_full or self.perm_config, - 'perm_access':self.perm_full or self.perm_access, - 'perm_appearance':self.perm_full or self.perm_appearance, - 'perm_full':self.perm_full, - } - - - @property - def json(self): - data=self.json_core - - data["user"]=self.user.json_core - #data["guild"]=self.board.json_core - - return data - - - - -class BanRelationship(Base, Stndrd, Age_times): - - __tablename__ = "bans" - id = Column(BigInteger, primary_key=True) - user_id = Column(Integer, ForeignKey("users.id")) - board_id = Column(Integer, ForeignKey("boards.id")) - created_utc = Column(BigInteger, default=0) - banning_mod_id = Column(Integer, ForeignKey("users.id")) - is_active = Column(Boolean, default=False) - mod_note = Column(String(128), default="") - - user = relationship( - "User", - lazy="joined", - primaryjoin="User.id==BanRelationship.user_id") - banning_mod = relationship( - "User", - lazy="joined", - primaryjoin="User.id==BanRelationship.banning_mod_id") - board = relationship("Board") - - def __init__(self, *args, **kwargs): - if "created_utc" not in kwargs: - kwargs["created_utc"] = int(time.time()) - - super().__init__(*args, **kwargs) - - def __repr__(self): - return f"" - - @property - def json_core(self): - return { - 'user_id':self.user_id, - 'board_id':self.board_id, - 'created_utc':self.created_utc, - 'mod_id':self.banning_mod_id - } - - - @property - def json(self): - data=self.json_core - - data["user"]=self.user.json_core - data["mod"]=self.banning_mod.json_core - data["guild"]=self.board.json_core - - return data - -class ContributorRelationship(Base, Stndrd, Age_times): - - __tablename__ = "contributors" - id = Column(BigInteger, primary_key=True) - user_id = Column(Integer, ForeignKey("users.id")) - board_id = Column(Integer, ForeignKey("boards.id")) - created_utc = Column(BigInteger, default=0) - is_active = Column(Boolean, default=True) - approving_mod_id = Column(Integer, ForeignKey("users.id")) - - user = relationship( - "User", - lazy="joined", - primaryjoin="User.id==ContributorRelationship.user_id") - approving_mod = relationship( - "User", - lazy='joined', - primaryjoin="User.id==ContributorRelationship.approving_mod_id") - board = relationship("Board", lazy="subquery") - - def __init__(self, *args, **kwargs): - if "created_utc" not in kwargs: - kwargs["created_utc"] = int(time.time()) - - super().__init__(*args, **kwargs) - - def __repr__(self): - return f"" - - -class PostRelationship(Base): - - __tablename__ = "postrels" - id = Column(BigInteger, primary_key=True) - post_id = Column(Integer, ForeignKey("submissions.id")) - board_id = Column(Integer, ForeignKey("boards.id")) - - post = relationship("Submission", lazy="subquery") - board = relationship("Board", lazy="subquery") - - def __repr__(self): - return f"" - - -class BoardBlock(Base, Stndrd, Age_times): - - __tablename__ = "boardblocks" - - id = Column(BigInteger, primary_key=True) - user_id = Column(Integer, ForeignKey("users.id")) - board_id = Column(Integer, ForeignKey("boards.id")) - created_utc = Column(Integer) - - user = relationship("User") - board = relationship("Board") - - def __repr__(self): - return f"" diff --git a/drama/classes/boards.py b/drama/classes/boards.py deleted file mode 100644 index fe7595eff4..0000000000 --- a/drama/classes/boards.py +++ /dev/null @@ -1,391 +0,0 @@ -from sqlalchemy.orm import lazyload -from .userblock import * -from .submission import * -from .board_relationships import * -from .comment import Comment -from .mix_ins import * -from drama.__main__ import Base, cache - - -class Board(Base, Stndrd, Age_times): - - __tablename__ = "boards" - - id = Column(Integer, primary_key=True) - name = Column(String) - created_utc = Column(Integer) - description = Column(String) - - description_html=Column(String) - over_18=Column(Boolean, default=False) - is_nsfl=Column(Boolean, default=False) - is_banned=Column(Boolean, default=False) - disablesignups=Column(Boolean, default=False) - has_banner=Column(Boolean, default=False) - creator_id=Column(Integer, ForeignKey("users.id")) - ban_reason=Column(String(256), default=None) - color=Column(String(8), default="FF66AC") - restricted_posting=Column(Boolean, default=False) - hide_banner_data=Column(Boolean, default=False) - profile_nonce=Column(Integer, default=0) - banner_nonce=Column(Integer, default=0) - is_private=Column(Boolean, default=False) - color_nonce=Column(Integer, default=0) - rank_trending=Column(Float, default=0) - stored_subscriber_count=Column(Integer, default=1) - all_opt_out=Column(Boolean, default=False) - is_siegable=Column(Boolean, default=True) - secondary_color=Column(String(6), default="cfcfcf") - motd = Column(String(1000), default='') - - moderators=relationship("ModRelationship") - submissions=relationship("Submission", primaryjoin="Board.id==Submission.board_id") - contributors=relationship("ContributorRelationship", lazy="dynamic") - bans=relationship("BanRelationship", lazy="dynamic") - postrels=relationship("PostRelationship", lazy="dynamic") - trending_rank=deferred(Column(Float, server_default=FetchedValue())) - - # db side functions - subscriber_count = deferred(Column(Integer, server_default=FetchedValue())) - - def __init__(self, **kwargs): - - kwargs["created_utc"] = int(time.time()) - - super().__init__(**kwargs) - - def __repr__(self): - return f"" - - @property - def fullname(self): - return f"t4_{self.base36id}" - - @property - def mods_list(self): - - z = [x for x in self.moderators if x.accepted and not ( - x.user.is_deleted or (x.user.is_banned and not x.user.unban_utc))] - - z = sorted(z, key=lambda x: x.created_utc) - return z - - @property - def mods(self): - - z = [x for x in self.moderators if x.accepted] - - z = sorted(z, key=lambda x: x.created_utc) - - z = [x.user for x in z] - - return z - - @property - def invited_mods(self): - - z = [x.user for x in self.moderators if x.accepted == - False and x.invite_rescinded == False] - z = sorted(z, key=lambda x: x.created_utc) - return z - - @property - def mod_invites(self): - z = [x for x in self.moderators if x.accepted == - False and x.invite_rescinded == False] - z = sorted(z, key=lambda x: x.created_utc) - return z - - @property - def mods_count(self): - - return len(self.mods_list) - - @property - def permalink(self): - - return f"/+{self.name}" - - def can_take(self, post): - if self.is_banned: - return False - return not self.postrels.filter_by(post_id=post.id).first() - - def has_mod(self, user, perm=None): - - if user is None: - return None - - if self.is_banned: - return False - - m=self.__dict__.get("_mod") - if not m: - for x in user.moderates: - if x.board_id == self.id and x.accepted and not x.invite_rescinded: - self.__dict__["mod"]=x - m=x - - if not m: - return False - - if perm: - - return m if (m.perm_full or m.__dict__[f"perm_{perm}"]) else False - - else: - return m - - - return False - - def has_mod_record(self, user, perm=None): - - if user is None: - return None - - if self.is_banned: - return False - - for x in user.moderates: - if x.board_id == self.id and not x.invite_rescinded: - - if perm: - return x if x.__dict__[f"perm_{perm}"] else False - else: - return x - - - return False - def can_invite_mod(self, user): - - return user.id not in [ - x.user_id for x in self.moderators if not x.invite_rescinded] - - def has_rescinded_invite(self, user): - - return user.id in [ - x.user_id for x in self.moderators if x.invite_rescinded == True] - - def has_invite(self, user): - - if user is None: - return None - - for x in [ - i for i in self.moderators if not i.invite_rescinded and not i.accepted]: - - if x.user_id == user.id: - return x - - return None - - def has_ban(self, user): - - if user is None: - return None - - if user.admin_level >=2: - return None - - return g.db.query(BanRelationship).filter_by( - board_id=self.id, user_id=user.id, is_active=True).first() - - def has_contributor(self, user): - - if user is None: - return False - - return g.db.query(ContributorRelationship).filter_by( - user_id=user.id, board_id=self.id, is_active=True).first() - - def can_submit(self, user): - - if user is None: - return False - - if user.admin_level >= 4: - return True - - if self.has_ban(user): - return False - - if self.has_contributor(user) or self.has_mod(user): - return True - - if self.is_private or self.restricted_posting: - return False - - return True - - def can_comment(self, user): - - if user is None: - return False - - if user.admin_level >= 4: - return True - - if self.has_ban(user): - return False - - if self.has_contributor(user) or self.has_mod(user): - return True - - if self.is_private: - return False - - return True - - def can_view(self, user): - - if user is None: - return False - - if user.admin_level >= 4: - return True - - if self.has_contributor(user) or self.has_mod( - user) or self.has_invite(user): - return True - - if self.is_private: - return False - - @property - def banner_url(self): - return "/assets/images/preview.png" - - @property - def profile_url(self): - return "/assets/images/favicon.png" - - @property - def css_url(self): - return f"/assets/{self.fullname}/main/{self.color_nonce}.css" - - @property - def css_dark_url(self): - return f"/assets/{self.fullname}/dark/{self.color_nonce}.css" - - def has_participant(self, user): - return (g.db.query(Submission).filter_by(original_board_id=self.id, author_id=user.id).first() or - g.db.query(Comment).filter_by( - author_id=user.id, original_board_id=self.id).first() - ) - - @property - @lazy - def n_pins(self): - return g.db.query(Submission).filter_by( - board_id=self.id, is_pinned=True).count() - - @property - def can_pin_another(self): - - return self.n_pins < 4 - - @property - def json_core(self): - - if self.is_banned: - return {'name': self.name, - 'permalink': self.permalink, - 'is_banned': True, - 'ban_reason': self.ban_reason, - 'id': self.base36id - } - return {'name': self.name, - 'profile_url': self.profile_url, - 'banner_url': self.banner_url, - 'created_utc': self.created_utc, - 'permalink': self.permalink, - 'description': self.description, - 'description_html': self.description_html, - 'over_18': self.over_18, - 'is_banned': False, - 'is_private': self.is_private, - 'is_restricted': self.restricted_posting, - 'id': self.base36id, - 'fullname': self.fullname, - 'banner_url': self.banner_url, - 'profile_url': self.profile_url, - 'color': "#" + self.color, - 'is_siege_protected': not self.is_siegable - } - - @property - def json(self): - data=self.json_core - - if self.is_banned: - return data - - - data['guildmasters']=[x.json_core for x in self.mods] - data['subscriber_count']= self.subscriber_count - - return data - - - @property - def show_settings_icons(self): - return self.is_private or self.restricted_posting or self.over_18 or self.all_opt_out - - @cache.memoize(600) - def comment_idlist(self, page=1, v=None, nsfw=False, **kwargs): - - posts = g.db.query(Submission).options( - lazyload('*')).filter_by(board_id=self.id) - - if not nsfw: - posts = posts.filter_by(over_18=False) - - if v and not v.show_nsfl: - posts = posts.filter_by(is_nsfl=False) - - if self.is_private: - if v and (self.can_view(v) or v.admin_level >= 4): - pass - elif v: - posts = posts.filter(or_(Submission.post_public == True, - Submission.author_id == v.id - ) - ) - else: - posts = posts.filter_by(post_public=True) - - posts = posts.subquery() - - comments = g.db.query(Comment).options(lazyload('*')) - - if v and v.hide_offensive: - comments = comments.filter_by(is_offensive=False) - - if v and v.hide_bot: - comments = comments.filter_by(is_bot=False) - - if v and not self.has_mod(v) and v.admin_level <= 3: - # blocks - blocking = g.db.query( - UserBlock.target_id).filter_by( - user_id=v.id).subquery() - blocked = g.db.query( - UserBlock.user_id).filter_by( - target_id=v.id).subquery() - - comments = comments.filter( - Comment.author_id.notin_(blocking), - Comment.author_id.notin_(blocked) - ) - - if not v or not v.admin_level >= 3: - comments = comments.filter_by(is_banned=False).filter(Comment.deleted_utc == 0) - - comments = comments.join( - posts, Comment.parent_submission == posts.c.id) - - comments = comments.order_by(Comment.created_utc.desc()).offset( - 25 * (page - 1)).limit(26).all() - - return [x.id for x in comments] \ No newline at end of file diff --git a/drama/classes/clients.py b/drama/classes/clients.py index 9e7ac33008..a04b36c871 100644 --- a/drama/classes/clients.py +++ b/drama/classes/clients.py @@ -19,7 +19,7 @@ class OauthApp(Base, Stndrd): redirect_uri = Column(String(4096)) author_id = Column(Integer, ForeignKey("users.id")) is_banned = Column(Boolean, default=False) - description = Column(String(256), default=None) + description = Column(String(256)) author = relationship("User") @@ -68,7 +68,6 @@ class ClientAuth(Base, Stndrd): scope_update = Column(Boolean, default=False) scope_delete = Column(Boolean, default=False) scope_vote = Column(Boolean, default=False) - scope_guildmaster = Column(Boolean, default=False) access_token = Column(String(128)) refresh_token = Column(String(128)) access_token_expire_utc = Column(Integer) @@ -86,7 +85,6 @@ class ClientAuth(Base, Stndrd): output += "update," if self.scope_update else "" output += "delete," if self.scope_delete else "" output += "vote," if self.scope_vote else "" - output += "guildmaster," if self.scope_guildmaster else "" output = output.rstrip(',') diff --git a/drama/classes/comment.py b/drama/classes/comment.py index 8f16e87d4b..d94c908ffe 100644 --- a/drama/classes/comment.py +++ b/drama/classes/comment.py @@ -14,7 +14,7 @@ class CommentAux(Base): key_id = Column(Integer, primary_key=True) id = Column(Integer, ForeignKey("comments.id")) - body = Column(String(10000), default=None) + body = Column(String(10000)) body_html = Column(String(20000)) ban_reason = Column(String(256), default='') @@ -40,8 +40,6 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing): is_banned = Column(Boolean, default=False) shadowbanned = Column(Boolean, default=False) distinguish_level = Column(Integer, default=0) - gm_distinguish = Column(Integer, ForeignKey("boards.id"), default=0) - distinguished_board = relationship("Board", lazy="joined", primaryjoin="Comment.gm_distinguish==Board.id") deleted_utc = Column(Integer, default=0) purged_utc = Column(Integer, default=0) is_approved = Column(Integer, default=0) @@ -51,18 +49,15 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing): score_top = Column(Integer, default=1) level = Column(Integer, default=0) parent_comment_id = Column(Integer, ForeignKey("comments.id")) - original_board_id = Column(Integer, ForeignKey("boards.id")) over_18 = Column(Boolean, default=False) - is_offensive = Column(Boolean, default=False) - is_nsfl = Column(Boolean, default=False) is_bot = Column(Boolean, default=False) - banaward = Column(String, default=None) + banaward = Column(String) is_pinned = Column(Boolean, default=False) - creation_region=Column(String(2), default=None) - sentto=Column(Integer, default=None) + creation_region=Column(String(2)) + sentto=Column(Integer) - app_id = Column(Integer, ForeignKey("oauth_apps.id"), default=None) + app_id = Column(Integer, ForeignKey("oauth_apps.id")) oauth_app=relationship("OauthApp") post = relationship("Submission") @@ -72,9 +67,6 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing): lazy="joined", innerjoin=True, primaryjoin="User.id==Comment.author_id") - board = association_proxy("post", "board") - original_board = relationship( - "Board", primaryjoin="Board.id==Comment.original_board_id") upvotes = Column(Integer, default=1) downvotes = Column(Integer, default=0) @@ -95,8 +87,6 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing): rank_fiery = deferred(Column(Float, server_default=FetchedValue())) rank_hot = deferred(Column(Float, server_default=FetchedValue())) - board_id = deferred(Column(Integer, server_default=FetchedValue())) - def __init__(self, *args, **kwargs): if "created_utc" not in kwargs: @@ -110,33 +100,19 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing): return f"" - @property - @lazy - def score_disputed(self): - return (self.upvotes+1) * (self.downvotes+1) - @property @lazy def fullname(self): return f"t3_{self.base36id}" + @property + @lazy + def score_disputed(self): + return (self.upvotes+1) * (self.downvotes+1) + def children(self, v): return sorted([x for x in self.child_comments if not x.author.shadowbanned or (v and v.id == x.author_id)], key=lambda x: x.score, reverse=True) - @property - @lazy - def is_deleted(self): - return bool(self.deleted_utc) - - @property - @lazy - def is_top_level(self): - return self.parent_fullname and self.parent_fullname.startswith("t2_") - - @property - def is_archived(self): - return self.post.is_archived - @property @lazy def parent(self): @@ -144,7 +120,7 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing): if not self.parent_submission: return None - if self.is_top_level: + if self.level == 1: return self.post else: @@ -176,18 +152,6 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing): if self.post: return f"{self.post.permalink}/{self.id}/" else: return f"/comment/{self.id}/" - @property - def any_descendants_live(self): - - if self.replies == []: - return False - - if any([not x.is_banned and x.deleted_utc == 0 for x in self.replies]): - return True - - else: - return any([x.any_descendants_live for x in self.replies]) - def rendered_comment(self, v=None, render_replies=True, standalone=False, level=1, **kwargs): @@ -229,27 +193,13 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing): else: return self.flag_count - def visibility_reason(self, v): - if not v or self.author_id == v.id: - return "this is your content." - elif not self.board: - return None - elif self.board.has_mod(v): - return f"you are a guildmaster of +{self.board.name}." - elif self.board.has_contributor(v): - return f"you are an approved contributor in +{self.board.name}." - elif self.parent.author_id == v.id: - return "this is a reply to your content." - elif v.admin_level >= 4: - return "you are a Drama admin." - @property def json_raw(self): data= { 'id': self.base36id, 'fullname': self.fullname, 'level': self.level, - 'author_name': self.author.username if not self.author.is_deleted else None, + 'author_name': self.author.username, 'body': self.body, 'body_html': self.body_html, 'is_archived': self.is_archived, @@ -257,10 +207,8 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing): 'created_utc': self.created_utc, 'edited_utc': self.edited_utc or 0, 'is_banned': bool(self.is_banned), - 'is_deleted': self.is_deleted, + 'deleted_utc': self.deleted_utc, 'is_nsfw': self.over_18, - 'is_offensive': self.is_offensive, - 'is_nsfl': self.is_nsfl, 'permalink': self.permalink, 'post_id': self.post.base36id, 'score': self.score_fuzzed, @@ -315,7 +263,6 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing): data["author"]=self.author.json_core data["post"]=self.post.json_core - data["guild"]=self.post.board.json_core if self.level >= 2: data["parent"]=self.parent.json_core @@ -402,9 +349,6 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing): if not v: return False - - if self.is_offensive and v.hide_offensive: - return True if self.is_bot and v.hide_bot: return True @@ -454,14 +398,10 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing): return data - @property - def is_exiled_for(self): - return self.__dict__.get('_is_exiled_for', None) - @property @lazy def is_op(self): - return self.author_id==self.post.author_id and not self.author.is_deleted and not self.post.author.is_deleted and not self.post.is_deleted + return self.author_id==self.post.author_id @@ -474,10 +414,10 @@ class Notification(Base): user_id = Column(Integer, ForeignKey("users.id")) comment_id = Column(Integer, ForeignKey("comments.id")) read = Column(Boolean, default=False) - followsender = Column(Integer, default=None) - unfollowsender = Column(Integer, default=None) - blocksender = Column(Integer, default=None) - unblocksender = Column(Integer, default=None) + followsender = Column(Integer) + unfollowsender = Column(Integer) + blocksender = Column(Integer) + unblocksender = Column(Integer) comment = relationship("Comment", lazy="joined", innerjoin=True) user=relationship("User", innerjoin=True) diff --git a/drama/classes/domains.py b/drama/classes/domains.py index 84fdeff18b..8cb870ceb3 100644 --- a/drama/classes/domains.py +++ b/drama/classes/domains.py @@ -20,8 +20,8 @@ class Domain(Base): can_comment = Column(Boolean, default=True) reason = Column(Integer, default=0) show_thumbnail = Column(Boolean, default=False) - embed_function = Column(String(64), default=None) - embed_template = Column(String(32), default=None) + embed_function = Column(String(64)) + embed_template = Column(String(32)) @property def reason_text(self): diff --git a/drama/classes/flags.py b/drama/classes/flags.py index 631b7dd760..de01017dab 100644 --- a/drama/classes/flags.py +++ b/drama/classes/flags.py @@ -10,7 +10,7 @@ class Flag(Base, Stndrd): id = Column(Integer, primary_key=True) post_id = Column(Integer, ForeignKey("submissions.id")) user_id = Column(Integer, ForeignKey("users.id")) - reason = Column(String(100), default=None) + reason = Column(String(100)) created_utc = Column(Integer) user = relationship("User", lazy = "joined", primaryjoin = "Flag.user_id == User.id", uselist = False) @@ -27,7 +27,7 @@ class CommentFlag(Base, Stndrd): id = Column(Integer, primary_key=True) user_id = Column(Integer, ForeignKey("users.id")) comment_id = Column(Integer, ForeignKey("comments.id")) - reason = Column(String(100), default=None) + reason = Column(String(100)) created_utc = Column(Integer) user = relationship("User", lazy = "joined", primaryjoin = "CommentFlag.user_id == User.id", uselist = False) @@ -45,8 +45,6 @@ class Report(Base): post_id = Column(Integer, ForeignKey("submissions.id")) user_id = Column(Integer, ForeignKey("users.id")) created_utc = Column(Integer) - - board_id = Column(Integer, server_default=FetchedValue()) user = relationship("User", lazy = "joined", primaryjoin = "Report.user_id == User.id", uselist = False) diff --git a/drama/classes/images.py b/drama/classes/images.py index 6ff9d4b152..701dd8dcdb 100644 --- a/drama/classes/images.py +++ b/drama/classes/images.py @@ -29,7 +29,7 @@ class BadPic(Base): __tablename__="badpics" id = Column(BigInteger, primary_key=True) - description=Column(String(255), default=None) + description=Column(String(255)) phash=Column(String(64)) ban_reason=Column(String(64)) ban_time=Column(Integer) diff --git a/drama/classes/mod_logs.py b/drama/classes/mod_logs.py index b4c678f393..b9d633c531 100644 --- a/drama/classes/mod_logs.py +++ b/drama/classes/mod_logs.py @@ -9,18 +9,16 @@ class ModAction(Base, Stndrd, Age_times): id = Column(BigInteger, primary_key=True) user_id = Column(Integer, ForeignKey("users.id")) - board_id = Column(Integer, ForeignKey("boards.id")) kind = Column(String(32)) target_user_id = Column(Integer, ForeignKey("users.id"), default=0) target_submission_id = Column(Integer, ForeignKey("submissions.id"), default=0) target_comment_id = Column(Integer, ForeignKey("comments.id"), default=0) - _note=Column(String(256), default=None) + _note=Column(String(256)) created_utc = Column(Integer, default=0) user = relationship("User", lazy="joined", primaryjoin="User.id==ModAction.user_id") target_user = relationship("User", lazy="joined", primaryjoin="User.id==ModAction.target_user_id") - board = relationship("Board", lazy="joined") target_post = relationship("Submission", lazy="joined") target_comment = relationship("Comment", lazy="joined") @@ -70,10 +68,7 @@ class ModAction(Base, Stndrd, Age_times): @property def target_link(self): if self.target_user: - if self.target_user.is_deleted: - return "[deleted user]" - else: - return f'{self.target_user.username}' + return f'{self.target_user.username}' elif self.target_post: return f'{self.target_post.title}' elif self.target_comment: @@ -86,7 +81,6 @@ class ModAction(Base, Stndrd, Age_times): def json(self): data={ "id":self.base36id, - "guild": self.board.name, "kind": self.kind, "created_utc": self.created_utc, "mod": self.user.username, @@ -120,14 +114,7 @@ class ModAction(Base, Stndrd, Age_times): @property def permalink(self): - return f"/log/{self.base36id}" - @property - def title_text(self): - if self.user.is_deleted: - return f"[deleted user] {self.actiontype['title'].format(self=self)}" - else: - return f"@{self.user.username} {self.actiontype['title'].format(self=self)}" - + return f"/log/{self.base36id}" @@ -270,36 +257,6 @@ ACTIONTYPES={ "color": "bg-muted", "title": 'un-pinned post {self.target_post.title}' }, - "invite_mod":{ - "str":'invited badmin {self.target_link}', - "icon":"fa-user-crown", - "color": "bg-info", - "title": 'invited badmin @{self.target_user.username}' - }, - "uninvite_mod":{ - "str":'rescinded badmin invitation to {self.target_link}', - "icon":"fa-user-crown", - "color": "bg-muted", - "title": 'rescinded badmin invitation to @{self.target_user.username}' - }, - "accept_mod_invite":{ - "str":'accepted badmin invitation', - "icon":"fa-user-crown", - "color": "bg-warning", - "title": 'accepted badmin invitation' - }, - "remove_mod":{ - "str":'removed badmin {self.target_link}', - "icon":"fa-user-crown", - "color": "bg-danger", - "title": 'removed badmin @{self.target_user.username}' - }, - "dethrone_self":{ - "str":'stepped down as guildmaster', - "icon":"fa-user-crown", - "color": "bg-danger", - "title": 'stepped down as guildmaster' - }, "add_mod":{ "str":'added badmin {self.target_link}', "icon":"fa-user-crown", @@ -330,18 +287,6 @@ ACTIONTYPES={ "color": "bg-muted", "title": 'un-set nsfw on post {self.target_post.title}' }, - "set_nsfl":{ - "str":'set nsfl on post {self.target_link}', - "icon":"fa-skull", - "color": "bg-black", - "title": 'set nsfl on post {self.target_post.title}' - }, - "unset_nsfl":{ - "str":'un-set nsfl on post {self.target_link}', - "icon":"fa-skull", - "color": "bg-muted", - "title": 'un-set nsfw on post {self.target_post.title}' - }, "ban_post":{ "str": 'removed post {self.target_link}', "icon":"fa-feather-alt", @@ -378,10 +323,4 @@ ACTIONTYPES={ "color": "bg-muted", "title": "changed permissions on invitation to {self.target_user.username}" }, - "create_guild":{ - "str": 'created +{self.board.name}', - "icon": "fa-chess-rook", - "color": "bg-primary", - "title": "created +{self.board.name}" - } } \ No newline at end of file diff --git a/drama/classes/submission.py b/drama/classes/submission.py index 42e12cec00..8f58dd300f 100644 --- a/drama/classes/submission.py +++ b/drama/classes/submission.py @@ -15,9 +15,9 @@ class SubmissionAux(Base): # we don't care about this ID key_id = Column(BigInteger, primary_key=True) id = Column(BigInteger, ForeignKey("submissions.id")) - title = Column(String(500), default=None) - title_html = Column(String(500), default=None) - url = Column(String(500), default=None) + title = Column(String(500)) + title_html = Column(String(500)) + url = Column(String(500)) body = Column(String(10000), default="") body_html = Column(String(20000), default="") ban_reason = Column(String(128), default="") @@ -37,20 +37,19 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing): uselist=False, innerjoin=True, primaryjoin="Submission.id==SubmissionAux.id") + gm_distinguish = Column(Integer, default=0) author_id = Column(BigInteger, ForeignKey("users.id")) repost_id = Column(BigInteger, ForeignKey("submissions.id"), default=0) edited_utc = Column(BigInteger, default=0) created_utc = Column(BigInteger, default=0) - thumburl = Column(String, default=None) + thumburl = Column(String) is_banned = Column(Boolean, default=False) views = Column(Integer, default=0) deleted_utc = Column(Integer, default=0) - banaward = Column(String, default=None) + banaward = Column(String) purged_utc = Column(Integer, default=0) distinguish_level = Column(Integer, default=0) - gm_distinguish = Column(Integer, ForeignKey("boards.id"), default=0) - distinguished_board = relationship("Board", lazy="joined", primaryjoin="Board.id==Submission.gm_distinguish") - created_str = Column(String(255), default=None) + created_str = Column(String(255)) stickied = Column(Boolean, default=False) is_pinned = Column(Boolean, default=False) private = Column(Boolean, default=False) @@ -64,26 +63,15 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing): flags = relationship("Flag", backref="submission") is_approved = Column(Integer, ForeignKey("users.id"), default=0) approved_utc = Column(Integer, default=0) - board_id = Column(Integer, ForeignKey("boards.id"), default=None) - original_board_id = Column(Integer, ForeignKey("boards.id"), default=None) over_18 = Column(Boolean, default=False) - original_board = relationship( - "Board", primaryjoin="Board.id==Submission.original_board_id") creation_ip = Column(String(64), default="") - mod_approved = Column(Integer, default=None) + mod_approved = Column(Integer) accepted_utc = Column(Integer, default=0) has_thumb = Column(Boolean, default=False) post_public = Column(Boolean, default=True) score_hot = Column(Float, default=0) score_top = Column(Float, default=1) score_activity = Column(Float, default=0) - is_offensive = Column(Boolean, default=False) - is_nsfl = Column(Boolean, default=False) - board = relationship( - "Board", - lazy="joined", - innerjoin=True, - primaryjoin="Submission.board_id==Board.id") author = relationship( "User", lazy="joined", @@ -96,9 +84,9 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing): upvotes = Column(Integer, default=1) downvotes = Column(Integer, default=0) - creation_region=Column(String(2), default=None) + creation_region=Column(String(2)) - app_id=Column(Integer, ForeignKey("oauth_apps.id"), default=None) + app_id=Column(Integer, ForeignKey("oauth_apps.id")) oauth_app=relationship("OauthApp") approved_by = relationship( @@ -138,16 +126,6 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing): def __repr__(self): return f"" - - @property - @lazy - def board_base36id(self): - return base36encode(self.board_id) - - @property - @lazy - def is_deleted(self): - return bool(self.deleted_utc) @property @lazy @@ -215,17 +193,12 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing): if "replies" not in self.__dict__ and "_preloaded_comments" in self.__dict__: self.tree_comments(comment=comment) - # return template - is_allowed_to_comment = self.board.can_comment( - v) and not self.is_archived - return render_template(template, v=v, p=self, sort=sort, linked_comment=comment, comment_info=comment_info, - is_allowed_to_comment=is_allowed_to_comment, render_replies=True, ) @@ -288,33 +261,18 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing): else: return None - def visibility_reason(self, v): - - - if not v or self.author_id == v.id: - return "this is your content." - elif self.is_pinned: - return "a guildmaster has pinned it." - elif self.board.has_mod(v): - return f"you are a guildmaster of +{self.board.name}." - elif self.board.has_contributor(v): - return f"you are an approved contributor in +{self.board.name}." - elif v.admin_level >= 4: - return "you are a Drama admin." - @property def json_raw(self): - data = {'author_name': self.author.username if not self.author.is_deleted else None, + data = {'author_name': self.author.username, 'permalink': self.permalink, 'is_banned': bool(self.is_banned), - 'is_deleted': self.is_deleted, + 'deleted_utc': self.deleted_utc, 'created_utc': self.created_utc, 'id': self.base36id, 'fullname': self.fullname, 'title': self.title, 'is_nsfw': self.over_18, - 'is_nsfl': self.is_nsfl, 'is_bot': self.is_bot, 'thumb_url': self.thumb_url, 'domain': self.domain, @@ -324,14 +282,11 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing): 'body_html': self.body_html, 'created_utc': self.created_utc, 'edited_utc': self.edited_utc or 0, - 'guild_name': self.board.name, - 'guild_id': base36encode(self.board_id), 'comment_count': self.comment_count, 'score': self.score_fuzzed, 'upvotes': self.upvotes_fuzzed, 'downvotes': self.downvotes_fuzzed, #'award_count': self.award_count, - 'is_offensive': self.is_offensive, 'meta_title': self.meta_title, 'meta_description': self.meta_description, 'voted': self.voted @@ -339,9 +294,6 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing): if self.ban_reason: data["ban_reason"]=self.ban_reason - if self.board_id != self.original_board_id and self.original_board: - data['original_guild_name'] = self.original_board.name - data['original_guild_id'] = base36encode(self.original_board_id) return data @property @@ -349,20 +301,18 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing): if self.is_banned: return {'is_banned': True, - 'is_deleted': self.is_deleted, + 'deleted_utc': self.deleted_utc, 'ban_reason': self.ban_reason, 'id': self.base36id, 'title': self.title, 'permalink': self.permalink, - 'guild_name': self.board.name } - elif self.is_deleted: + elif self.deleted_utc: return {'is_banned': bool(self.is_banned), - 'is_deleted': True, + 'deleted_utc': True, 'id': self.base36id, 'title': self.title, 'permalink': self.permalink, - 'guild_name': self.board.name } return self.json_raw @@ -376,8 +326,6 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing): return data data["author"]=self.author.json_core - data["guild"]=self.board.json_core - data["original_guild"]=self.original_board.json_core if not self.board_id==self.original_board_id else None data["comment_count"]=self.comment_count @@ -506,10 +454,6 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing): def is_blocking(self): return self.__dict__.get('_is_blocking', False) - @property - def is_public(self): - return self.post_public or not self.board.is_private - @property def flag_count(self): return len(self.flags) @@ -553,15 +497,10 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing): 'created_utc': self.created_utc, 'id': self.base36id, 'fullname': self.fullname, - 'guild_name': self.board.name, 'comment_count': self.comment_count, 'permalink': self.permalink } - if self.original_board_id and (self.original_board_id!= self.board_id): - - data['original_guild_name'] = self.original_board.name - return data @property diff --git a/drama/classes/subscriptions.py b/drama/classes/subscriptions.py index 560ab8b168..67aa95f0a2 100644 --- a/drama/classes/subscriptions.py +++ b/drama/classes/subscriptions.py @@ -8,13 +8,11 @@ class Subscription(Base): __tablename__ = "subscriptions" id = Column(BigInteger, primary_key=True) user_id = Column(BigInteger, ForeignKey("users.id")) - board_id = Column(BigInteger, ForeignKey("boards.id")) created_utc = Column(BigInteger, default=0) is_active = Column(Boolean, default=True) submission_id = Column(BigInteger, default=0) user = relationship("User", uselist=False) - board = relationship("Board", uselist=False) def __init__(self, *args, **kwargs): if "created_utc" not in kwargs: diff --git a/drama/classes/titles.py b/drama/classes/titles.py index 4fe67c23a6..4c2469cef3 100644 --- a/drama/classes/titles.py +++ b/drama/classes/titles.py @@ -13,11 +13,11 @@ class Title(Base): color = Column(String(6), default="888888") kind = Column(Integer, default=1) - background_color_1 = Column(String(6), default=None) - background_color_2 = Column(String(6), default=None) + background_color_1 = Column(String(6)) + background_color_2 = Column(String(6)) gradient_angle = Column(Integer, default=0) - box_shadow_color = Column(String(32), default=None) - text_shadow_color = Column(String(32), default=None) + box_shadow_color = Column(String(32)) + text_shadow_color = Column(String(32)) def check_eligibility(self, v): diff --git a/drama/classes/user.py b/drama/classes/user.py index 7bdf989ce0..bf54ed986b 100644 --- a/drama/classes/user.py +++ b/drama/classes/user.py @@ -8,8 +8,6 @@ from .alts import Alt from .titles import Title from .submission import SaveRelationship from .comment import Notification -from .boards import Board -from .board_relationships import * from .subscriptions import * from .userblock import * from .badges import * @@ -20,22 +18,22 @@ from drama.helpers.security import * class User(Base, Stndrd, Age_times): __tablename__ = "users" id = Column(Integer, primary_key=True) - username = Column(String, default=None) + username = Column(String) namecolor = Column(String, default='ff66ac') - customtitle = Column(String, default=None) - customtitleplain = Column(String, default=None) + customtitle = Column(String) + customtitleplain = Column(String) titlecolor = Column(String, default='ff66ac') theme = Column(String, default='dark') themecolor = Column(String, default='ff66ac') - song = Column(String, default=None) - profileurl = Column(String, default=None) - bannerurl = Column(String, default=None) + song = Column(String) + profileurl = Column(String) + bannerurl = Column(String) patron = Column(Boolean, default=False) animatedname = Column(Boolean, default=False) - email = Column(String, default=None) - css = deferred(Column(String, default=None)) - profilecss = deferred(Column(String, default=None)) - passhash = deferred(Column(String, default=None)) + email = Column(String) + css = deferred(Column(String)) + profilecss = deferred(Column(String)) + passhash = deferred(Column(String)) banawards = Column(Integer, default=0) created_utc = Column(Integer, default=0) suicide_utc = Column(Integer, default=0) @@ -52,7 +50,7 @@ class User(Base, Stndrd, Age_times): newtab = Column(Boolean, default=False) newtabexternal = Column(Boolean, default=True) oldreddit = Column(Boolean, default=False) - creation_ip = Column(String, default=None) + creation_ip = Column(String) submissions = relationship( "Submission", lazy="dynamic", @@ -67,7 +65,7 @@ class User(Base, Stndrd, Age_times): bio = Column(String, default="") bio_html = Column(String, default="") badges = relationship("Badge", lazy="dynamic", backref="user") - real_id = Column(String, default=None) + real_id = Column(String) notifications = relationship( "Notification", lazy="dynamic") @@ -76,30 +74,27 @@ class User(Base, Stndrd, Age_times): # "Notification", # primaryjoin="and_(Notification.user_id==User.id, Notification.read==False)") - referred_by = Column(Integer, default=None) + referred_by = Column(Integer) is_banned = Column(Integer, default=0) unban_utc = Column(Integer, default=0) ban_reason = Column(String, default="") feed_nonce = Column(Integer, default=0) login_nonce = Column(Integer, default=0) - title_id = Column(Integer, ForeignKey("titles.id"), default=None) + title_id = Column(Integer, ForeignKey("titles.id")) title = relationship("Title", lazy="joined") has_banner = Column(Boolean, default=False) - reserved = Column(String(256), default=None) + reserved = Column(String(256)) is_nsfw = Column(Boolean, default=False) profile_nonce = Column(Integer, default=0) + dramacoins = Column(Integer, default=0) banner_nonce = Column(Integer, default=0) last_siege_utc = Column(Integer, default=0) - mfa_secret = deferred(Column(String(16), default=None)) + mfa_secret = deferred(Column(String(16))) hide_offensive = Column(Boolean, default=False) hide_bot = Column(Boolean, default=False) - show_nsfl = Column(Boolean, default=False) is_private = Column(Boolean, default=False) read_announcement_utc = Column(Integer, default=0) unban_utc = Column(Integer, default=0) - - is_deleted = Column(Boolean, default=False) - delete_reason = Column(String(500), default='') filter_nsfw = Column(Boolean, default=False) stored_subscriber_count = Column(Integer, default=0) defaultsortingcomments = Column(String, default="top") @@ -111,12 +106,12 @@ class User(Base, Stndrd, Age_times): is_nofollow = Column(Boolean, default=False) custom_filter_list = Column(String(1000), default="") - discord_id = Column(String(64), default=None) - creation_region = Column(String(2), default=None) + discord_id = Column(String(64)) + creation_region = Column(String(2)) ban_evade = Column(Integer, default=0) - profile_upload_ip = deferred(Column(String(255), default=None)) - banner_upload_ip = deferred(Column(String(255), default=None)) + profile_upload_ip = deferred(Column(String(255))) + banner_upload_ip = deferred(Column(String(255))) profile_upload_region = deferred(Column(String(2))) banner_upload_region = deferred(Column(String(2))) @@ -126,15 +121,7 @@ class User(Base, Stndrd, Age_times): original_username = deferred(Column(String(255))) name_changed_utc = deferred(Column(Integer, default=0)) - moderates = relationship("ModRelationship") - banned_from = relationship("BanRelationship", primaryjoin="BanRelationship.user_id==User.id") subscriptions = relationship("Subscription") - boards_created = relationship("Board", lazy="dynamic") - contributes = relationship( - "ContributorRelationship", - lazy="dynamic", - primaryjoin="ContributorRelationship.user_id==User.id") - board_blocks = relationship("BoardBlock", lazy="dynamic") following = relationship("Follow", primaryjoin="Follow.user_id==User.id") followers = relationship("Follow", primaryjoin="Follow.target_id==User.id") @@ -166,17 +153,6 @@ class User(Base, Stndrd, Age_times): super().__init__(**kwargs) - @property - @lazy - def dramacoins(self): - posts = sum([x[0] - 1 for x in - g.db.query(Submission.score).options(lazyload('*')).filter_by(author_id=self.id, is_banned=False, - deleted_utc=0).all()]) - comments = sum([x[0] - 1 for x in - g.db.query(Comment.score).options(lazyload('*')).filter_by(author_id=self.id, is_banned=False, - deleted_utc=0).all()]) - return int(posts + comments) - def has_block(self, target): return g.db.query(UserBlock).filter_by( @@ -256,27 +232,8 @@ class User(Base, Stndrd, Age_times): comments = comments.filter(Comment.deleted_utc == 0) comments = comments.filter(Comment.is_banned == False) - if v and v.admin_level >= 4: - pass - elif v: - m = g.db.query(ModRelationship).filter_by(user_id=v.id, invite_rescinded=False).subquery() - c = v.contributes.subquery() - - comments = comments.join(m, - m.c.board_id == Submission.board_id, - isouter=True - ).join(c, - c.c.board_id == Submission.board_id, - isouter=True - ).join(Board, Board.id == Submission.board_id) - comments = comments.filter(or_(Comment.author_id == v.id, - Submission.post_public == True, - Board.is_private == False, - m.c.board_id != None, - c.c.board_id != None)) - else: - comments = comments.join(Board, Board.id == Submission.board_id).filter( - or_(Submission.post_public == True, Board.is_private == False)) + if v and v.admin_level == 0: + comments = comments.filter(or_(Comment.author_id == v.id)) comments = comments.options(contains_eager(Comment.post)) @@ -310,20 +267,6 @@ class User(Base, Stndrd, Age_times): secondrange = firstrange + 26 return [x.id for x in comments[firstrange:secondrange]] - @property - @lazy - def mods_anything(self): - - return bool([i for i in self.moderates if i.accepted]) - - @property - def boards_modded(self): - - z = [x.board for x in self.moderates if x and x.board and x.accepted and not x.board.is_banned] - z = sorted(z, key=lambda x: x.name) - - return z - @property def base36id(self): return base36encode(self.id) @@ -332,15 +275,6 @@ class User(Base, Stndrd, Age_times): def fullname(self): return f"t1_{self.base36id}" - @property - @cache.memoize(timeout=60) - def has_report_queue(self): - board_ids = [ - x.board_id for x in self.moderates.filter_by( - accepted=True).all()] - return bool(g.db.query(Submission).filter(Submission.board_id.in_( - board_ids), Submission.mod_approved == 0, Submission.is_banned == False).join(Submission.reports).first()) - @property def banned_by(self): @@ -617,44 +551,8 @@ class User(Base, Stndrd, Age_times): else: return self.defaultpicture() - @property - def available_titles(self): - - locs = {"v": self, - "Board": Board, - "Submission": Submission - } - - titles = [ - i for i in g.db.query(Title).order_by( - text("id asc")).all() if eval( - i.qualification_expr, {}, locs)] - return titles - - @property - def can_make_guild(self): - return False - - @property - def can_join_gms(self): - return len([x for x in self.boards_modded if x.is_siegable]) < 10 - - @property - def can_siege(self): - - if self.is_suspended: - return False - - now = int(time.time()) - - return now - max(self.last_siege_utc, - self.created_utc) > 60 * 60 * 24 * 7 - @property def can_submit_image(self): - # Has premium - # Has 1000 Rep, or 500 for older accounts - # if connecting through Tor, must have verified email return self.dramacoins >= 0 @property @@ -699,22 +597,12 @@ class User(Base, Stndrd, Age_times): 'ban_reason': self.ban_reason, 'id': self.base36id } - - elif self.is_deleted: - return {'username': self.username, - 'permalink': self.permalink, - 'is_deleted': True, - 'id': self.base36id - } return self.json_raw @property def json(self): data = self.json_core - if self.is_deleted or self.is_banned: - return data - data["badges"] = [x.json_core for x in self.badges] data['dramacoins'] = int(self.dramacoins) data['post_count'] = self.post_count @@ -726,20 +614,6 @@ class User(Base, Stndrd, Age_times): def can_use_darkmode(self): return True - # return self.referral_count or self.has_earned_darkmode or - # self.has_badge(16) or self.has_badge(17) - - @property - def is_valid(self): - if self.is_banned and self.unban_utc == 0: - return False - - elif self.is_deleted: - return False - - else: - return True - def ban(self, admin=None, reason=None, days=0): if days > 0: @@ -869,90 +743,12 @@ 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): - - now = int(time.time()) - - if self.negative_balance_cents: - return False - - elif self.premium_expires_utc > now: - return True - - elif self.coin_balance >= 1: - self.coin_balance -= 1 - self.premium_expires_utc = now + 60 * 60 * 24 * 7 - - g.db.add(self) - - return True - - else: - - if self.premium_expires_utc: - self.premium_expires_utc = 0 - g.db.add(self) - - return False - - @property - def has_premium_no_renew(self): - - now = int(time.time()) - - if self.negative_balance_cents: - return False - elif self.premium_expires_utc > now: - return True - elif self.coin_balance >= 1: - return True - else: - return False - - @property - def renew_premium_time(self): - return time.strftime("%d %b %Y at %H:%M:%S", - time.gmtime(self.premium_expires_utc)) - @property def filter_words(self): l = [i.strip() for i in self.custom_filter_list.split('\n')] if self.custom_filter_list else [] l = [i for i in l if i] return l - @property - def boards_modded_ids(self): - return [x.id for x in self.boards_modded] - @property def json_admin(self): data = self.json_raw @@ -966,7 +762,7 @@ class User(Base, Stndrd, Age_times): @property def can_upload_comment_image(self): - return self.dramacoins >= 0 and (request.headers.get("cf-ipcountry") != "T1" or self.is_activated) + return self.dramacoins >= 0 and request.headers.get("cf-ipcountry") != "T1" @property def can_change_name(self): diff --git a/drama/classes/votes.py b/drama/classes/votes.py index a249c53741..e24d38d3ab 100644 --- a/drama/classes/votes.py +++ b/drama/classes/votes.py @@ -14,8 +14,8 @@ class Vote(Base): vote_type = Column(Integer) submission_id = Column(Integer, ForeignKey("submissions.id")) created_utc = Column(Integer, default=0) - creation_ip = Column(String, default=None) - app_id = Column(Integer, ForeignKey("oauth_apps.id"), default=None) + creation_ip = Column(String) + app_id = Column(Integer, ForeignKey("oauth_apps.id")) user = relationship("User", lazy="subquery") post = relationship("Submission", lazy="subquery") @@ -76,8 +76,8 @@ class CommentVote(Base): vote_type = Column(Integer) comment_id = Column(Integer, ForeignKey("comments.id")) created_utc = Column(Integer, default=0) - creation_ip = Column(String, default=None) - app_id = Column(Integer, ForeignKey("oauth_apps.id"), default=None) + creation_ip = Column(String) + app_id = Column(Integer, ForeignKey("oauth_apps.id")) user = relationship("User", lazy="subquery") comment = relationship("Comment", lazy="subquery") diff --git a/drama/helpers/session.py b/drama/helpers/session.py index 11b0a10f9b..2706ab7201 100644 --- a/drama/helpers/session.py +++ b/drama/helpers/session.py @@ -3,18 +3,11 @@ import time from .security import * -def session_over18(board): +def session_over18(): now = int(time.time()) - return session.get('over_18', {}).get(board.base36id, 0) >= now - - -def session_isnsfl(board): - - now = int(time.time()) - - return session.get('show_nsfl', {}).get(board.base36id, 0) >= now + return session.get('over_18', {}).get(1) >= now def make_logged_out_formkey(t): diff --git a/drama/helpers/wrappers.py b/drama/helpers/wrappers.py index 3520b917e7..0793e5921c 100644 --- a/drama/helpers/wrappers.py +++ b/drama/helpers/wrappers.py @@ -47,12 +47,8 @@ def get_logged_in_user(db=None): nonce = session.get("login_nonce", 0) if not uid: x= (None, None) - v = db.query(User).options( - joinedload(User.moderates).joinedload(ModRelationship.board), #joinedload(Board.reports), - ).filter_by( - id=uid, - is_deleted=False - ).first() + v = db.query(User).filter_by( + id=uid).first() if v and v.agendaposter_expires_utc and v.agendaposter_expires_utc < g.timestamp: v.agendaposter_expires_utc = 0 @@ -94,7 +90,6 @@ def check_ban_evade(v): kind="ban_post", user_id=2317, target_submission_id=post.id, - board_id=post.board_id, note="ban evasion" ) g.db.add(ma) @@ -113,7 +108,6 @@ def check_ban_evade(v): kind="ban_comment", user_id=2317, target_comment_id=comment.id, - board_id=comment.post.board_id, note="ban evasion" ) g.db.add(ma) diff --git a/drama/routes/__init__.py b/drama/routes/__init__.py index eb789f8f09..438666d820 100644 --- a/drama/routes/__init__.py +++ b/drama/routes/__init__.py @@ -1,5 +1,4 @@ from .admin import * -from .boards import * from .comments import * from .discord import * from .errors import * diff --git a/drama/routes/admin.py b/drama/routes/admin.py index 9ed218f810..3c8fe341ad 100644 --- a/drama/routes/admin.py +++ b/drama/routes/admin.py @@ -24,6 +24,27 @@ import matplotlib.pyplot as plt from .front import frontlist from drama.__main__ import app, cache +@app.route("/dramacoins/posts", methods=["GET"]) +@admin_level_required(6) +def dp(v): + for p in g.db.query(Submission).options(lazyload('*')).all(): + print(p.id) + if p.author: + print(p.author.username) + p.author.dramacoins += p.upvotes + p.downvotes - 1 + g.db.add(p.author) + return "sex" + +@app.route("/dramacoins/comments", methods=["GET"]) +@admin_level_required(6) +def dc(v): + for p in g.db.query(Comment).options(lazyload('*')).filter(Comment.parent_submission != None).all(): + print(p.id) + if p.author: + print(p.author.username) + p.author.dramacoins += p.upvotes + p.downvotes - 1 + g.db.add(p.author) + return "sex" @app.route("/admin/shadowbanned", methods=["GET"]) @auth_required @@ -126,8 +147,7 @@ def flagged_comments(v): @app.route("/admin", methods=["GET"]) @admin_level_required(3) def admin_home(v): - b = g.db.query(Board).filter_by(id=1).first() - return render_template("admin/admin_home.html", v=v, b=b) + return render_template("admin/admin_home.html", v=v) @app.route("/admin/badge_grant", methods=["GET"]) @@ -536,7 +556,6 @@ def agendaposter(user_id, v): kind=kind, user_id=v.id, target_user_id=user.id, - board_id=1, note = note ) g.db.add(ma) @@ -546,14 +565,11 @@ def agendaposter(user_id, v): else: return redirect(user.url) -@app.route("/disablesignups", methods=["POST"]) -@admin_level_required(6) -@validate_formkey -def disablesignups(v): - board = g.db.query(Board).filter_by(id=1).first() - board.disablesignups = not board.disablesignups - g.db.add(board) - return "", 204 +# @app.route("/disablesignups", methods=["POST"]) +# @admin_level_required(6) +# @validate_formkey +# def disablesignups(v): +# return "", 204 @app.route("/shadowban/", methods=["POST"]) @@ -572,7 +588,6 @@ def shadowban(user_id, v): kind="shadowban", user_id=v.id, target_user_id=user.id, - board_id=1, ) g.db.add(ma) cache.delete_memoized(frontlist) @@ -595,7 +610,6 @@ def unshadowban(user_id, v): kind="unshadowban", user_id=v.id, target_user_id=user.id, - board_id=1, ) g.db.add(ma) cache.delete_memoized(frontlist) @@ -629,7 +643,6 @@ def admin_title_change(user_id, v): kind=kind, user_id=v.id, target_user_id=user.id, - board_id=1, note=f'"{new_name}"' ) g.db.add(ma) @@ -683,7 +696,6 @@ def ban_user(user_id, v): kind="exile_user", user_id=v.id, target_user_id=user.id, - board_id=1, note=f'reason: "{reason}", duration: {duration}' ) g.db.add(ma) @@ -717,7 +729,6 @@ def unban_user(user_id, v): kind="unexile_user", user_id=v.id, target_user_id=user.id, - board_id=1, ) g.db.add(ma) g.db.commit() @@ -757,7 +768,6 @@ def ban_post(post_id, v): kind="ban_post", user_id=v.id, target_submission_id=post.id, - board_id=post.board_id, ) g.db.add(ma) return "", 204 @@ -778,7 +788,6 @@ def unban_post(post_id, v): kind="unban_post", user_id=v.id, target_submission_id=post.id, - board_id=post.board_id, ) g.db.add(ma) @@ -857,7 +866,6 @@ def api_ban_comment(c_id, v): kind="ban_comment", user_id=v.id, target_comment_id=comment.id, - board_id=comment.post.board_id, ) g.db.add(ma) return "", 204 @@ -877,7 +885,6 @@ def api_unban_comment(c_id, v): kind="unban_comment", user_id=v.id, target_comment_id=comment.id, - board_id=comment.post.board_id, ) g.db.add(ma) @@ -911,7 +918,6 @@ def admin_distinguish_comment(c_id, v): v=v, comments=[comment], render_replies=False, - is_allowed_to_comment=True ) html=str(BeautifulSoup(html, features="html.parser").find(id=f"comment-{comment.base36id}-only")) @@ -987,7 +993,6 @@ def admin_nuke_user(v): kind="nuke_user", user_id=v.id, target_user_id=user.id, - board_id=1, ) g.db.add(ma) @@ -1018,7 +1023,6 @@ def admin_nunuke_user(v): kind="unnuke_user", user_id=v.id, target_user_id=user.id, - board_id=1, ) g.db.add(ma) @@ -1178,4 +1182,51 @@ def multiple_plots(**kwargs): plt.savefig(name) plt.clf() - return upload_from_file(name, name) \ No newline at end of file + return upload_from_file(name, name) + + +@app.route("/admin/distinguish_post/", methods=["POST"]) +@app.route("/api/v1/distinguish_post/", methods=["POST"]) +@admin_level_required(6) +@api("update") +def distinguish_post(pid, v): + + post = get_post(pid, v=v) + + if post.author_id != v.id: + abort(403) + + if post.gm_distinguish: + post.gm_distinguish = 0 + else: + post.gm_distinguish = 1 + g.db.add(post) + + ma=ModAction( + kind="herald_post" if post.gm_distinguish else "unherald_post", + user_id=v.id, + target_submission_id=post.id, + ) + g.db.add(ma) + + return "", 204 + +@app.route("/admin/add_admin", methods=["POST"]) +@auth_required +@validate_formkey +def invite_username(v): + + username = request.form.get("username", '').lstrip('@') + user = get_user(username) + if not user: + return jsonify({"error": "That user doesn't exist."}), 404 + user.admin_level = 6 + g.db.add(user) + ma=ModAction( + kind="add_mod", + user_id=v.id, + target_user_id=user.id, + ) + g.db.add(ma) + + return "", 204 \ No newline at end of file diff --git a/drama/routes/boards.py b/drama/routes/boards.py deleted file mode 100644 index 7fc42e5add..0000000000 --- a/drama/routes/boards.py +++ /dev/null @@ -1,311 +0,0 @@ -from drama.helpers.wrappers import * -from drama.helpers.alerts import * -from drama.classes import * -from flask import * -from drama.__main__ import app, limiter, cache - -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 -@api("guildmaster") -def mod_distinguish_post(bid, pid, board, v): - - #print(pid, board, v) - - post = get_post(pid, v=v) - - if not post.board_id==board.id: - abort(400) - - if post.author_id != v.id: - abort(403) - - if post.gm_distinguish: - post.gm_distinguish = 0 - else: - post.gm_distinguish = board.id - g.db.add(post) - - ma=ModAction( - kind="herald_post" if post.gm_distinguish else "unherald_post", - user_id=v.id, - target_submission_id=post.id, - board_id=board.id - ) - g.db.add(ma) - - return "", 204 - -@app.route("/mod/invite_mod", methods=["POST"]) -@auth_required -@validate_formkey -def mod_invite_username(v): - - username = request.form.get("username", '').lstrip('@') - user = get_user(username) - if not user: - return jsonify({"error": "That user doesn't exist."}), 404 - - if not user.can_join_gms: - return jsonify({"error": f"@{user.username} already leads enough guilds."}), 409 - - x = g.db.query(ModRelationship).filter_by( - user_id=user.id, board_id=1).first() - - if x and x.accepted: - return jsonify({"error": f"@{user.username} is already a mod."}), 409 - - if x and not x.invite_rescinded: - return jsonify({"error": f"@{user.username} has already been invited."}), 409 - - if x: - - x.invite_rescinded = False - g.db.add(x) - - else: - x = ModRelationship( - user_id=user.id, - board_id=1, - accepted=False, - perm_full=True, - perm_content=True, - perm_appearance=True, - perm_access=True, - perm_config=True - ) - - text = f"You have been invited to become an admin. You can [click here](/badmins) and accept this invitation. Or, if you weren't expecting this, you can ignore it." - send_notification(1046, user, text) - - g.db.add(x) - - ma=ModAction( - kind="invite_mod", - user_id=v.id, - target_user_id=user.id, - board_id=1 - ) - g.db.add(ma) - - return "", 204 - - -@app.route("/mod//rescind/", methods=["POST"]) -@auth_required -@validate_formkey -def mod_rescind_bid_username(bid, username, board, v): - - user = get_user(username) - - invitation = g.db.query(ModRelationship).filter_by(board_id=board.id, - user_id=user.id, - accepted=False).first() - if not invitation: - abort(404) - - invitation.invite_rescinded = True - - g.db.add(invitation) - ma=ModAction( - kind="uninvite_mod", - user_id=v.id, - target_user_id=user.id, - board_id=1 - ) - g.db.add(ma) - return "", 204 - - -@app.route("/mod/accept/", methods=["POST"]) -@app.route("/api/v1/accept_invite/", methods=["POST"]) -@auth_required -@validate_formkey -@api("guildmaster") -def mod_accept_board(bid, v): - - board = g.db.query(Board).first() - - x = board.has_invite(v) - if not x: - abort(404) - - if not v.can_join_gms: - return jsonify({"error": f"You already lead enough guilds."}), 409 - if board.has_ban(v): - return jsonify({"error": f"You are exiled from +{board.name} and can't currently become a guildmaster."}), 409 - x.accepted = True - x.created_utc=int(time.time()) - g.db.add(x) - - ma=ModAction( - kind="accept_mod_invite", - user_id=v.id, - target_user_id=v.id, - board_id=board.id - ) - g.db.add(ma) - - v.admin_level = 6 - return "", 204 - -@app.route("/mod//step_down", methods=["POST"]) -@auth_required -@validate_formkey -def mod_step_down(bid, board, v): - - - v_mod = board.has_mod(v) - - if not v_mod: - abort(404) - - g.db.delete(v_mod) - - ma=ModAction( - kind="dethrone_self", - user_id=v.id, - target_user_id=v.id, - board_id=board.id - ) - g.db.add(ma) - v.admin_level = 0 - return "", 204 - - - -@app.route("/mod//remove/", methods=["POST"]) -@auth_required -@validate_formkey -def mod_remove_username(bid, username, board, v): - - user = get_user(username) - - u_mod = board.has_mod(user) - v_mod = board.has_mod(v) - - if not u_mod: - abort(400) - elif not v_mod: - abort(400) - - if not u_mod.board_id==board.id: - abort(400) - - if not v_mod.board_id==board.id: - abort(400) - - if v_mod.id > u_mod.id: - abort(403) - - g.db.delete(u_mod) - - ma=ModAction( - kind="remove_mod", - user_id=v.id, - target_user_id=user.id, - board_id=board.id - ) - g.db.add(ma) - - user.admin_level = 0 - return "", 204 - -@app.route("/badmins", methods=["GET"]) -@app.route("/api/vue/mod/mods", methods=["GET"]) -@app.route("/api/v1/mod/mods", methods=["GET"]) -@auth_desired -@public("read") -def board_about_mods(v): - - board = g.db.query(Board).first() - - me = board.has_mod(v) - - return { - "html":lambda:render_template("mods.html", v=v, b=board, me=me), - "api":lambda:jsonify({"data":[x.json for x in board.mods_list]}) - } - -@app.route("/log", methods=["GET"]) -@app.route("/api/v1/mod_log", methods=["GET"]) -@auth_desired -@api("read") -def board_mod_log(v): - - page=int(request.args.get("page",1)) - - if v and v.admin_level == 6: actions = g.db.query(ModAction).order_by(ModAction.id.desc()).offset(25 * (page - 1)).limit(26).all() - else: actions=g.db.query(ModAction).filter(ModAction.kind!="shadowban", ModAction.kind!="unshadowban").order_by(ModAction.id.desc()).offset(25*(page-1)).limit(26).all() - actions=[i for i in actions] - - next_exists=len(actions)==26 - actions=actions[0:25] - - return { - "html":lambda:render_template( - "modlog.html", - v=v, - actions=actions, - next_exists=next_exists, - page=page - ), - "api":lambda:jsonify({"data":[x.json for x in actions]}) - } - -@app.route("/log/", methods=["GET"]) -@auth_desired -def mod_log_item(aid, v): - - action=g.db.query(ModAction).filter_by(id=base36decode(aid)).first() - - if not action: - abort(404) - - if request.path != action.permalink: - return redirect(action.permalink) - - return render_template("modlog.html", - v=v, - actions=[action], - next_exists=False, - page=1, - action=action - ) - -@app.route("/mod/edit_perms", methods=["POST"]) -@auth_required -@validate_formkey -def board_mod_perms_change(boardname, board, v): - - user=get_user(request.form.get("username")) - - v_mod=board.has_mod(v) - u_mod=board.has_mod_record(user) - - if v_mod.id > u_mod.id: - return jsonify({"error":"You can't change perms on badmins above you."}), 403 - - #print({x:request.form.get(x) for x in request.form}) - - u_mod.perm_full = bool(request.form.get("perm_full" , False)) - u_mod.perm_access = bool(request.form.get("perm_access" , False)) - u_mod.perm_appearance = bool(request.form.get("perm_appearance" , False)) - u_mod.perm_config = bool(request.form.get("perm_config" , False)) - u_mod.perm_content = bool(request.form.get("perm_content" , False)) - - g.db.add(u_mod) - g.db.commit() - - ma=ModAction( - kind="change_perms" if u_mod.accepted else "change_invite", - user_id=v.id, - board_id=board.id, - target_user_id=user.id, - note=u_mod.permchangelist - ) - g.db.add(ma) - - return redirect(f"{board.permalink}/mod/mods") \ No newline at end of file diff --git a/drama/routes/comments.py b/drama/routes/comments.py index 7f2a2c7dcd..e7cc52d7cd 100644 --- a/drama/routes/comments.py +++ b/drama/routes/comments.py @@ -39,7 +39,6 @@ def banawardcomment(comment_id, v): kind="exile_user", user_id=v.id, target_user_id=u.id, - board_id=1, note=f'reason: "1 day ban award", duration: 1 day' ) g.db.add(ma) @@ -85,16 +84,14 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): except: abort(404) post = get_post(pid, v=v) - board = post.board - if post.over_18 and not (v and v.over_18) and not session_over18(comment.board): + if post.over_18 and not (v and v.over_18) and not session_over18(1): t = int(time.time()) return {'html': lambda: render_template("errors/nsfw.html", v=v, t=t, lo_formkey=make_logged_out_formkey( t), - board=comment.board ), 'api': lambda: {'error': f'This content is not suitable for some users and situations.'} @@ -107,7 +104,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): except: context = 0 comment_info = comment c = comment - while context > 0 and not c.is_top_level: + while context > 0 and c.level > 1: parent = get_comment(c.parent_comment_id, v=v) @@ -312,12 +309,6 @@ def api_comment(v): return jsonify( {"error": "You can't reply to users who have blocked you, or users you have blocked."}), 403 - # check for archive and ban state - post = get_post(parent_id) - if post.is_archived or not post.board.can_comment(v): - - return jsonify({"error": "You can't comment on this."}), 403 - # get bot status is_bot = request.headers.get("X-User-Type","")=="Bot" @@ -362,7 +353,6 @@ def api_comment(v): user_id=2317, target_comment_id=comment.id, kind="ban_comment", - board_id=comment.post.board_id, note="spam" ) g.db.add(ma) @@ -400,8 +390,6 @@ def api_comment(v): parent_comment_id=parent_comment_id, level=level, over_18=post.over_18 or request.form.get("over_18","")=="true", - is_nsfl=post.is_nsfl or request.form.get("is_nsfl","")=="true", - original_board_id=parent_post.board_id, is_bot=is_bot, app_id=v.client.application.id if v.client else None, shadowbanned=shadowbanned @@ -424,21 +412,6 @@ def api_comment(v): with CustomRenderer(post_id=parent_id) as renderer: body_md = renderer.render(mistletoe.Document(body)) body_html = sanitize(body_md, linkgen=True) - - # #csam detection - # def del_function(): - # delete_file(name) - # c.is_banned=True - # g.db.add(c) - # g.db.commit() - - # csam_thread=threading.Thread(target=check_csam_url, - # args=(f"https://s3.eu-central-1.amazonaws.com/i.ruqqus.ga/{name}", - # v, - # del_function - # ) - # ) - # csam_thread.start() c_aux = CommentAux( id=c.id, @@ -462,7 +435,6 @@ def api_comment(v): parent_fullname=c.fullname, parent_comment_id=c.id, level=level+1, - original_board_id=1, is_bot=True, ) @@ -497,7 +469,6 @@ def api_comment(v): parent_fullname=c.fullname, parent_comment_id=c.id, level=level+1, - original_board_id=1, is_bot=True, ) @@ -530,7 +501,6 @@ def api_comment(v): parent_fullname=c.fullname, parent_comment_id=c.id, level=level+1, - original_board_id=1, is_bot=True, ) @@ -558,7 +528,6 @@ def api_comment(v): parent_fullname=c2.fullname, parent_comment_id=c2.id, level=level+2, - original_board_id=1, is_bot=True, ) @@ -586,7 +555,6 @@ def api_comment(v): parent_fullname=c3.fullname, parent_comment_id=c3.id, level=level+3, - original_board_id=1, is_bot=True, ) @@ -672,7 +640,6 @@ def api_comment(v): # print(f"Content Event: @{v.username} comment {c.base36id}") - board = g.db.query(Board).first() cache.delete_memoized(comment_idlist) cache.delete_memoized(User.commentlisting, v) @@ -680,7 +647,6 @@ def api_comment(v): v=v, comments=[c], render_replies=False, - is_allowed_to_comment=True )}), "api": lambda: c.json } @@ -835,7 +801,6 @@ def edit_comment(cid, v): parent_fullname=c.fullname, parent_comment_id=c.id, level=c.level+1, - original_board_id=1, is_bot=True, ) @@ -961,15 +926,12 @@ def embed_comment_cid(cid, pid=None): 'api': lambda: {'error': f'Comment {cid} has been removed'} } - if comment.board.is_banned: - abort(410) - return render_template("embeds/comment.html", c=comment) @app.route("/comment_pin/", methods=["POST"]) @auth_required @validate_formkey -def mod_toggle_comment_pin(cid, v): +def toggle_comment_pin(cid, v): comment = get_comment(cid, v=v) @@ -985,7 +947,6 @@ def mod_toggle_comment_pin(cid, v): ma=ModAction( kind="pin_comment" if comment.is_pinned else "unpin_comment", user_id=v.id, - board_id=1, target_comment_id=comment.id ) g.db.add(ma) @@ -995,7 +956,6 @@ def mod_toggle_comment_pin(cid, v): v=v, comments=[comment], render_replies=False, - is_allowed_to_comment=True ) html=str(BeautifulSoup(html, features="html.parser").find(id=f"comment-{comment.base36id}-only")) diff --git a/drama/routes/errors.py b/drama/routes/errors.py index 5a178b92af..69817cd999 100644 --- a/drama/routes/errors.py +++ b/drama/routes/errors.py @@ -154,24 +154,24 @@ def error_503(e, v): } -@app.route("/allow_nsfw_logged_in/", methods=["POST"]) +@app.route("/allow_nsfw_logged_in", methods=["POST"]) @auth_required @validate_formkey -def allow_nsfw_logged_in(bid, v): +def allow_nsfw_logged_in(v): cutoff = int(time.time()) + 3600 if not session.get("over_18", None): session["over_18"] = {} - session["over_18"][bid] = cutoff + session["over_18"][1] = cutoff return redirect(request.form.get("redir")) -@app.route("/allow_nsfw_logged_out/", methods=["POST"]) +@app.route("/allow_nsfw_logged_out", methods=["POST"]) @auth_desired -def allow_nsfw_logged_out(bid, v): +def allow_nsfw_logged_out(v): if v: return redirect('/') @@ -187,49 +187,10 @@ def allow_nsfw_logged_out(bid, v): session["over_18"] = {} cutoff = int(time.time()) + 3600 - session["over_18"][bid] = cutoff + session["over_18"][1] = cutoff return redirect(request.form.get("redir")) - -@app.route("/allow_nsfl_logged_in/", methods=["POST"]) -@auth_required -@validate_formkey -def allow_nsfl_logged_in(bid, v): - - cutoff = int(time.time()) + 3600 - - if not session.get("show_nsfl", None): - session["show_nsfl"] = {} - - session["show_nsfl"][bid] = cutoff - - return redirect(request.form.get("redir")) - - -@app.route("/allow_nsfl_logged_out/", methods=["POST"]) -@auth_desired -def allow_nsfl_logged_out(bid, v): - - if v: - return redirect('/') - - t = int(request.form.get('time')) - - if not validate_logged_out_formkey(t, - request.form.get("formkey") - ): - abort(403) - - if not session.get("show_nsfl", None): - session["show_nsfl"] = {} - - cutoff = int(time.time()) + 3600 - session["show_nsfl"][bid] = cutoff - - return redirect(request.form.get("redir")) - - @app.route("/error/", methods=["GET"]) @auth_desired def error_all_preview(error, v): diff --git a/drama/routes/feeds.py b/drama/routes/feeds.py index 90385002bf..a995f0781b 100644 --- a/drama/routes/feeds.py +++ b/drama/routes/feeds.py @@ -35,7 +35,6 @@ def feeds_user(sort='hot', t='all'): for post in posts: #print("POST IMAGE "+ str( post.is_image )) - board_name = f"+{post.board.name}" with tag("entry", ("xml:base", request.url)): with tag("title", type="text"): text(post.title) @@ -60,8 +59,6 @@ def feeds_user(sort='hot', t='all'): doc.stag("link", href=full_link(post.permalink)) - doc.stag("category", term=board_name, label=board_name, schema=full_link("/" + board_name)) - image_url = post.thumb_url or post.embed_url or post.url doc.stag("media:thumbnail", url=image_url) diff --git a/drama/routes/front.py b/drama/routes/front.py index 20bd260075..aa23b51828 100644 --- a/drama/routes/front.py +++ b/drama/routes/front.py @@ -427,7 +427,6 @@ def all_comments(v): idlist = idlist[0:25] - board = g.db.query(Board).first() return {"html": lambda: render_template("home_comments.html", v=v, sort=sort, diff --git a/drama/routes/login.py b/drama/routes/login.py index 58ee7f4f70..67d66f6eba 100644 --- a/drama/routes/login.py +++ b/drama/routes/login.py @@ -60,8 +60,7 @@ def login_post(): if "@" in username: account = g.db.query(User).filter( - User.email.ilike(username), - User.is_deleted == False).first() + User.email.ilike(username)).first() else: account = get_user(username, graceful=True) @@ -69,10 +68,6 @@ def login_post(): time.sleep(random.uniform(0, 2)) return render_template("login.html", failed=True, i=random_image()) - if account.is_deleted: - time.sleep(random.uniform(0, 2)) - return render_template("login.html", failed=True, i=random_image()) - # test password if request.form.get("password"): @@ -161,11 +156,9 @@ def logout(v): @no_cors @auth_desired def sign_up_get(v): - board = g.db.query(Board).filter_by(id=1).first() - if board.disablesignups: return "Signups are disable for the time being.", 403 + #if disablesignups: return "Signups are disable for the time being.", 403 - if v: - return redirect("/") + if v: return redirect("/") agent = request.headers.get("User-Agent", None) if not agent: @@ -219,8 +212,7 @@ def sign_up_get(v): @no_cors @auth_desired def sign_up_post(v): - board = g.db.query(Board).filter_by(id=1).first() - if board.disablesignups: return "Signups are disable for the time being.", 403 + #if disablesignups: return "Signups are disable for the time being.", 403 if v: abort(403) @@ -420,8 +412,7 @@ def post_forgot(): user = g.db.query(User).filter( User.username.ilike(username), - User.email.ilike(email), - User.is_deleted == False).first() + User.email.ilike(email)).first() if user: # generate url diff --git a/drama/routes/oauth.py b/drama/routes/oauth.py index 62a47667eb..5573efef1c 100644 --- a/drama/routes/oauth.py +++ b/drama/routes/oauth.py @@ -12,7 +12,6 @@ SCOPES = { 'update': 'Edit your posts and comments', 'delete': 'Delete your posts and comments', 'vote': 'Cast votes as you', - 'guildmaster': 'Perform Badmin actions' } @@ -49,9 +48,8 @@ def oauth_authorize_prompt(v): if scope not in SCOPES: return jsonify({"oauth_error": f"The provided scope `{scope}` is not valid."}), 400 - if any(x in scopes for x in ["create", "update", - "guildmaster"]) and "identity" not in scopes: - return jsonify({"oauth_error": f"`identity` scope required when requesting `create`, `update`, or `guildmaster` scope."}), 400 + if any(x in scopes for x in ["create", "update"]) and "identity" not in scopes: + return jsonify({"oauth_error": f"`identity` scope required when requesting `create` or `update` scope."}), 400 redirect_uri = request.args.get("redirect_uri") if not redirect_uri: @@ -112,9 +110,8 @@ def oauth_authorize_post(v): if scope not in SCOPES: return jsonify({"oauth_error": f"The provided scope `{scope}` is not valid."}), 400 - if any(x in scopes for x in ["create", "update", - "guildmaster"]) and "identity" not in scopes: - return jsonify({"oauth_error": f"`identity` scope required when requesting `create`, `update`, or `guildmaster` scope."}), 400 + if any(x in scopes for x in ["create", "update"]) and "identity" not in scopes: + return jsonify({"oauth_error": f"`identity` scope required when requesting `create` or `update` scope."}), 400 if not state: return jsonify({'oauth_error': 'state argument required'}), 400 @@ -131,7 +128,6 @@ def oauth_authorize_post(v): scope_update="update" in scopes, scope_delete="delete" in scopes, scope_vote="vote" in scopes, - scope_guildmaster="guildmaster" in scopes, refresh_token=secrets.token_urlsafe(128)[0:128] if permanent else None ) diff --git a/drama/routes/posts.py b/drama/routes/posts.py index 5c07205b95..280e2ef1a3 100644 --- a/drama/routes/posts.py +++ b/drama/routes/posts.py @@ -40,7 +40,6 @@ def postbanaward(post_id, v): kind="exile_user", user_id=v.id, target_user_id=u.id, - board_id=1, note=f'reason: "1 day ban award", duration: 1 day' ) g.db.add(ma) @@ -69,13 +68,9 @@ def publish(pid, v): @auth_required def submit_get(v): if v and v.is_banned and not v.unban_utc: return render_template("seized.html") - - b = g.db.query(Board).first() - + return render_template("submit.html", - v=v, - b=b - ) + v=v) @app.route("/post/", methods=["GET"]) @app.route("/post//", methods=["GET"]) @@ -237,15 +232,12 @@ def post_base36id(pid, anything=None, v=None): g.db.add(post) g.db.commit() - board = post.board - - if post.over_18 and not (v and v.over_18) and not session_over18(board): + if post.over_18 and not (v and v.over_18) and not session_over18(1): t = int(time.time()) return {"html":lambda:render_template("errors/nsfw.html", v=v, t=t, lo_formkey=make_logged_out_formkey(t), - board=post.board ), "api":lambda:(jsonify({"error":"Must be 18+ to view"}), 451) @@ -271,9 +263,6 @@ def edit_post(pid, v): if p.is_banned: abort(403) - if p.board.has_ban(v): - abort(403) - body = request.form.get("body", "") for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif))', body, re.MULTILINE): body = body.replace(i.group(1), f'![]({i.group(1)})') body = body.replace("\n", "\n\n") @@ -346,9 +335,6 @@ def edit_post(pid, v): parent_fullname=p.fullname, level=1, over_18=False, - is_nsfl=False, - is_offensive=False, - original_board_id=1, is_bot=True, app_id=None, creation_region=request.headers.get("cf-ipcountry"), @@ -600,8 +586,6 @@ def submit_post(v): if repost: return redirect(repost.permalink) - board = g.db.query(Board).first() - if not title: return {"html": lambda: (render_template("submit.html", v=v, @@ -610,22 +594,10 @@ def submit_post(v): url=url, body=request.form.get( "body", ""), - b=board ), 400), "api": lambda: ({"error": "Please enter a better title"}, 400) } - # if len(title)<10: - # return render_template("submit.html", - # v=v, - # error="Please enter a better title.", - # title=title, - # url=url, - # body=request.form.get("body",""), - # b=board - # ) - - elif len(title) > 500: return {"html": lambda: (render_template("submit.html", v=v, @@ -634,7 +606,6 @@ def submit_post(v): url=url, body=request.form.get( "body", ""), - b=board ), 400), "api": lambda: ({"error": "500 character limit for titles"}, 400) } @@ -649,7 +620,6 @@ def submit_post(v): url=url, body=request.form.get( "body", ""), - b=board ), 400), "api": lambda: ({"error": "`url` or `body` parameter required."}, 400) } @@ -677,7 +647,6 @@ def submit_post(v): Submission.author_id == v.id, Submission.deleted_utc == 0, - Submission.board_id == board.id, SubmissionAux.title == title, SubmissionAux.url == url, SubmissionAux.body == body @@ -710,7 +679,6 @@ def submit_post(v): url=url, body=request.form.get( "body", ""), - b=board ), 400), "api": lambda: ({"error": "ToS violation"}, 400) } @@ -727,65 +695,6 @@ def submit_post(v): embed = None - # board - board_name = request.form.get("board", "general") - board_name = board_name.lstrip("+") - board_name = board_name.strip() - - board = g.db.query(Board).first() - - if not board: - - return {"html": lambda: (render_template("submit.html", - v=v, - error=f"Please enter a Guild to submit to.", - title=title, - url=url, body=request.form.get( - "body", ""), - b=None - ), 403), - "api": lambda: (jsonify({"error": f"403 Forbidden - +{board.name} has been banned."})) - } - - if board.is_banned: - - return {"html": lambda: (render_template("submit.html", - v=v, - error=f"+{board.name} has been banned.", - title=title, - url=url, body=request.form.get( - "body", ""), - b=None - ), 403), - "api": lambda: (jsonify({"error": f"403 Forbidden - +{board.name} has been banned."})) - } - - if board.has_ban(v): - return {"html": lambda: (render_template("submit.html", - v=v, - error=f"You are exiled from +{board.name}.", - title=title, - url=url, body=request.form.get( - "body", ""), - b=None - ), 403), - "api": lambda: (jsonify({"error": f"403 Not Authorized - You are exiled from +{board.name}"}), 403) - } - - if (board.restricted_posting or board.is_private) and not ( - board.can_submit(v)): - return {"html": lambda: (render_template("submit.html", - v=v, - error=f"You are not an approved contributor for +{board.name}.", - title=title, - url=url, - body=request.form.get( - "body", ""), - b=None - ), 403), - "api": lambda: (jsonify({"error": f"403 Not Authorized - You are not an approved contributor for +{board.name}"}), 403) - } - # similarity check now = int(time.time()) cutoff = now - 60 * 60 * 24 @@ -857,7 +766,6 @@ def submit_post(v): user_id=2317, target_submission_id=post.id, kind="ban_post", - board_id=post.board_id, note="spam" ) g.db.add(ma) @@ -874,7 +782,6 @@ def submit_post(v): url=url, body=request.form.get( "body", ""), - b=board ), 400), "api": lambda: ({"error": "10000 character limit for text body."}, 400) } @@ -888,7 +795,6 @@ def submit_post(v): url=url, body=request.form.get( "body", ""), - b=board ), 400), "api": lambda: ({"error": "2048 character limit for URLs."}, 400) } @@ -920,7 +826,6 @@ def submit_post(v): url=url, body=request.form.get( "body", ""), - b=board ), 403), "api": lambda: ({"error": reason}, 403) } @@ -961,7 +866,6 @@ def submit_post(v): url=url, body=request.form.get( "body", ""), - b=board ), 400), "api": lambda: ({"error": f"The link `{badlink.link}` is not allowed. Reason: {badlink.reason}"}, 400) } @@ -977,13 +881,8 @@ def submit_post(v): private=bool(request.form.get("private","")), author_id=v.id, domain_ref=domain_obj.id if domain_obj else None, - board_id=board.id, - original_board_id=board.id, over_18=bool(request.form.get("over_18","")), - is_nsfl=bool(request.form.get("is_nsfl","")), - post_public=not board.is_private, repost_id=repost.id if repost else None, - is_offensive=False, app_id=v.client.application.id if v.client else None, creation_region=request.headers.get("cf-ipcountry"), is_bot = request.headers.get("X-User-Type","").lower()=="bot" @@ -1037,7 +936,6 @@ def submit_post(v): title=title, body=request.form.get( "body", ""), - b=board ), 400), "api": lambda: ({"error": f"Image files only"}, 400) } @@ -1054,7 +952,6 @@ def submit_post(v): # spin off thumbnail generation and csam detection as new threads if (new_post.url or request.files.get('file')) and (v.is_activated or request.headers.get('cf-ipcountry')!="T1"): thumbs(new_post) - # expire the relevant caches: front page new, board new cache.delete_memoized(frontlist) cache.delete_memoized(User.userpagelisting) g.db.commit() @@ -1091,9 +988,6 @@ def submit_post(v): parent_fullname=new_post.fullname, level=1, over_18=False, - is_nsfl=False, - is_offensive=False, - original_board_id=1, is_bot=True, app_id=None, creation_region=request.headers.get("cf-ipcountry"), @@ -1131,9 +1025,6 @@ def submit_post(v): parent_fullname=new_post.fullname, level=1, over_18=False, - is_nsfl=False, - is_offensive=False, - original_board_id=1, is_bot=True, app_id=None, creation_region=request.headers.get("cf-ipcountry") @@ -1205,7 +1096,7 @@ def embed_post_pid(pid): post = get_post(pid) - if post.is_banned or post.board.is_banned: + if post.is_banned: abort(410) return render_template("embeds/submission.html", p=post) @@ -1232,12 +1123,7 @@ def toggle_post_nsfw(pid, v): post = get_post(pid) - mod=post.board.has_mod(v) - - if not post.author_id == v.id and not v.admin_level >= 3 and not mod: - abort(403) - - if post.board.over_18 and post.over_18: + if not post.author_id == v.id and not v.admin_level >= 3: abort(403) post.over_18 = not post.over_18 @@ -1248,7 +1134,6 @@ def toggle_post_nsfw(pid, v): kind="set_nsfw" if post.over_18 else "unset_nsfw", user_id=v.id, target_submission_id=post.id, - board_id=post.board.id, ) g.db.add(ma) diff --git a/drama/routes/search.py b/drama/routes/search.py index 4fbd17e792..8d8c6ae935 100644 --- a/drama/routes/search.py +++ b/drama/routes/search.py @@ -55,7 +55,6 @@ def searchlisting(criteria, v=None, page=1, t="None", sort="top", b=None): posts=posts.filter( Submission.author_id==get_user(criteria['author']).id, User.is_private==False, - User.is_deleted==False ) if 'domain' in criteria: diff --git a/drama/routes/settings.py b/drama/routes/settings.py index fdcb610e53..697ee08ec3 100644 --- a/drama/routes/settings.py +++ b/drama/routes/settings.py @@ -392,16 +392,6 @@ def settings_delete_banner(v): msg="Banner successfully removed.") -@app.route("/settings/toggle_collapse", methods=["POST"]) -@auth_required -@validate_formkey -def settings_toggle_collapse(v): - - session["sidebar_collapsed"] = not session.get("sidebar_collapsed", False) - - return "", 204 - - @app.route("/settings/read_announcement", methods=["POST"]) @auth_required @validate_formkey diff --git a/drama/routes/static.py b/drama/routes/static.py index 076f052591..d2e640f0c5 100644 --- a/drama/routes/static.py +++ b/drama/routes/static.py @@ -2,6 +2,65 @@ from drama.mail import * from drama.__main__ import app, limiter from drama.helpers.alerts import * + +@app.route("/badmins", methods=["GET"]) +@app.route("/api/vue/admin/mods", methods=["GET"]) +@app.route("/api/v1/admin/mods", methods=["GET"]) +@auth_desired +@public("read") +def badmins(v): + badmins = g.db.query(User).filter_by(admin_level=6).all() + return { + "html":lambda:render_template("mods.html", v=v, badmins=badmins), + "api":lambda:jsonify({"data":[x.json for x in badmins]}) + } + +@app.route("/log", methods=["GET"]) +@app.route("/api/v1/mod_log", methods=["GET"]) +@auth_desired +@api("read") +def log(v): + + page=int(request.args.get("page",1)) + + if v and v.admin_level == 6: actions = g.db.query(ModAction).order_by(ModAction.id.desc()).offset(25 * (page - 1)).limit(26).all() + else: actions=g.db.query(ModAction).filter(ModAction.kind!="shadowban", ModAction.kind!="unshadowban").order_by(ModAction.id.desc()).offset(25*(page-1)).limit(26).all() + actions=[i for i in actions] + + next_exists=len(actions)==26 + actions=actions[0:25] + + return { + "html":lambda:render_template( + "modlog.html", + v=v, + actions=actions, + next_exists=next_exists, + page=page + ), + "api":lambda:jsonify({"data":[x.json for x in actions]}) + } + +@app.route("/log/", methods=["GET"]) +@auth_desired +def log_item(aid, v): + + action=g.db.query(ModAction).filter_by(id=base36decode(aid)).first() + + if not action: + abort(404) + + if request.path != action.permalink: + return redirect(action.permalink) + + return render_template("modlog.html", + v=v, + actions=[action], + next_exists=False, + page=1, + action=action + ) + @app.route("/sex") def index(): return render_template("index.html", **{"greeting": "Hello from Flask!"}) diff --git a/drama/routes/users.py b/drama/routes/users.py index 1f77132474..d8143c9be9 100644 --- a/drama/routes/users.py +++ b/drama/routes/users.py @@ -264,13 +264,6 @@ def u_username(username, v=None): g.db.add(view) - if u.is_deleted and (not v or v.admin_level < 3): - return {'html': lambda: render_template("userpage_deleted.html", - u=u, - v=v), - 'api': lambda: {"error": "That user deactivated their account."} - } - if u.is_private and (not v or (v.id != u.id and v.admin_level < 3)): return {'html': lambda: render_template("userpage_private.html", u=u, @@ -407,7 +400,6 @@ def u_username_comments(username, v=None): is_following = (v and user.has_follower(v)) - board = g.db.query(Board).first() return {"html": lambda: render_template("userpage_comments.html", u=user, v=v, diff --git a/drama/routes/votes.py b/drama/routes/votes.py index 73ab3dbb18..cc4678a9a5 100644 --- a/drama/routes/votes.py +++ b/drama/routes/votes.py @@ -3,7 +3,6 @@ from drama.helpers.get import * from drama.classes import * from flask import * from drama.__main__ import app -from .users import leaderboard @app.route("/votes", methods=["GET"]) @@ -113,8 +112,6 @@ def api_vote_post(post_id, x, v): post.downvotes = post.downs g.db.add(post) g.db.commit() - - users1, users2 = leaderboard() return "", 204 @app.route("/api/v1/vote/comment//", methods=["POST"]) diff --git a/drama/templates/admin/admin_home.html b/drama/templates/admin/admin_home.html index 2a16d55105..6537b433b0 100644 --- a/drama/templates/admin/admin_home.html +++ b/drama/templates/admin/admin_home.html @@ -1,8 +1,5 @@ {% extends "default.html" %} -{% block sidebarblock %}{% endblock %} -{% block sidebarLeftblock %}{% endblock %} - {% block title %} Drama diff --git a/drama/templates/admin/alt_votes.html b/drama/templates/admin/alt_votes.html index 9cdce00f84..d2a24d282d 100644 --- a/drama/templates/admin/alt_votes.html +++ b/drama/templates/admin/alt_votes.html @@ -1,8 +1,5 @@ {% extends "default.html" %} -{% block sidebarblock %}{% endblock %} -{% block sidebarLeftblock %}{% endblock %} - {% block title %} Drama diff --git a/drama/templates/admin/app.html b/drama/templates/admin/app.html index e2b3be60f5..b9c6d2e0f3 100644 --- a/drama/templates/admin/app.html +++ b/drama/templates/admin/app.html @@ -1,8 +1,5 @@ {% extends "default.html" %} -{% block sidebarblock %}{% endblock %} -{% block sidebarLeftblock %}{% endblock %} - {% block title %} API App Administration diff --git a/drama/templates/admin/app_data.html b/drama/templates/admin/app_data.html index 8a72acabbc..c0b93710f5 100644 --- a/drama/templates/admin/app_data.html +++ b/drama/templates/admin/app_data.html @@ -1,8 +1,5 @@ {% extends "default.html" %} -{% block sidebarblock %}{% endblock %} -{% block sidebarLeftblock %}{% endblock %} - {% block title %} Drama diff --git a/drama/templates/admin/apps.html b/drama/templates/admin/apps.html index 96aff06bab..f289765d35 100644 --- a/drama/templates/admin/apps.html +++ b/drama/templates/admin/apps.html @@ -1,8 +1,5 @@ {% extends "default.html" %} -{% block sidebarblock %}{% endblock %} -{% block sidebarLeftblock %}{% endblock %} - {% block title %} API App Administration diff --git a/drama/templates/admin/badge_grant.html b/drama/templates/admin/badge_grant.html index 0e6ae8dcdd..fca3c53bec 100644 --- a/drama/templates/admin/badge_grant.html +++ b/drama/templates/admin/badge_grant.html @@ -6,8 +6,6 @@ {% block pagetype %}message{% endblock %} -{% block sidebarblock %}{% endblock %} - {% block content %} {% if error %} diff --git a/drama/templates/admin/cache.html b/drama/templates/admin/cache.html index 7ba222c173..5d98226325 100644 --- a/drama/templates/admin/cache.html +++ b/drama/templates/admin/cache.html @@ -1,8 +1,5 @@ {% extends "default.html" %} -{% block sidebarblock %}{% endblock %} -{% block sidebarLeftblock %}{% endblock %} - {% block title %} Drama diff --git a/drama/templates/admin/content_stats.html b/drama/templates/admin/content_stats.html index 8d1e6253ec..bf3104a8e1 100644 --- a/drama/templates/admin/content_stats.html +++ b/drama/templates/admin/content_stats.html @@ -1,8 +1,5 @@ {% extends "default.html" %} -{% block sidebarblock %}{% endblock %} -{% block sidebarLeftblock %}{% endblock %} - {% block title %} Drama diff --git a/drama/templates/admin/flagged_posts.html b/drama/templates/admin/flagged_posts.html index d345af0dfb..ecd1eb5d72 100644 --- a/drama/templates/admin/flagged_posts.html +++ b/drama/templates/admin/flagged_posts.html @@ -5,7 +5,6 @@ {% block banner %}{% endblock %} {% block mobileBanner %}{% endblock %} {% block desktopBanner %}{% endblock %} -{% block sidebarLeftblock %}{% endblock %} {% block desktopUserBanner %}{% endblock %} {% block mobileUserBanner %}{% endblock %} diff --git a/drama/templates/admin/image_ban.html b/drama/templates/admin/image_ban.html index e9c0b8fcfc..954a5a574a 100644 --- a/drama/templates/admin/image_ban.html +++ b/drama/templates/admin/image_ban.html @@ -1,8 +1,5 @@ {% extends "default.html" %} -{% block sidebarblock %}{% endblock %} -{% block sidebarLeftblock %}{% endblock %} - {% block title %} Image Ban diff --git a/drama/templates/admin/image_posts.html b/drama/templates/admin/image_posts.html index 74e2bed936..57a60be1f0 100644 --- a/drama/templates/admin/image_posts.html +++ b/drama/templates/admin/image_posts.html @@ -5,7 +5,6 @@ {% block banner %}{% endblock %} {% block mobileBanner %}{% endblock %} {% block desktopBanner %}{% endblock %} -{% block sidebarLeftblock %}{% endblock %} {% block desktopUserBanner %}{% endblock %} {% block mobileUserBanner %}{% endblock %} @@ -41,22 +40,6 @@ {% endblock %} -{% block sidebarblock %} -

-

-
-{% endblock %}
-
 {% block content %}
 
 
diff --git a/drama/templates/admin/image_purge.html b/drama/templates/admin/image_purge.html
index 557e76eae9..bb16048059 100644
--- a/drama/templates/admin/image_purge.html
+++ b/drama/templates/admin/image_purge.html
@@ -1,8 +1,5 @@
 {% extends "default.html" %}
 
-{% block sidebarblock %}{% endblock %}
-{% block sidebarLeftblock %}{% endblock %}
-
 {% block title %}
 Purge Image
 
diff --git a/drama/templates/admin/manage_domain.html b/drama/templates/admin/manage_domain.html
index 7d332765ca..ab113aeacf 100644
--- a/drama/templates/admin/manage_domain.html
+++ b/drama/templates/admin/manage_domain.html
@@ -1,8 +1,5 @@
 {% extends "default.html" %}
 
-{% block sidebarblock %}{% endblock %}
-{% block sidebarLeftblock %}{% endblock %}
-
 {% block title %}
 Drama
 
diff --git a/drama/templates/admin/new_users.html b/drama/templates/admin/new_users.html
index cb44eb421c..429c0704bb 100644
--- a/drama/templates/admin/new_users.html
+++ b/drama/templates/admin/new_users.html
@@ -6,14 +6,4 @@
 {% include "user_listing.html" %}
 {% endblock %}
 
-{% block sidebarblock %}
-	
-{% endblock %}
-
-{% block navbar %}{% endblock %}
-
-{% block sidebar %}{% endblock %}
\ No newline at end of file
+{% block navbar %}{% endblock %}
\ No newline at end of file
diff --git a/drama/templates/admin/votes.html b/drama/templates/admin/votes.html
index 117216c907..3fb2437f1a 100644
--- a/drama/templates/admin/votes.html
+++ b/drama/templates/admin/votes.html
@@ -1,8 +1,5 @@
 {% extends "default.html" %}
 
-{% block sidebarblock %}{% endblock %}
-{% block sidebarLeftblock %}{% endblock %}
-
 {% block title %}
 Drama
 
diff --git a/drama/templates/badmins.html b/drama/templates/badmins.html
new file mode 100644
index 0000000000..61cd2db646
--- /dev/null
+++ b/drama/templates/badmins.html
@@ -0,0 +1,34 @@
+{% extends "settings2.html" %}
+
+{% block pagetitle %}Badmins{% endblock %}
+
+{% block content %}
+
+
+ +
+ + + + + + + + + + {% for badmin in badmins %} + + + + {% else %} + + {% endfor %} + +
UserBadmin Since
+ + @{{badmin.username}} +
There are no badmins.
+
+
+ +{% endblock %} diff --git a/drama/templates/banned.html b/drama/templates/banned.html index 12cf4ab42a..f927b4710a 100644 --- a/drama/templates/banned.html +++ b/drama/templates/banned.html @@ -1,4 +1,4 @@ -{% extends "guild_settings.html" %} +{% extends "settings2.html" %} {% block content %} diff --git a/drama/templates/blocks.html b/drama/templates/blocks.html index f0494a2c3b..c0f04ba493 100644 --- a/drama/templates/blocks.html +++ b/drama/templates/blocks.html @@ -1,4 +1,4 @@ -{% extends "guild_settings.html" %} +{% extends "settings2.html" %} {% block pagetitle %}Blocks{% endblock %} diff --git a/drama/templates/changelog.html b/drama/templates/changelog.html index 4a7d5cace9..11c08ea8dd 100644 --- a/drama/templates/changelog.html +++ b/drama/templates/changelog.html @@ -1,4 +1,4 @@ -{% extends "guild_settings.html" %} +{% extends "settings2.html" %} {% block pagetitle %}Changelog{% endblock %} diff --git a/drama/templates/comments.html b/drama/templates/comments.html index ab20d808d1..1cf5d9e7dd 100644 --- a/drama/templates/comments.html +++ b/drama/templates/comments.html @@ -85,7 +85,7 @@ {% if c.parent_submission %} {% if c.author_id==v.id and c.child_comments and is_notification_page%} Comment {{'Replies' if (c.child_comments | length)>1 else 'Reply'}}: {{c.post.title | safe}} - {% elif c.post.author_id==v.id and c.is_top_level and is_notification_page%} + {% elif c.post.author_id==v.id and c.level == 1 and is_notification_page%} Post Reply: {{c.post.title | safe}} {% elif is_notification_page and c.parent_submission in v.subscribed_idlist() %} Subscribed Thread: {{c.post.title | safe}} @@ -116,7 +116,6 @@ {% if c.banaward %}  {% endif %} {% if c.active_flags %} {{c.active_flags}} Reports {% endif %} {% if c.over_18 %}+18 {% endif %} - {% if c.is_nsfl %}nsfl {% endif %} {% if v and v.admin_level==6 and c.author.shadowbanned %} {% endif %} {% if c.is_pinned %} {% endif %} {% if c.distinguish_level %} {% endif %} @@ -125,7 +124,7 @@ {% if c.is_blocking %} {% endif %} {% if c.is_blocked %} {% endif %} - {% if c.author.is_deleted %}[deleted account]{% else %}{{c.author.username}}{% if c.author.customtitle %}  {{c.author.customtitle | safe}}{% endif %}{% endif %} + {{c.author.username}}{% if c.author.customtitle %}  {{c.author.customtitle | safe}}{% endif %}  {{c.age_string}} {% if c.edited_utc %} @@ -163,7 +162,7 @@ {% if c.parent_submission %} - {% if v and v.id==c.author_id and (standalone or is_allowed_to_comment) %} + {% if v and v.id==c.author_id %}
- - - - - - - - - - {% for mod in b.mods_list %} - - - - - - - {% else %} - - {% endfor %} - - -
UserBadmin Since
- - @{{mod.user.username}} - {{mod.created_date}} - {% if me and me.id < mod.id %} - - {% endif %} - - -
There are no badmins.
- - - - -

Pending

- -

These users have been invited to be badmins.

- -
- - - - - - - - - - - {% for m in b.mod_invites %} - - - - - - {% else %} - - {% endfor %} - - -
UserInvited On
- - @{{m.user.username}} - {{m.created_date}} - -
There are no badmin invitations.
-
- - - - - - - - - - - - - - - - - - - - - - - -{% endblock %} - -{% block errorToasts %} - - - -{% endblock %} - -{% block invitationModal %} -{% if b.has_invite(v) %} -{% include "gm_invitation_modal.html" %} -{% endif %} -{% endblock %} diff --git a/drama/templates/oauthhelp.html b/drama/templates/oauthhelp.html index a0b76c9764..2f74e99bcb 100644 --- a/drama/templates/oauthhelp.html +++ b/drama/templates/oauthhelp.html @@ -34,7 +34,7 @@ Send your user to `https://rdrama.net/oauth/authorize`, with the following URL p * `client_id` - Your application's Client ID * `redirect_uri` - The redirect URI (or one of the URIs) specified in your application information. Must not use HTTP unless using localhost (use HTTPS instead). * `state` - This is your own anti-cross-site-forgery token. We don't do anything with this, except give it to the user to pass back to you later. You are responsible for generating and validating the state token. -* `scope` - A comma-separated list of permission scopes that you are requesting. Valid scopes are: `identity`, `create`, `read`, `update`, `delete`, `vote`, and `guildmaster`. +* `scope` - A comma-separated list of permission scopes that you are requesting. Valid scopes are: `identity`, `create`, `read`, `update`, `delete` and `vote`. * `permanent` - optional. Set to `true` if you are requesting indefinite access. Omit if not. If done correctly, the user will see that your application wants to access their Drama account, and be prompted to approve or deny the request. diff --git a/drama/templates/search_users.html b/drama/templates/search_users.html index 01f8f7d357..a397aa8d09 100644 --- a/drama/templates/search_users.html +++ b/drama/templates/search_users.html @@ -9,7 +9,6 @@ {% block listinglength %}{{users | length}}{% endblock %} {% block pagenav %} - {% if boards %} - {% endif %} {% endblock %} diff --git a/drama/templates/guild_settings.html b/drama/templates/settings2.html similarity index 100% rename from drama/templates/guild_settings.html rename to drama/templates/settings2.html diff --git a/drama/templates/submission.html b/drama/templates/submission.html index bcc33af789..147ef5370c 100644 --- a/drama/templates/submission.html +++ b/drama/templates/submission.html @@ -14,18 +14,6 @@ {% set downs=p.downvotes_fuzzed %} {% set score=ups-downs %} -{% block sidebarblock %} - -{% endblock %} - {% if v %} {% set voted=p.voted if p.voted else 0 %} {% else %} @@ -38,24 +26,23 @@ {% if comment_info and not comment_info.is_banned and not linked_comment.deleted_utc > 0 %} -{{'@'+comment_info.author.username if not comment_info.author.is_deleted else '[deleted account]'}} comments on "{{title}} - Drama" +{{'@'+comment_info.author.username}} comments on "{{title}} - Drama" - - + {% if comment_info.edited_utc %}{% endif %} - - + + - - + + @@ -68,12 +55,11 @@ {{title | safe}} - Drama - - + {% if p.edited_utc %}{% endif %} - + @@ -82,7 +68,7 @@ - + @@ -110,7 +96,7 @@