rename submissions to posts

master
Aevann 2023-06-08 02:26:32 +03:00
parent bf078e2f1a
commit 32fa466e6a
55 changed files with 401 additions and 389 deletions

View File

@ -4290,7 +4290,7 @@ small, .small {
text-decoration: none;
}
.post-meta-domain {
/* fixes very long domains overflowing submission_listing */
/* fixes very long domains overflowing post_listing */
display: inline-block;
max-width: 20em;
overflow: hidden;
@ -4868,10 +4868,10 @@ ul.comment-section {
width: 100% !important;
}
}
.submission .body {
.post .body {
padding: 1rem;
}
.submission .footer {
.post .footer {
background-color: transparent;
padding: 1rem;
border-bottom-left-radius: 0.25rem;
@ -5149,13 +5149,13 @@ pre .com, code .com {
#thread .post-title {
font-size: 16px;
}
#submit .submission {
#submit .post {
border: none;
}
#submit .submission .body {
#submit .post .body {
padding: 0;
}
#submit .submission .footer {
#submit .post .footer {
background: transparent;
padding: 1rem 0;
}

View File

@ -11,7 +11,7 @@ from .flags import *
from .user import *
from .badges import *
from .userblock import *
from .submission import *
from .post import *
from .votes import *
from .domains import *
from .subscriptions import *

View File

@ -14,7 +14,7 @@ class AwardRelationship(Base):
id = Column(Integer, primary_key=True)
user_id = Column(Integer, ForeignKey("users.id"))
submission_id = Column(Integer, ForeignKey("submissions.id"))
post_id = Column(Integer, ForeignKey("posts.id"))
comment_id = Column(Integer, ForeignKey("comments.id"))
kind = Column(String, nullable=False)
awarded_utc = Column(Integer)
@ -22,7 +22,7 @@ class AwardRelationship(Base):
price_paid = Column(Integer, default = 0, nullable=False)
user = relationship("User", primaryjoin="AwardRelationship.user_id==User.id", back_populates="awards")
post = relationship("Submission", primaryjoin="AwardRelationship.submission_id==Submission.id", back_populates="awards")
post = relationship("Post", primaryjoin="AwardRelationship.post_id==Post.id", back_populates="awards")
comment = relationship("Comment", primaryjoin="AwardRelationship.comment_id==Comment.id", back_populates="awards")
def __init__(self, *args, **kwargs):

View File

@ -9,7 +9,7 @@ from files.helpers.config.const import *
from files.helpers.lazy import lazy
from .comment import Comment
from .submission import Submission
from .post import Post
class OauthApp(Base):
__tablename__ = "oauth_apps"

View File

@ -105,7 +105,7 @@ class Comment(Base):
id = Column(Integer, primary_key=True)
author_id = Column(Integer, ForeignKey("users.id"))
parent_submission = Column(Integer, ForeignKey("submissions.id"))
parent_submission = Column(Integer, ForeignKey("posts.id"))
wall_user_id = Column(Integer, ForeignKey("users.id"))
created_utc = Column(Integer)
edited_utc = Column(Integer, default=0)
@ -139,7 +139,7 @@ class Comment(Base):
casino_game_id = Column(Integer, ForeignKey("casino_games.id"))
oauth_app = relationship("OauthApp")
post = relationship("Submission", back_populates="comments")
post = relationship("Post", back_populates="comments")
author = relationship("User", primaryjoin="User.id==Comment.author_id")
senttouser = relationship("User", primaryjoin="User.id==Comment.sentto")
parent_comment = relationship("Comment", remote_side=[id])

View File

@ -11,7 +11,7 @@ from files.helpers.regex import censor_slurs
class Flag(Base):
__tablename__ = "flags"
post_id = Column(Integer, ForeignKey("submissions.id"), primary_key=True)
post_id = Column(Integer, ForeignKey("posts.id"), primary_key=True)
user_id = Column(Integer, ForeignKey("users.id"), primary_key=True)
reason = Column(String)
created_utc = Column(Integer)

View File

@ -16,14 +16,14 @@ class ModAction(Base):
user_id = Column(Integer, ForeignKey("users.id"))
kind = Column(String)
target_user_id = Column(Integer, ForeignKey("users.id"))
target_submission_id = Column(Integer, ForeignKey("submissions.id"))
target_post_id = Column(Integer, ForeignKey("posts.id"))
target_comment_id = Column(Integer, ForeignKey("comments.id"))
_note=Column(String)
created_utc = Column(Integer)
user = relationship("User", primaryjoin="User.id==ModAction.user_id")
target_user = relationship("User", primaryjoin="User.id==ModAction.target_user_id")
target_post = relationship("Submission")
target_post = relationship("Post")
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())

View File

@ -7,17 +7,17 @@ from sqlalchemy.sql.sqltypes import *
from files.classes import Base
from files.helpers.lazy import lazy
class SubmissionOption(Base):
__tablename__ = "submission_options"
class PostOption(Base):
__tablename__ = "post_options"
id = Column(Integer, primary_key=True)
parent_id = Column(Integer, ForeignKey("submissions.id"))
parent_id = Column(Integer, ForeignKey("posts.id"))
body_html = Column(Text)
exclusive = Column(Integer)
created_utc = Column(Integer)
votes = relationship("SubmissionOptionVote")
parent = relationship("Submission", back_populates="options")
votes = relationship("PostOptionVote")
parent = relationship("Post", back_populates="options")
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
@ -37,14 +37,14 @@ class SubmissionOption(Base):
return v.id in [x.user_id for x in self.votes]
class SubmissionOptionVote(Base):
class PostOptionVote(Base):
__tablename__ = "submission_option_votes"
__tablename__ = "post_option_votes"
option_id = Column(Integer, ForeignKey("submission_options.id"), primary_key=True)
option_id = Column(Integer, ForeignKey("post_options.id"), primary_key=True)
user_id = Column(Integer, ForeignKey("users.id"), primary_key=True)
created_utc = Column(Integer)
submission_id = Column(Integer, ForeignKey("submissions.id"))
post_id = Column(Integer, ForeignKey("posts.id"))
user = relationship("User")

View File

@ -19,8 +19,8 @@ from .sub import *
from .subscriptions import *
from .saves import SaveRelationship
class Submission(Base):
__tablename__ = "submissions"
class Post(Base):
__tablename__ = "posts"
id = Column(Integer, primary_key=True)
author_id = Column(Integer, ForeignKey("users.id"))
@ -60,14 +60,14 @@ class Submission(Base):
new = Column(Boolean)
notify = Column(Boolean)
author = relationship("User", primaryjoin="Submission.author_id==User.id")
author = relationship("User", primaryjoin="Post.author_id==User.id")
oauth_app = relationship("OauthApp")
approved_by = relationship("User", uselist=False, primaryjoin="Submission.is_approved==User.id")
approved_by = relationship("User", uselist=False, primaryjoin="Post.is_approved==User.id")
awards = relationship("AwardRelationship", order_by="AwardRelationship.awarded_utc.desc()", back_populates="post")
flags = relationship("Flag", order_by="Flag.created_utc")
comments = relationship("Comment", primaryjoin="Comment.parent_submission==Submission.id", back_populates="post")
subr = relationship("Sub", primaryjoin="foreign(Submission.sub)==remote(Sub.name)")
options = relationship("SubmissionOption", order_by="SubmissionOption.id")
comments = relationship("Comment", primaryjoin="Comment.parent_submission==Post.id", back_populates="post")
subr = relationship("Sub", primaryjoin="foreign(Post.sub)==remote(Sub.name)")
options = relationship("PostOption", order_by="PostOption.id")
bump_utc = deferred(Column(Integer, server_default=FetchedValue()))
@ -372,9 +372,9 @@ class Submission(Base):
@property
@lazy
def num_subscribers(self):
return g.db.query(Subscription).filter_by(submission_id=self.id).count()
return g.db.query(Subscription).filter_by(post_id=self.id).count()
@property
@lazy
def num_savers(self):
return g.db.query(SaveRelationship).filter_by(submission_id=self.id).count()
return g.db.query(SaveRelationship).filter_by(post_id=self.id).count()

View File

@ -10,17 +10,17 @@ class SaveRelationship(Base):
__tablename__="save_relationship"
user_id=Column(Integer, ForeignKey("users.id"), primary_key=True)
submission_id=Column(Integer, ForeignKey("submissions.id"), primary_key=True)
post_id=Column(Integer, ForeignKey("posts.id"), primary_key=True)
created_utc = Column(Integer)
post = relationship("Submission", uselist=False)
post = relationship("Post", uselist=False)
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"<{self.__class__.__name__}(user_id={self.user_id}, submission_id={self.submission_id})>"
return f"<{self.__class__.__name__}(user_id={self.user_id}, post_id={self.post_id})>"
class CommentSaveRelationship(Base):

View File

@ -17,14 +17,14 @@ class SubAction(Base):
user_id = Column(Integer, ForeignKey("users.id"))
kind = Column(String)
target_user_id = Column(Integer, ForeignKey("users.id"))
target_submission_id = Column(Integer, ForeignKey("submissions.id"))
target_post_id = Column(Integer, ForeignKey("posts.id"))
target_comment_id = Column(Integer, ForeignKey("comments.id"))
_note=Column(String)
created_utc = Column(Integer)
user = relationship("User", primaryjoin="User.id==SubAction.user_id")
target_user = relationship("User", primaryjoin="User.id==SubAction.target_user_id")
target_post = relationship("Submission")
target_post = relationship("Post")
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())

View File

@ -9,11 +9,11 @@ from files.classes import Base
class Subscription(Base):
__tablename__ = "subscriptions"
user_id = Column(Integer, ForeignKey("users.id"), primary_key=True)
submission_id = Column(Integer, ForeignKey("submissions.id"), primary_key=True)
post_id = Column(Integer, ForeignKey("posts.id"), primary_key=True)
created_utc = Column(Integer)
user = relationship("User", uselist=False)
post = relationship("Submission", uselist=False)
post = relationship("Post", uselist=False)
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())

View File

@ -460,10 +460,10 @@ class User(Base):
return self.offsitementions or self.admin_level >= PERMS['NOTIFICATIONS_REDDIT']
@lazy
def can_edit(self, target:Union[Submission, Comment]) -> bool:
def can_edit(self, target:Union[Post, Comment]) -> bool:
if isinstance(target, Comment) and not target.post: return False
if self.id == target.author_id: return True
if not isinstance(target, Submission): return False
if not isinstance(target, Post): return False
return bool(self.admin_level >= PERMS['POST_EDITING'])
@property
@ -475,7 +475,7 @@ class User(Base):
return_value.append(HOUSE_AWARDS[self.house])
awards_owned = g.db.query(AwardRelationship.kind, func.count()) \
.filter_by(user_id=self.id, submission_id=None, comment_id=None) \
.filter_by(user_id=self.id, post_id=None, comment_id=None) \
.group_by(AwardRelationship.kind).all()
awards_owned = dict(awards_owned)
@ -603,7 +603,7 @@ class User(Base):
awards = {}
post_awards = g.db.query(AwardRelationship).join(AwardRelationship.post).filter(Submission.author_id == self.id).all()
post_awards = g.db.query(AwardRelationship).join(AwardRelationship.post).filter(Post.author_id == self.id).all()
comment_awards = g.db.query(AwardRelationship).join(AwardRelationship.comment).filter(Comment.author_id == self.id).all()
total_awards = post_awards + comment_awards
@ -687,19 +687,19 @@ class User(Base):
@property
@lazy
def post_notifications_count(self):
return g.db.query(Submission).filter(
return g.db.query(Post).filter(
or_(
Submission.author_id.in_(self.followed_users),
Submission.sub.in_(self.followed_subs)
Post.author_id.in_(self.followed_users),
Post.sub.in_(self.followed_subs)
),
Submission.created_utc > self.last_viewed_post_notifs,
Submission.deleted_utc == 0,
Submission.is_banned == False,
Submission.private == False,
Submission.notify == True,
Submission.author_id != self.id,
Submission.ghost == False,
Submission.author_id.notin_(self.userblocks)
Post.created_utc > self.last_viewed_post_notifs,
Post.deleted_utc == 0,
Post.is_banned == False,
Post.private == False,
Post.notify == True,
Post.author_id != self.id,
Post.ghost == False,
Post.author_id.notin_(self.userblocks)
).count()
@property
@ -932,9 +932,9 @@ class User(Base):
def get_relationship_count(self, relationship_cls):
# TODO: deduplicate (see routes/users.py)
if relationship_cls in {SaveRelationship, Subscription}:
query = relationship_cls.submission_id
query = relationship_cls.post_id
join = relationship_cls.post
cls = Submission
cls = Post
elif relationship_cls is CommentSaveRelationship:
query = relationship_cls.comment_id
join = relationship_cls.comment
@ -950,7 +950,7 @@ class User(Base):
@property
@lazy
def saved_idlist(self):
posts = g.db.query(SaveRelationship.submission_id).filter_by(user_id=self.id).all()
posts = g.db.query(SaveRelationship.post_id).filter_by(user_id=self.id).all()
return [x[0] for x in posts]
@property
@ -962,7 +962,7 @@ class User(Base):
@property
@lazy
def subscribed_idlist(self):
posts = g.db.query(Subscription.submission_id).filter_by(user_id=self.id).all()
posts = g.db.query(Subscription.post_id).filter_by(user_id=self.id).all()
return [x[0] for x in posts]
@ -1006,14 +1006,14 @@ class User(Base):
return f'{tier_name} - Donates ${tier_money}/month'
@classmethod
def can_see_content(cls, user:Optional["User"], other:Union[Submission, Comment, Sub]) -> bool:
def can_see_content(cls, user:Optional["User"], other:Union[Post, Comment, Sub]) -> bool:
'''
Whether a user can see this item (be it a submission or comment)'s content.
Whether a user can see this item (be it a post or comment)'s content.
If False, they won't be able to view its content.
'''
if not cls.can_see(user, other): return False
if user and user.admin_level >= PERMS["POST_COMMENT_MODERATION"]: return True
if isinstance(other, (Submission, Comment)):
if isinstance(other, (Post, Comment)):
if user and user.id == other.author_id: return True
if other.is_banned: return False
if other.deleted_utc: return False
@ -1023,15 +1023,15 @@ class User(Base):
return True
@classmethod
def can_see(cls, user:Optional["User"], other:Union[Submission, Comment, Sub, "User"]) -> bool:
def can_see(cls, user:Optional["User"], other:Union[Post, Comment, Sub, "User"]) -> bool:
'''
Whether a user can strictly see this item. can_see_content is used where
content of a thing can be hidden from view
'''
if isinstance(other, (Submission, Comment)):
if isinstance(other, (Post, Comment)):
if not cls.can_see(user, other.author): return False
if user and user.id == other.author_id: return True
if isinstance(other, Submission):
if isinstance(other, Post):
if not (user and user.patron) and (other.title.lower().startswith('[paypigs]') or other.title.lower().startswith('[patrons]')):
return False
if other.sub and not cls.can_see(user, other.subr):

View File

@ -10,7 +10,7 @@ from files.helpers.lazy import lazy
class Vote(Base):
__tablename__ = "votes"
submission_id = Column(Integer, ForeignKey("submissions.id"), primary_key=True)
post_id = Column(Integer, ForeignKey("posts.id"), primary_key=True)
user_id = Column(Integer, ForeignKey("users.id"), primary_key=True)
vote_type = Column(Integer)
app_id = Column(Integer, ForeignKey("oauth_apps.id"))
@ -32,7 +32,7 @@ class Vote(Base):
def json(self):
return {
"user_id": self.user_id,
"submission_id": self.submission_id,
"post_id": self.post_id,
"vote_type": self.vote_type,
"user": self.user.json,
}
@ -63,7 +63,7 @@ class CommentVote(Base):
def json(self):
return {
"user_id": self.user_id,
"submission_id": self.submission_id,
"post_id": self.post_id,
"vote_type": self.vote_type,
"user": self.user.json,
}

View File

@ -10,7 +10,7 @@ from flask import g
from files.classes.flags import Flag
from files.classes.mod_logs import ModAction
from files.classes.notifications import Notification
from files.classes.polls import CommentOption, SubmissionOption
from files.classes.polls import CommentOption, PostOption
from files.classes.award import AwardRelationship
from files.helpers.alerts import send_repeatable_notification, push_notif
@ -23,7 +23,7 @@ from files.helpers.sanitize import *
from files.helpers.settings import get_setting
from files.helpers.slots import check_slots_command
post_target_type = Union[Submission, User]
post_target_type = Union[Post, User]
def _archiveorg(url):
try:
@ -51,7 +51,7 @@ def snappy_report(post, reason):
message = f'@Snappy reported [{post.title}]({post.shortlink})\n\n> {reason}'
send_repeatable_notification(post.author_id, message)
def execute_snappy(post:Submission, v:User):
def execute_snappy(post:Post, v:User):
group_members = []
ghost = post.ghost
@ -92,7 +92,7 @@ def execute_snappy(post:Submission, v:User):
if body.startswith(''): body = body[1:]
vote = Vote(user_id=SNAPPY_ID,
vote_type=-1,
submission_id=post.id,
post_id=post.id,
real = True
)
g.db.add(vote)
@ -105,7 +105,7 @@ def execute_snappy(post:Submission, v:User):
if body.startswith(''): body = body[1:]
vote = Vote(user_id=SNAPPY_ID,
vote_type=1,
submission_id=post.id,
post_id=post.id,
real = True
)
g.db.add(vote)
@ -132,7 +132,7 @@ def execute_snappy(post:Submission, v:User):
award_object = AwardRelationship(
user_id=snappy.id,
kind="glowie",
submission_id=post.id,
post_id=post.id,
)
g.db.add(award_object)
@ -256,7 +256,7 @@ def execute_snappy(post:Submission, v:User):
def execute_zozbot(c:Comment, level:int, post_target:post_target_type, v):
if SITE_NAME != 'rDrama': return
posting_to_submission = isinstance(post_target, Submission)
posting_to_submission = isinstance(post_target, Post)
if random.random() >= 0.001: return
c2 = Comment(author_id=ZOZBOT_ID,
parent_submission=post_target.id if posting_to_submission else None,
@ -321,7 +321,7 @@ def execute_zozbot(c:Comment, level:int, post_target:post_target_type, v):
def execute_longpostbot(c:Comment, level:int, body, body_html, post_target:post_target_type, v:User):
if SITE_NAME != 'rDrama': return
posting_to_submission = isinstance(post_target, Submission)
posting_to_submission = isinstance(post_target, Post)
if not len(c.body.split()) >= 200: return
if "</blockquote>" in body_html: return
body = random.choice(LONGPOST_REPLIES)
@ -369,17 +369,17 @@ def execute_antispam_submission_check(title, v, url):
now = int(time.time())
cutoff = now - 60 * 60 * 24
similar_posts = g.db.query(Submission).filter(
Submission.author_id == v.id,
Submission.title.op('<->')(title) < SPAM_SIMILARITY_THRESHOLD,
Submission.created_utc > cutoff
similar_posts = g.db.query(Post).filter(
Post.author_id == v.id,
Post.title.op('<->')(title) < SPAM_SIMILARITY_THRESHOLD,
Post.created_utc > cutoff
).all()
if url:
similar_urls = g.db.query(Submission).filter(
Submission.author_id == v.id,
Submission.url.op('<->')(url) < SPAM_URL_SIMILARITY_THRESHOLD,
Submission.created_utc > cutoff
similar_urls = g.db.query(Post).filter(
Post.author_id == v.id,
Post.url.op('<->')(url) < SPAM_URL_SIMILARITY_THRESHOLD,
Post.created_utc > cutoff
).all()
else: similar_urls = []
@ -400,7 +400,7 @@ def execute_antispam_submission_check(title, v, url):
g.db.add(post)
ma=ModAction(
user_id=AUTOJANNY_ID,
target_submission_id=post.id,
target_post_id=post.id,
kind="ban_post",
_note="Spam"
)
@ -466,7 +466,7 @@ def execute_antispam_comment_check(body:str, v:User):
g.db.commit()
abort(403, "Too much spam!")
def execute_under_siege(v:User, target:Optional[Union[Submission, Comment]], body, kind:str) -> bool:
def execute_under_siege(v:User, target:Optional[Union[Post, Comment]], body, kind:str) -> bool:
if not get_setting("under_siege"): return
if v.shadowbanned: return
if v.admin_level >= PERMS['SITE_BYPASS_UNDER_SIEGE_MODE']: return
@ -486,7 +486,7 @@ def execute_under_siege(v:User, target:Optional[Union[Submission, Comment]], bod
g.db.add(v)
if kind == "report":
if isinstance(target, Submission):
if isinstance(target, Post):
reason = f'report on <a href="{target.permalink}">post</a>'
else:
reason = f'report on <a href="{target.permalink}">comment</a>'
@ -508,7 +508,7 @@ def execute_under_siege(v:User, target:Optional[Union[Submission, Comment]], bod
g.db.add(n)
def execute_lawlz_actions(v:User, p:Submission):
def execute_lawlz_actions(v:User, p:Post):
if v.id != LAWLZ_ID: return
if SITE_NAME != 'rDrama': return
if not FEATURES['PINS']: return
@ -519,18 +519,18 @@ def execute_lawlz_actions(v:User, p:Submission):
ma_1=ModAction(
kind="pin_post",
user_id=AUTOJANNY_ID,
target_submission_id=p.id,
target_post_id=p.id,
_note='for 1 day'
)
ma_2=ModAction(
kind="distinguish_post",
user_id=AUTOJANNY_ID,
target_submission_id=p.id
target_post_id=p.id
)
ma_3=ModAction(
kind="flair_post",
user_id=AUTOJANNY_ID,
target_submission_id=p.id,
target_post_id=p.id,
_note=f'"{p.flair}"'
)
g.db.add(p)
@ -539,7 +539,7 @@ def execute_lawlz_actions(v:User, p:Submission):
g.db.add(ma_3)
def process_poll_options(v:User, target:Union[Submission, Comment]):
def process_poll_options(v:User, target:Union[Post, Comment]):
patterns = [(poll_regex, 0), (choice_regex, 1)]
@ -562,8 +562,8 @@ def process_poll_options(v:User, target:Union[Submission, Comment]):
if len(body) > 500:
abort(400, f"Poll option body too long! (Max 500 characters)")
if isinstance(target, Submission):
cls = SubmissionOption
if isinstance(target, Post):
cls = PostOption
else:
cls = CommentOption

View File

@ -70,10 +70,10 @@ def _sub_inactive_purge_task():
return False
one_week_ago = time.time() - 604800
active_holes = [x[0] for x in g.db.query(Submission.sub).distinct() \
.filter(Submission.sub != None, Submission.created_utc > one_week_ago,
Submission.private == False, Submission.is_banned == False,
Submission.deleted_utc == 0).all()]
active_holes = [x[0] for x in g.db.query(Post.sub).distinct() \
.filter(Post.sub != None, Post.created_utc > one_week_ago,
Post.private == False, Post.is_banned == False,
Post.deleted_utc == 0).all()]
active_holes.extend(['changelog','countryclub','museumofrdrama']) # holes immune from deletion
dead_holes = g.db.query(Sub).filter(Sub.name.notin_(active_holes)).all()
@ -99,7 +99,7 @@ def _sub_inactive_purge_task():
for admin in admins:
send_repeatable_notification(admin, f":marseyrave: /h/{name} has been deleted for inactivity after one week without new posts. All posts in it have been moved to the main feed :marseyrave:")
posts = g.db.query(Submission).filter(Submission.sub.in_(names)).all()
posts = g.db.query(Post).filter(Post.sub.in_(names)).all()
for post in posts:
if post.sub == 'programming':
post.sub = 'slackernews'
@ -158,7 +158,7 @@ def _leaderboard_task():
cache.set("users13_1", list(users13_1))
cache.set("users13_2", list(users13_2))
votes1 = g.db.query(Submission.author_id, func.count(Submission.author_id)).join(Vote).filter(Vote.vote_type==-1).group_by(Submission.author_id).order_by(func.count(Submission.author_id).desc()).all()
votes1 = g.db.query(Post.author_id, func.count(Post.author_id)).join(Vote).filter(Vote.vote_type==-1).group_by(Post.author_id).order_by(func.count(Post.author_id).desc()).all()
votes2 = g.db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote).filter(CommentVote.vote_type==-1).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).all()
votes3 = Counter(dict(votes1)) + Counter(dict(votes2))
users8 = g.db.query(User.id).filter(User.id.in_(votes3.keys())).all()

View File

@ -4,7 +4,7 @@ from flask import *
from sqlalchemy import and_, any_, or_
from sqlalchemy.orm import joinedload, selectinload, Query
from files.classes import Comment, CommentVote, Hat, Sub, Submission, User, UserBlock, Vote
from files.classes import Comment, CommentVote, Hat, Sub, Post, User, UserBlock, Vote
from files.helpers.config.const import *
from files.__main__ import cache
@ -121,7 +121,7 @@ def get_accounts_dict(ids:Union[Iterable[str], Iterable[int]], v:Optional[User]=
if len(users) != len(ids) and not graceful: abort(404)
return {u.id:u for u in users}
def get_post(i:Union[str, int], v:Optional[User]=None, graceful=False) -> Optional[Submission]:
def get_post(i:Union[str, int], v:Optional[User]=None, graceful=False) -> Optional[Post]:
try: i = int(i)
except:
if graceful: return None
@ -132,22 +132,22 @@ def get_post(i:Union[str, int], v:Optional[User]=None, graceful=False) -> Option
else: abort(404)
if v:
vt = g.db.query(Vote).filter_by(user_id=v.id, submission_id=i).subquery()
vt = g.db.query(Vote).filter_by(user_id=v.id, post_id=i).subquery()
blocking = v.blocking.subquery()
post = g.db.query(
Submission,
Post,
vt.c.vote_type,
blocking.c.target_id,
)
post=post.filter(Submission.id == i
post=post.filter(Post.id == i
).outerjoin(
vt,
vt.c.submission_id == Submission.id,
vt.c.post_id == Post.id,
).outerjoin(
blocking,
blocking.c.target_id == Submission.author_id,
blocking.c.target_id == Post.author_id,
)
post=post.one_or_none()
@ -160,7 +160,7 @@ def get_post(i:Union[str, int], v:Optional[User]=None, graceful=False) -> Option
x.voted = post[1] or 0
x.is_blocking = post[2] or 0
else:
post = g.db.get(Submission, i)
post = g.db.get(Post, i)
if not post:
if graceful: return None
else: abort(404)
@ -169,12 +169,12 @@ def get_post(i:Union[str, int], v:Optional[User]=None, graceful=False) -> Option
return x
def get_posts(pids:Iterable[int], v:Optional[User]=None, eager:bool=False, extra:Optional[Callable[[Query], Query]]=None) -> List[Submission]:
def get_posts(pids:Iterable[int], v:Optional[User]=None, eager:bool=False, extra:Optional[Callable[[Query], Query]]=None) -> List[Post]:
if not pids: return []
if v:
vt = g.db.query(Vote.vote_type, Vote.submission_id).filter(
Vote.submission_id.in_(pids),
vt = g.db.query(Vote.vote_type, Vote.post_id).filter(
Vote.post_id.in_(pids),
Vote.user_id==v.id
).subquery()
@ -182,38 +182,38 @@ def get_posts(pids:Iterable[int], v:Optional[User]=None, eager:bool=False, extra
blocked = v.blocked.subquery()
query = g.db.query(
Submission,
Post,
vt.c.vote_type,
blocking.c.target_id,
blocked.c.target_id,
).filter(
Submission.id.in_(pids)
Post.id.in_(pids)
).outerjoin(
vt, vt.c.submission_id==Submission.id
vt, vt.c.post_id==Post.id
).outerjoin(
blocking,
blocking.c.target_id == Submission.author_id,
blocking.c.target_id == Post.author_id,
).outerjoin(
blocked,
blocked.c.user_id == Submission.author_id,
blocked.c.user_id == Post.author_id,
)
else:
query = g.db.query(Submission).filter(Submission.id.in_(pids))
query = g.db.query(Post).filter(Post.id.in_(pids))
if extra: query = extra(query)
if eager:
query = query.options(
selectinload(Submission.author).options(
selectinload(Post.author).options(
selectinload(User.hats_equipped.and_(Hat.equipped == True)) \
.joinedload(Hat.hat_def, innerjoin=True),
selectinload(User.badges),
selectinload(User.sub_mods),
selectinload(User.sub_exiles),
),
selectinload(Submission.flags),
selectinload(Submission.awards),
selectinload(Submission.options),
selectinload(Post.flags),
selectinload(Post.awards),
selectinload(Post.options),
)
results = query.all()
@ -246,16 +246,16 @@ def get_comment(i:Union[str, int], v:Optional[User]=None, graceful=False) -> Opt
return add_vote_and_block_props(comment, v, CommentVote)
def add_block_props(target:Union[Submission, Comment, User], v:Optional[User]):
def add_block_props(target:Union[Post, Comment, User], v:Optional[User]):
if not v: return target
id = None
if any(isinstance(target, cls) for cls in {Submission, Comment}):
if any(isinstance(target, cls) for cls in {Post, Comment}):
id = target.author_id
elif isinstance(target, User):
id = target.id
else:
raise TypeError("add_block_props only supports non-None submissions, comments, and users")
raise TypeError("add_block_props only supports non-None posts, comments, and users")
if hasattr(target, 'is_blocking') and hasattr(target, 'is_blocked'):
return target
@ -281,12 +281,12 @@ def add_block_props(target:Union[Submission, Comment, User], v:Optional[User]):
target.is_blocked = block and block.target_id == v.id
return target
def add_vote_props(target:Union[Submission, Comment], v:Optional[User], vote_cls):
def add_vote_props(target:Union[Post, Comment], v:Optional[User], vote_cls):
if hasattr(target, 'voted'): return target
vt = g.db.query(vote_cls.vote_type).filter_by(user_id=v.id)
if vote_cls == Vote:
vt = vt.filter_by(submission_id=target.id)
vt = vt.filter_by(post_id=target.id)
elif vote_cls == CommentVote:
vt = vt.filter_by(comment_id=target.id)
else:
@ -295,7 +295,7 @@ def add_vote_props(target:Union[Submission, Comment], v:Optional[User], vote_cls
target.voted = vt.vote_type if vt else 0
return target
def add_vote_and_block_props(target:Union[Submission, Comment], v:Optional[User], vote_cls):
def add_vote_and_block_props(target:Union[Post, Comment], v:Optional[User], vote_cls):
if not v: return target
target = add_block_props(target, v)
return add_vote_props(target, v, vote_cls)

View File

@ -33,7 +33,7 @@ def offsite_mentions_task(cache:Cache):
g.db.commit() # commit early otherwise localhost testing fails to commit
def get_mentions(cache:Cache, queries:Iterable[str], reddit_notifs_users=False):
kinds = ['submission', 'comment']
kinds = ['post', 'comment']
mentions = []
exclude_subreddits = ['PokemonGoRaids', 'SubSimulatorGPT2', 'SubSimGPT2Interactive']
try:

View File

@ -690,7 +690,7 @@ def complies_with_chud(obj):
#check for cases where u should leave
if not obj.author.agendaposter: return True
if obj.author.marseyawarded: return True
if isinstance(obj, Submission):
if isinstance(obj, Post):
if obj.id in ADMIGGER_THREADS: return True
if obj.sub == "chudrama": return True
elif obj.parent_submission:
@ -709,7 +709,7 @@ def complies_with_chud(obj):
obj.body_html = str(soup).replace('<html><body>','').replace('</body></html>','')
#torture title_html and check for agendaposter_phrase in plain title and leave if it's there
if isinstance(obj, Submission):
if isinstance(obj, Post):
obj.title_html = torture_ap(obj.title_html, obj.author.username)
if obj.author.agendaposter_phrase in obj.title.lower():
return True

View File

@ -29,25 +29,25 @@ def sort_objects(sort, objects, cls):
if sort == 'hot':
ti = int(time.time()) + 3600
metric = cls.realupvotes
if cls.__name__ == "Submission": metric += cls.comment_count/5
if cls.__name__ == "Post": metric += cls.comment_count/5
return objects.order_by(-1000000*(metric + 1)/(func.power(((ti - cls.created_utc)/1000), 1.35)), cls.created_utc.desc())
elif sort == "views" and cls.__name__ == "Submission":
elif sort == "views" and cls.__name__ == "Post":
return objects.order_by(cls.views.desc(), cls.created_utc.desc())
elif sort == "bump" and cls.__name__ == "Submission":
elif sort == "bump" and cls.__name__ == "Post":
return objects.filter(cls.comment_count > 1).order_by(cls.bump_utc.desc(), cls.created_utc.desc())
elif sort == "comments" and cls.__name__ == "Submission":
elif sort == "comments" and cls.__name__ == "Post":
return objects.order_by(cls.comment_count.desc(), cls.created_utc.desc())
elif sort == "subscriptions" and cls.__name__ == "Submission":
return objects.outerjoin(Subscription, Subscription.submission_id == cls.id).group_by(cls.id).order_by(func.count(Subscription.submission_id).desc(), cls.created_utc.desc())
elif sort == "saves" and cls.__name__ == "Submission":
return objects.outerjoin(SaveRelationship, SaveRelationship.submission_id == cls.id).group_by(cls.id).order_by(func.count(SaveRelationship.submission_id).desc(), cls.created_utc.desc())
elif sort == "subscriptions" and cls.__name__ == "Post":
return objects.outerjoin(Subscription, Subscription.post_id == cls.id).group_by(cls.id).order_by(func.count(Subscription.post_id).desc(), cls.created_utc.desc())
elif sort == "saves" and cls.__name__ == "Post":
return objects.outerjoin(SaveRelationship, SaveRelationship.post_id == cls.id).group_by(cls.id).order_by(func.count(SaveRelationship.post_id).desc(), cls.created_utc.desc())
elif sort == "saves" and cls.__name__ == "Comment":
return objects.outerjoin(CommentSaveRelationship, CommentSaveRelationship.comment_id == cls.id).group_by(cls.id).order_by(func.count(CommentSaveRelationship.comment_id).desc(), cls.created_utc.desc())
elif sort == "new":
return objects.order_by(cls.created_utc.desc())
elif sort == "old":
return objects.order_by(cls.created_utc)
elif sort == "controversial" and cls.__name__ == "Submission":
elif sort == "controversial" and cls.__name__ == "Post":
return objects.order_by((cls.upvotes+1)/(cls.downvotes+1) + (cls.downvotes+1)/(cls.upvotes+1) - cls.comment_count/500, cls.downvotes.desc(), cls.created_utc.desc())
elif sort == "controversial":
return objects.order_by((cls.upvotes+1)/(cls.downvotes+1) + (cls.downvotes+1)/(cls.upvotes+1), cls.downvotes.desc(), cls.created_utc.desc())

View File

@ -5,7 +5,7 @@ import matplotlib.pyplot as plt
from sqlalchemy import *
from files.classes.user import User
from files.classes.submission import Submission
from files.classes.post import Post
from files.classes.comment import Comment
from files.classes.votes import Vote, CommentVote
from files.classes.emoji import *
@ -42,10 +42,10 @@ def chart(kind, site):
User.created_utc > day_cutoffs[i + 1]).count()
for i in range(len(day_cutoffs) - 1)][::-1]
post_stats = [g.db.query(Submission).filter(
Submission.created_utc < day_cutoffs[i],
Submission.created_utc > day_cutoffs[i + 1],
Submission.is_banned == False).count()
post_stats = [g.db.query(Post).filter(
Post.created_utc < day_cutoffs[i],
Post.created_utc > day_cutoffs[i + 1],
Post.is_banned == False).count()
for i in range(len(day_cutoffs) - 1)][::-1]
comment_stats = [g.db.query(Comment).filter(
@ -89,7 +89,7 @@ def stats():
now = time.time()
day = int(now) - 86400
week = int(now) - 604800
posters = g.db.query(Submission.author_id).distinct(Submission.author_id).filter(Submission.created_utc > week).all()
posters = g.db.query(Post.author_id).distinct(Post.author_id).filter(Post.created_utc > week).all()
commenters = g.db.query(Comment.author_id).distinct(Comment.author_id).filter(Comment.created_utc > week).all()
voters = g.db.query(Vote.user_id).distinct(Vote.user_id).filter(Vote.created_utc > week).all()
commentvoters = g.db.query(CommentVote.user_id).distinct(CommentVote.user_id).filter(CommentVote.created_utc > week).all()
@ -105,12 +105,12 @@ def stats():
"coins in circulation": "{:,}".format(g.db.query(func.sum(User.coins)).scalar()),
"total shop sales": "{:,}".format(g.db.query(func.sum(User.coins_spent)).scalar()),
"signups last 24h": "{:,}".format(g.db.query(User).filter(User.created_utc > day).count()),
"total posts": "{:,}".format(g.db.query(Submission).count()),
"posting users": "{:,}".format(g.db.query(Submission.author_id).distinct().count()),
"listed posts": "{:,}".format(g.db.query(Submission).filter_by(is_banned=False).filter(Submission.deleted_utc == 0).count()),
"removed posts (by admins)": "{:,}".format(g.db.query(Submission).filter_by(is_banned=True).count()),
"deleted posts (by author)": "{:,}".format(g.db.query(Submission).filter(Submission.deleted_utc > 0).count()),
"posts last 24h": "{:,}".format(g.db.query(Submission).filter(Submission.created_utc > day).count()),
"total posts": "{:,}".format(g.db.query(Post).count()),
"posting users": "{:,}".format(g.db.query(Post.author_id).distinct().count()),
"listed posts": "{:,}".format(g.db.query(Post).filter_by(is_banned=False).filter(Post.deleted_utc == 0).count()),
"removed posts (by admins)": "{:,}".format(g.db.query(Post).filter_by(is_banned=True).count()),
"deleted posts (by author)": "{:,}".format(g.db.query(Post).filter(Post.deleted_utc > 0).count()),
"posts last 24h": "{:,}".format(g.db.query(Post).filter(Post.created_utc > day).count()),
"total comments": "{:,}".format(g.db.query(Comment).filter(Comment.author_id != AUTOJANNY_ID).count()),
"commenting users": "{:,}".format(g.db.query(Comment.author_id).distinct().count()),
"removed comments (by admins)": "{:,}".format(g.db.query(Comment).filter_by(is_banned=True).count()),
@ -121,7 +121,7 @@ def stats():
"total upvotes": "{:,}".format(g.db.query(Vote).filter_by(vote_type=1).count() + g.db.query(CommentVote).filter_by(vote_type=1).count()),
"total downvotes": "{:,}".format(g.db.query(Vote).filter_by(vote_type=-1).count() + g.db.query(CommentVote).filter_by(vote_type=-1).count()),
"total awards": "{:,}".format(g.db.query(AwardRelationship).count()),
"awards given": "{:,}".format(g.db.query(AwardRelationship).filter(or_(AwardRelationship.submission_id != None, AwardRelationship.comment_id != None)).count()),
"awards given": "{:,}".format(g.db.query(AwardRelationship).filter(or_(AwardRelationship.post_id != None, AwardRelationship.comment_id != None)).count()),
"users who posted, commented, or voted in the past 7 days": "{:,}".format(len(active_users)),
"users online in the past 7 days": "{:,}".format(g.db.query(User).filter(User.last_active > week).count()),
}

View File

@ -163,7 +163,7 @@ def distribute(v:User, kind, option_id):
try: option_id = int(option_id)
except: abort(400)
if kind == 'post': cls = SubmissionOption
if kind == 'post': cls = PostOption
else: cls = CommentOption
option = g.db.get(cls, option_id)
@ -203,11 +203,11 @@ def distribute(v:User, kind, option_id):
for uid in losing_voters:
add_notif(cid, uid, text)
if isinstance(parent, Submission):
if isinstance(parent, Post):
ma = ModAction(
kind="distribute",
user_id=v.id,
target_submission_id=parent.id
target_post_id=parent.id
)
else:
ma = ModAction(
@ -241,8 +241,8 @@ def revert_actions(v:User, username):
cutoff = int(time.time()) - 86400
posts = [x[0] for x in g.db.query(ModAction.target_submission_id).filter(ModAction.user_id == revertee.id, ModAction.created_utc > cutoff, ModAction.kind == 'ban_post').all()]
posts = g.db.query(Submission).filter(Submission.id.in_(posts)).all()
posts = [x[0] for x in g.db.query(ModAction.target_post_id).filter(ModAction.user_id == revertee.id, ModAction.created_utc > cutoff, ModAction.kind == 'ban_post').all()]
posts = g.db.query(Post).filter(Post.id.in_(posts)).all()
comments = [x[0] for x in g.db.query(ModAction.target_comment_id).filter(ModAction.user_id == revertee.id, ModAction.created_utc > cutoff, ModAction.kind == 'ban_comment').all()]
comments = g.db.query(Comment).filter(Comment.id.in_(comments)).all()
@ -299,9 +299,9 @@ def image_posts_listing(v):
try: page = int(request.values.get('page', 1))
except: page = 1
posts = g.db.query(Submission).options(
load_only(Submission.id, Submission.url)
).order_by(Submission.id.desc())
posts = g.db.query(Post).options(
load_only(Post.id, Post.url)
).order_by(Post.id.desc())
posts = [x.id for x in posts if x.is_image]
@ -323,15 +323,15 @@ def image_posts_listing(v):
def reported_posts(v):
page = get_page()
listing = g.db.query(Submission).options(load_only(Submission.id)).filter_by(
listing = g.db.query(Post).options(load_only(Post.id)).filter_by(
is_approved=None,
is_banned=False,
deleted_utc=0
).join(Submission.flags)
).join(Post.flags)
total = listing.count()
listing = listing.order_by(Submission.id.desc()).offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE)
listing = listing.order_by(Post.id.desc()).offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE)
listing = [p.id for p in listing]
listing = get_posts(listing, v=v)
@ -566,11 +566,11 @@ def alt_votes_get(v):
u2 = get_user(u2)
u1_post_ups = g.db.query(
Vote.submission_id).filter_by(
Vote.post_id).filter_by(
user_id=u1.id,
vote_type=1).all()
u1_post_downs = g.db.query(
Vote.submission_id).filter_by(
Vote.post_id).filter_by(
user_id=u1.id,
vote_type=-1).all()
u1_comment_ups = g.db.query(
@ -582,11 +582,11 @@ def alt_votes_get(v):
user_id=u1.id,
vote_type=-1).all()
u2_post_ups = g.db.query(
Vote.submission_id).filter_by(
Vote.post_id).filter_by(
user_id=u2.id,
vote_type=1).all()
u2_post_downs = g.db.query(
Vote.submission_id).filter_by(
Vote.post_id).filter_by(
user_id=u2.id,
vote_type=-1).all()
u2_comment_ups = g.db.query(
@ -735,11 +735,11 @@ def admin_delink_relink_alt(v:User, username, other):
def admin_removed(v):
page = get_page()
listing = g.db.query(Submission).options(load_only(Submission.id)).join(Submission.author).filter(
or_(Submission.is_banned==True, User.shadowbanned != None))
listing = g.db.query(Post).options(load_only(Post.id)).join(Post.author).filter(
or_(Post.is_banned==True, User.shadowbanned != None))
total = listing.count()
listing = listing.order_by(Submission.id.desc()).offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE).all()
listing = listing.order_by(Post.id.desc()).offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE).all()
listing = [x.id for x in listing]
posts = get_posts(listing, v=v)
@ -786,7 +786,7 @@ def unagendaposter(id, v):
if id.startswith('p_'):
post_id = id.split('p_')[1]
post = g.db.get(Submission, post_id)
post = g.db.get(Post, post_id)
user = post.author
elif id.startswith('c_'):
comment_id = id.split('c_')[1]
@ -942,7 +942,7 @@ def ban_user(id, v):
if id.startswith('p_'):
post_id = id.split('p_')[1]
post = g.db.get(Submission, post_id)
post = g.db.get(Post, post_id)
user = post.author
elif id.startswith('c_'):
comment_id = id.split('c_')[1]
@ -1037,7 +1037,7 @@ def agendaposter(id, v):
if id.startswith('p_'):
post_id = id.split('p_')[1]
post = g.db.get(Submission, post_id)
post = g.db.get(Post, post_id)
user = post.author
elif id.startswith('c_'):
comment_id = id.split('c_')[1]
@ -1140,7 +1140,7 @@ def unban_user(id, v):
if id.startswith('p_'):
post_id = id.split('p_')[1]
post = g.db.get(Submission, post_id)
post = g.db.get(Post, post_id)
user = post.author
elif id.startswith('c_'):
comment_id = id.split('c_')[1]
@ -1236,7 +1236,7 @@ def progstack_post(post_id, v):
ma=ModAction(
kind="progstack_post",
user_id=v.id,
target_submission_id=post.id,
target_post_id=post.id,
)
g.db.add(ma)
@ -1257,7 +1257,7 @@ def unprogstack_post(post_id, v):
ma=ModAction(
kind="unprogstack_post",
user_id=v.id,
target_submission_id=post.id,
target_post_id=post.id,
)
g.db.add(ma)
@ -1324,7 +1324,7 @@ def remove_post(post_id, v):
ma=ModAction(
kind="ban_post",
user_id=v.id,
target_submission_id=post.id,
target_post_id=post.id,
)
g.db.add(ma)
@ -1352,7 +1352,7 @@ def approve_post(post_id, v):
ma=ModAction(
kind="unban_post",
user_id=v.id,
target_submission_id=post.id,
target_post_id=post.id,
)
g.db.add(ma)
@ -1391,7 +1391,7 @@ def distinguish_post(post_id, v):
ma = ModAction(
kind=kind,
user_id=v.id,
target_submission_id=post.id
target_post_id=post.id
)
g.db.add(ma)
@ -1416,7 +1416,7 @@ def sticky_post(post_id, v):
if FEATURES['AWARDS'] and post.stickied and post.stickied.endswith(PIN_AWARD_TEXT) and v.admin_level < PERMS["UNDO_AWARD_PINS"]:
abort(403, "Can't pin award pins!")
pins = g.db.query(Submission).filter(Submission.stickied != None, Submission.is_banned == False).count()
pins = g.db.query(Post).filter(Post.stickied != None, Post.is_banned == False).count()
if not post.stickied_utc:
post.stickied_utc = int(time.time()) + 3600
@ -1438,7 +1438,7 @@ def sticky_post(post_id, v):
ma=ModAction(
kind="pin_post",
user_id=v.id,
target_submission_id=post.id,
target_post_id=post.id,
_note=pin_time
)
g.db.add(ma)
@ -1470,7 +1470,7 @@ def unsticky_post(post_id, v):
ma=ModAction(
kind="unpin_post",
user_id=v.id,
target_submission_id=post.id
target_post_id=post.id
)
g.db.add(ma)
@ -1711,7 +1711,7 @@ def admin_nuke_user(v):
user=get_user(request.values.get("user"))
for post in g.db.query(Submission).filter_by(author_id=user.id).all():
for post in g.db.query(Post).filter_by(author_id=user.id).all():
if post.is_banned:
continue
@ -1747,7 +1747,7 @@ def admin_nunuke_user(v):
user=get_user(request.values.get("user"))
for post in g.db.query(Submission).filter_by(author_id=user.id).all():
for post in g.db.query(Post).filter_by(author_id=user.id).all():
if not post.is_banned:
continue

View File

@ -39,7 +39,7 @@ def shop(v:User):
for val in AWARDS.values(): val["owned"] = 0
for useraward in g.db.query(AwardRelationship).filter(AwardRelationship.user_id == v.id, AwardRelationship.submission_id == None, AwardRelationship.comment_id == None).all():
for useraward in g.db.query(AwardRelationship).filter(AwardRelationship.user_id == v.id, AwardRelationship.post_id == None, AwardRelationship.comment_id == None).all():
if useraward.kind in AWARDS: AWARDS[useraward.kind]["owned"] += 1
for val in AWARDS.values():
@ -160,13 +160,13 @@ def award_thing(v, thing_type, id):
award = g.db.query(AwardRelationship).filter(
AwardRelationship.kind == kind,
AwardRelationship.user_id == v.id,
AwardRelationship.submission_id == None,
AwardRelationship.post_id == None,
AwardRelationship.comment_id == None
).first()
if not award: abort(404, "You don't have that award")
if thing_type == 'post': award.submission_id = thing.id
if thing_type == 'post': award.post_id = thing.id
else: award.comment_id = thing.id
award.awarded_utc = int(time.time())

View File

@ -76,8 +76,8 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None):
if v and v.client: return top_comment.json(db=g.db)
else:
if post.is_banned and not (v and (v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or post.author_id == v.id)): template = "submission_banned.html"
else: template = "submission.html"
if post.is_banned and not (v and (v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or post.author_id == v.id)): template = "post_banned.html"
else: template = "post.html"
return render_template(template, v=v, p=post, sort=sort, comment_info=comment_info, render_replies=True, sub=post.subr)
@app.post("/comment")
@ -128,20 +128,20 @@ def comment(v:User):
post_target = get_post(parent.parent_submission, v=v, graceful=True) or get_account(parent.wall_user_id, v=v, include_blocks=True)
parent_comment_id = parent.id
if parent.author_id == v.id: rts = True
if not v.can_post_in_ghost_threads and isinstance(post_target, Submission) and post_target.ghost:
if not v.can_post_in_ghost_threads and isinstance(post_target, Post) and post_target.ghost:
abort(403, f"You need {TRUESCORE_GHOST_MINIMUM} truescore to post in ghost threads")
ghost = parent.ghost
else: abort(404)
level = 1 if isinstance(parent, (Submission, User)) else int(parent.level) + 1
level = 1 if isinstance(parent, (Post, User)) else int(parent.level) + 1
parent_user = parent if isinstance(parent, User) else parent.author
posting_to_submission = isinstance(post_target, Submission)
posting_to_submission = isinstance(post_target, Post)
if not User.can_see(v, parent): abort(403)
if not isinstance(parent, User) and parent.deleted_utc != 0:
if isinstance(parent, Submission):
if isinstance(parent, Post):
abort(403, "You can't reply to deleted posts!")
else:
abort(403, "You can't reply to deleted comments!")
@ -333,7 +333,7 @@ def comment(v:User):
push_notif(notify_users, f'New mention of you by @{c.author_name}', c.body, c)
if c.level == 1 and posting_to_submission:
subscriber_ids = [x[0] for x in g.db.query(Subscription.user_id).filter(Subscription.submission_id == post_target.id, Subscription.user_id != v.id).all()]
subscriber_ids = [x[0] for x in g.db.query(Subscription.user_id).filter(Subscription.post_id == post_target.id, Subscription.user_id != v.id).all()]
notify_users.update(subscriber_ids)

View File

@ -2,7 +2,7 @@
from sqlalchemy import or_, not_
from sqlalchemy.orm import load_only
from files.classes.submission import Submission
from files.classes.post import Post
from files.classes.votes import Vote
from files.helpers.config.const import *
from files.helpers.get import *
@ -72,48 +72,48 @@ LIMITED_WPD_HOLES = ('gore', 'aftermath', 'selfharm', 'meta', 'discussion', 'soc
@cache.memoize()
def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='', gt=0, lt=0, sub=None, pins=True):
posts = g.db.query(Submission)
posts = g.db.query(Post)
if v and v.hidevotedon:
posts = posts.outerjoin(Vote,
and_(Vote.submission_id == Submission.id, Vote.user_id == v.id)
).filter(Vote.submission_id == None)
and_(Vote.post_id == Post.id, Vote.user_id == v.id)
).filter(Vote.post_id == None)
if sub: posts = posts.filter(Submission.sub == sub.name)
elif v: posts = posts.filter(or_(Submission.sub == None, Submission.sub.notin_(v.all_blocks)))
if sub: posts = posts.filter(Post.sub == sub.name)
elif v: posts = posts.filter(or_(Post.sub == None, Post.sub.notin_(v.all_blocks)))
if gt: posts = posts.filter(Submission.created_utc > gt)
if lt: posts = posts.filter(Submission.created_utc < lt)
if gt: posts = posts.filter(Post.created_utc > gt)
if lt: posts = posts.filter(Post.created_utc < lt)
if not gt and not lt:
posts = apply_time_filter(t, posts, Submission)
posts = apply_time_filter(t, posts, Post)
posts = posts.filter(
Submission.is_banned == False,
Submission.private == False,
Submission.deleted_utc == 0,
Post.is_banned == False,
Post.private == False,
Post.deleted_utc == 0,
)
if pins and not gt and not lt:
if sub: posts = posts.filter(Submission.hole_pinned == None)
else: posts = posts.filter(Submission.stickied == None)
if sub: posts = posts.filter(Post.hole_pinned == None)
else: posts = posts.filter(Post.stickied == None)
if v:
posts = posts.filter(Submission.author_id.notin_(v.userblocks))
posts = posts.filter(Post.author_id.notin_(v.userblocks))
if v and filter_words:
for word in filter_words:
word = word.replace('\\', '').replace('_', '\_').replace('%', '\%').strip()
posts=posts.filter(not_(Submission.title.ilike(f'%{word}%')))
posts=posts.filter(not_(Post.title.ilike(f'%{word}%')))
total = posts.count()
posts = sort_objects(sort, posts, Submission)
posts = sort_objects(sort, posts, Post)
if v: size = v.frontsize or 0
else: size = PAGE_SIZE
posts = posts.options(load_only(Submission.id)).offset(size * (page - 1))
posts = posts.options(load_only(Post.id)).offset(size * (page - 1))
if SITE_NAME == 'WPD' and sort == "hot" and sub == None:
posts = posts.limit(200).all()
@ -128,12 +128,12 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
if pins and page == 1 and not gt and not lt:
if sub:
pins = g.db.query(Submission).options(load_only(Submission.id)).filter(Submission.sub == sub.name, Submission.hole_pinned != None)
pins = g.db.query(Post).options(load_only(Post.id)).filter(Post.sub == sub.name, Post.hole_pinned != None)
else:
pins = g.db.query(Submission).options(load_only(Submission.id)).filter(Submission.stickied != None, Submission.is_banned == False)
pins = g.db.query(Post).options(load_only(Post.id)).filter(Post.stickied != None, Post.is_banned == False)
if v:
pins = pins.filter(or_(Submission.sub == None, Submission.sub.notin_(v.all_blocks)))
pins = pins.filter(or_(Post.sub == None, Post.sub.notin_(v.all_blocks)))
for pin in pins:
if pin.stickied_utc and int(time.time()) > pin.stickied_utc:
pin.stickied = None
@ -141,10 +141,10 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
g.db.add(pin)
if v: pins = pins.filter(Submission.author_id.notin_(v.userblocks))
if v: pins = pins.filter(Post.author_id.notin_(v.userblocks))
if SITE_NAME == 'rDrama':
pins = pins.order_by(Submission.author_id != LAWLZ_ID)
pins = pins.order_by(Submission.created_utc.desc()).all()
pins = pins.order_by(Post.author_id != LAWLZ_ID)
pins = pins.order_by(Post.created_utc.desc()).all()
posts = pins + posts
if v and (time.time() - v.created_utc) > (365 * 86400 - 1):
@ -163,7 +163,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
@auth_required
def random_post(v:User):
p = g.db.query(Submission.id).filter(Submission.deleted_utc == 0, Submission.is_banned == False, Submission.private == False).order_by(func.random()).first()
p = g.db.query(Post.id).filter(Post.deleted_utc == 0, Post.is_banned == False, Post.private == False).order_by(func.random()).first()
if p: p = p[0]
else: abort(404)
@ -197,7 +197,7 @@ def comment_idlist(v=None, page=1, sort="new", t="day", gt=0, lt=0):
Comment.is_banned == False,
Comment.deleted_utc == 0,
Comment.author_id.notin_(v.userblocks),
or_(Comment.parent_submission == None, Submission.private == False),
or_(Comment.parent_submission == None, Post.private == False),
)
if gt: comments = comments.filter(Comment.created_utc > gt)

View File

@ -30,7 +30,7 @@ def post_embed(id, v):
from files.helpers.get import get_post
p = get_post(id, v, graceful=True)
if p: return render_template("submission_listing.html", listing=[p], v=v)
if p: return render_template("post_listing.html", listing=[p], v=v)
return ''
@app.template_filter("asset")

View File

@ -160,23 +160,23 @@ def notifications_messages(v:User):
def notifications_posts(v:User):
page = get_page()
listing = g.db.query(Submission).filter(
listing = g.db.query(Post).filter(
or_(
Submission.author_id.in_(v.followed_users),
Submission.sub.in_(v.followed_subs)
Post.author_id.in_(v.followed_users),
Post.sub.in_(v.followed_subs)
),
Submission.deleted_utc == 0,
Submission.is_banned == False,
Submission.private == False,
Submission.notify == True,
Submission.author_id != v.id,
Submission.ghost == False,
Submission.author_id.notin_(v.userblocks)
).options(load_only(Submission.id))
Post.deleted_utc == 0,
Post.is_banned == False,
Post.private == False,
Post.notify == True,
Post.author_id != v.id,
Post.ghost == False,
Post.author_id.notin_(v.userblocks)
).options(load_only(Post.id))
total = listing.count()
listing = listing.order_by(Submission.created_utc.desc()).offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE).all()
listing = listing.order_by(Post.created_utc.desc()).offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE).all()
listing = [x.id for x in listing]
listing = get_posts(listing, v=v, eager=True)

View File

@ -253,7 +253,7 @@ def admin_app_id_posts(v, aid):
page = get_page()
pids, total = oauth.idlist(Submission, page=page)
pids, total = oauth.idlist(Post, page=page)
posts = get_posts(pids, v=v)

View File

@ -16,7 +16,7 @@ def vote_option(option_id, v):
option_id = int(option_id)
except:
abort(404)
option = g.db.get(SubmissionOption, option_id)
option = g.db.get(PostOption, option_id)
if not option: abort(404)
sub = option.parent.sub
@ -34,21 +34,21 @@ def vote_option(option_id, v):
g.db.add(autojanny)
if option.exclusive:
vote = g.db.query(SubmissionOptionVote).join(SubmissionOption).filter(
SubmissionOptionVote.user_id==v.id,
SubmissionOptionVote.submission_id==option.parent_id,
SubmissionOption.exclusive==option.exclusive).all()
vote = g.db.query(PostOptionVote).join(PostOption).filter(
PostOptionVote.user_id==v.id,
PostOptionVote.post_id==option.parent_id,
PostOption.exclusive==option.exclusive).all()
if vote:
if option.exclusive == 2: abort(400, "You already voted on this bet!")
for x in vote:
g.db.delete(x)
existing = g.db.query(SubmissionOptionVote).filter_by(option_id=option_id, user_id=v.id).one_or_none()
existing = g.db.query(PostOptionVote).filter_by(option_id=option_id, user_id=v.id).one_or_none()
if not existing:
vote = SubmissionOptionVote(
vote = PostOptionVote(
option_id=option_id,
user_id=v.id,
submission_id=option.parent_id,
post_id=option.parent_id,
)
g.db.add(vote)
elif existing and not option.exclusive:
@ -121,15 +121,15 @@ def option_votes(option_id, v):
option_id = int(option_id)
except:
abort(404)
option = g.db.get(SubmissionOption, option_id)
option = g.db.get(PostOption, option_id)
if not option: abort(404)
if option.parent.ghost and v.admin_level < PERMS['SEE_GHOST_VOTES']:
abort(403)
ups = g.db.query(SubmissionOptionVote).filter_by(option_id=option_id).order_by(SubmissionOptionVote.created_utc).all()
ups = g.db.query(PostOptionVote).filter_by(option_id=option_id).order_by(PostOptionVote.created_utc).all()
user_ids = [x[0] for x in g.db.query(SubmissionOptionVote.user_id).filter_by(option_id=option_id).all()]
user_ids = [x[0] for x in g.db.query(PostOptionVote.user_id).filter_by(option_id=option_id).all()]
total_ts = g.db.query(func.sum(User.truescore)).filter(User.id.in_(user_ids)).scalar()
total_ts = format(total_ts, ",") if total_ts else '0'

View File

@ -170,10 +170,10 @@ def post_id(pid, anything=None, v=None, sub=None):
if v and v.client:
return p.json(g.db)
template = "submission.html"
template = "post.html"
if (p.is_banned or p.author.shadowbanned) \
and not (v and (v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or p.author_id == v.id)):
template = "submission_banned.html"
template = "post_banned.html"
result = render_template(template, v=v, p=p, ids=list(ids),
sort=sort, render_replies=True, offset=offset, sub=p.subr,
@ -276,11 +276,11 @@ def thumbnail_thread(pid:int, vid:int):
else:
return f"{post_url}/{fragment_url}"
p = db.get(Submission, pid)
p = db.get(Post, pid)
if not p or not p.url:
time.sleep(5)
p = db.get(Submission, pid)
p = db.get(Post, pid)
if not p or not p.url: return
@ -427,10 +427,10 @@ def is_repost(v):
url = url.rstrip('/')
search_url = url.replace('%', '').replace('\\', '').replace('_', '\_').strip()
repost = g.db.query(Submission).filter(
Submission.url.ilike(search_url),
Submission.deleted_utc == 0,
Submission.is_banned == False
repost = g.db.query(Post).filter(
Post.url.ilike(search_url),
Post.deleted_utc == 0,
Post.is_banned == False
).first()
if repost: return {'permalink': repost.permalink}
else: return not_a_repost
@ -517,10 +517,10 @@ def submit_post(v:User, sub=None):
url = url.rstrip('/')
search_url = url.replace('%', '').replace('\\', '').replace('_', '\_').strip()
repost = g.db.query(Submission).filter(
Submission.url.ilike(search_url),
Submission.deleted_utc == 0,
Submission.is_banned == False
repost = g.db.query(Post).filter(
Post.url.ilike(search_url),
Post.deleted_utc == 0,
Post.is_banned == False
).first()
if repost and FEATURES['REPOST_DETECTION'] and not v.admin_level >= PERMS['POST_BYPASS_REPOST_CHECKING']:
return {"post_id": repost.id, "success": False}
@ -550,12 +550,12 @@ def submit_post(v:User, sub=None):
abort(400, "Please enter a url or some text!")
if not IS_LOCALHOST:
dup = g.db.query(Submission).filter(
Submission.author_id == v.id,
Submission.deleted_utc == 0,
Submission.title == title,
Submission.url == url,
Submission.body == body
dup = g.db.query(Post).filter(
Post.author_id == v.id,
Post.deleted_utc == 0,
Post.title == title,
Post.url == url,
Post.body == body
).one_or_none()
if dup:
return {"post_id": dup.id, "success": False}
@ -575,7 +575,7 @@ def submit_post(v:User, sub=None):
abort(400, "You can only type marseys!")
if len(body_html) > POST_BODY_HTML_LENGTH_LIMIT:
abort(400, "Submission body_html too long!")
abort(400, "Post body_html too long!")
flag_notify = (request.values.get("notify", "on") == "on")
flag_new = request.values.get("new", False, bool) or 'megathread' in title.lower()
@ -591,7 +591,7 @@ def submit_post(v:User, sub=None):
if url == '': url = None
p = Submission(
p = Post(
private=flag_private,
notify=flag_notify,
author_id=v.id,
@ -621,7 +621,7 @@ def submit_post(v:User, sub=None):
vote = Vote(user_id=v.id,
vote_type=1,
submission_id=p.id,
post_id=p.id,
coins=0
)
g.db.add(vote)
@ -701,7 +701,7 @@ def submit_post(v:User, sub=None):
if not p.private and not (p.sub and g.db.query(Exile.user_id).filter_by(user_id=SNAPPY_ID, sub=p.sub).one_or_none()):
execute_snappy(p, v)
v.post_count = g.db.query(Submission).filter_by(author_id=v.id, deleted_utc=0).count()
v.post_count = g.db.query(Post).filter_by(author_id=v.id, deleted_utc=0).count()
g.db.add(v)
execute_lawlz_actions(v, p)
@ -744,7 +744,7 @@ def delete_post_pid(pid, v):
cache.delete_memoized(frontlist)
cache.delete_memoized(userpagelisting)
v.post_count = g.db.query(Submission).filter_by(author_id=v.id, deleted_utc=0).count()
v.post_count = g.db.query(Post).filter_by(author_id=v.id, deleted_utc=0).count()
g.db.add(v)
return {"message": "Post deleted!"}
@ -766,7 +766,7 @@ def undelete_post_pid(pid, v):
cache.delete_memoized(frontlist)
cache.delete_memoized(userpagelisting)
v.post_count = g.db.query(Submission).filter_by(author_id=v.id, deleted_utc=0).count()
v.post_count = g.db.query(Post).filter_by(author_id=v.id, deleted_utc=0).count()
g.db.add(v)
return {"message": "Post undeleted!"}
@ -796,7 +796,7 @@ def mark_post_nsfw(pid, v):
ma = ModAction(
kind = "set_nsfw",
user_id = v.id,
target_submission_id = p.id,
target_post_id = p.id,
)
g.db.add(ma)
else:
@ -804,7 +804,7 @@ def mark_post_nsfw(pid, v):
sub = p.sub,
kind = "set_nsfw",
user_id = v.id,
target_submission_id = p.id,
target_post_id = p.id,
)
g.db.add(ma)
send_repeatable_notification(p.author_id, f"@{v.username} (a site admin) has marked [{p.title}](/post/{p.id}) as +18")
@ -835,7 +835,7 @@ def unmark_post_nsfw(pid, v):
ma = ModAction(
kind = "unset_nsfw",
user_id = v.id,
target_submission_id = p.id,
target_post_id = p.id,
)
g.db.add(ma)
else:
@ -843,7 +843,7 @@ def unmark_post_nsfw(pid, v):
sub = p.sub,
kind = "unset_nsfw",
user_id = v.id,
target_submission_id = p.id,
target_post_id = p.id,
)
g.db.add(ma)
send_repeatable_notification(p.author_id, f"@{v.username} (a site admin) has unmarked [{p.title}](/post/{p.id}) as +18")
@ -860,10 +860,10 @@ def save_post(pid, v):
p = get_post(pid)
save = g.db.query(SaveRelationship).filter_by(user_id=v.id, submission_id=p.id).one_or_none()
save = g.db.query(SaveRelationship).filter_by(user_id=v.id, post_id=p.id).one_or_none()
if not save:
new_save=SaveRelationship(user_id=v.id, submission_id=p.id)
new_save=SaveRelationship(user_id=v.id, post_id=p.id)
g.db.add(new_save)
return {"message": "Post saved!"}
@ -878,7 +878,7 @@ def unsave_post(pid, v):
p = get_post(pid)
save = g.db.query(SaveRelationship).filter_by(user_id=v.id, submission_id=p.id).one_or_none()
save = g.db.query(SaveRelationship).filter_by(user_id=v.id, post_id=p.id).one_or_none()
if save:
g.db.delete(save)
@ -916,7 +916,7 @@ def set_new_sort(post_id:int, v:User):
ma = ModAction(
kind = "set_new",
user_id = v.id,
target_submission_id = p.id,
target_post_id = p.id,
)
g.db.add(ma)
send_repeatable_notification(p.author_id, f"@{v.username} (a site admin) has changed the the default sorting of comments on [{p.title}](/post/{p.id}) to `new`")
@ -938,7 +938,7 @@ def unset_new_sort(post_id:int, v:User):
ma = ModAction(
kind = "set_hot",
user_id = v.id,
target_submission_id = p.id,
target_post_id = p.id,
)
g.db.add(ma)
send_repeatable_notification(p.author_id, f"@{v.username} (a site admin) has changed the the default sorting of comments on [{p.title}](/post/{p.id}) to `hot`")
@ -1049,7 +1049,7 @@ def edit_post(pid, v):
if execute_blackjack(v, p, text, 'post'): break
if len(body_html) > POST_BODY_HTML_LENGTH_LIMIT:
abort(400, "Submission body_html too long!")
abort(400, "Post body_html too long!")
p.body_html = body_html
@ -1065,7 +1065,7 @@ def edit_post(pid, v):
ma=ModAction(
kind="edit_post",
user_id=v.id,
target_submission_id=p.id
target_post_id=p.id
)
g.db.add(ma)

View File

@ -37,7 +37,7 @@ def flag_post(pid, v):
ma=ModAction(
kind="flair_post",
user_id=v.id,
target_submission_id=post.id,
target_post_id=post.id,
_note=f'"{post.flair}"'
)
g.db.add(ma)
@ -47,7 +47,7 @@ def flag_post(pid, v):
sub=post.sub,
kind="flair_post",
user_id=v.id,
target_submission_id=post.id,
target_post_id=post.id,
_note=f'"{post.flair}"'
)
g.db.add(ma)
@ -125,7 +125,7 @@ def remove_report_post(v, pid, uid):
ma=ModAction(
kind="delete_report",
user_id=v.id,
target_submission_id=pid
target_post_id=pid
)
g.db.add(ma)
@ -157,7 +157,7 @@ def remove_report_comment(v, cid, uid):
g.db.add(ma)
return {"message": "Report removed successfully!"}
def move_post(post:Submission, v:User, reason:str) -> Union[bool, str]:
def move_post(post:Post, v:User, reason:str) -> Union[bool, str]:
if not reason.startswith('/h/') and not reason.startswith('h/'):
return False
@ -207,7 +207,7 @@ def move_post(post:Submission, v:User, reason:str) -> Union[bool, str]:
ma = ModAction(
kind='move_hole',
user_id=v.id,
target_submission_id=post.id,
target_post_id=post.id,
_note=f'{sub_from_str}{sub_to_str}',
)
g.db.add(ma)
@ -216,7 +216,7 @@ def move_post(post:Submission, v:User, reason:str) -> Union[bool, str]:
sub=sub_from,
kind='move_hole',
user_id=v.id,
target_submission_id=post.id,
target_post_id=post.id,
_note=f'{sub_from_str}{sub_to_str}',
)
g.db.add(ma)

View File

@ -8,7 +8,7 @@ from sqlalchemy.sql.expression import or_
from flask import g, session
from files.classes import Alt, Comment, User, Submission
from files.classes import Alt, Comment, User, Post
from files.helpers.config.const import *
from files.helpers.security import generate_hash, validate_hash
from files.__main__ import cache
@ -105,7 +105,7 @@ def check_for_alts(current:User, include_current_session=False):
u.blacklisted_by = current.blacklisted_by
g.db.add(u)
def execute_shadowban_viewers_and_voters(v:Optional[User], target:Union[Submission, Comment]):
def execute_shadowban_viewers_and_voters(v:Optional[User], target:Union[Post, Comment]):
if not v or not v.shadowbanned: return
if not target: return
if v.id != target.author_id: return
@ -120,6 +120,6 @@ def execute_shadowban_viewers_and_voters(v:Optional[User], target:Union[Submissi
amount = randint(0, 3)
target.upvotes += amount
if isinstance(target, Submission):
if isinstance(target, Post):
target.views += amount*randint(3, 5)
g.db.add(target)

View File

@ -62,18 +62,18 @@ def searchposts(v:User):
criteria=searchparse(query)
posts = g.db.query(Submission).options(load_only(Submission.id)) \
.join(Submission.author) \
.filter(Submission.author_id.notin_(v.userblocks))
posts = g.db.query(Post).options(load_only(Post.id)) \
.join(Post.author) \
.filter(Post.author_id.notin_(v.userblocks))
if v.admin_level < PERMS['POST_COMMENT_MODERATION']:
posts = posts.filter(
Submission.deleted_utc == 0,
Submission.is_banned == False,
Submission.private == False)
Post.deleted_utc == 0,
Post.is_banned == False,
Post.private == False)
if 'author' in criteria:
posts = posts.filter(Submission.ghost == False)
posts = posts.filter(Post.ghost == False)
author = get_user(criteria['author'], v=v)
if not author.is_visible_to(v):
if v.client:
@ -90,28 +90,28 @@ def searchposts(v:User):
domain_obj=None,
error=f"@{author.username}'s profile is private; You can't use the 'author' syntax on them."
), 403
posts = posts.filter(Submission.author_id == author.id)
posts = posts.filter(Post.author_id == author.id)
if 'exact' in criteria and 'full_text' in criteria:
regex_str = '[[:<:]]'+criteria['full_text']+'[[:>:]]' # https://docs.oracle.com/cd/E17952_01/mysql-5.5-en/regexp.html "word boundaries"
if 'title' in criteria:
words = [Submission.title.regexp_match(regex_str)]
words = [Post.title.regexp_match(regex_str)]
else:
words = [or_(Submission.title.regexp_match(regex_str), Submission.body.regexp_match(regex_str))]
words = [or_(Post.title.regexp_match(regex_str), Post.body.regexp_match(regex_str))]
posts = posts.filter(*words)
elif 'q' in criteria:
if('title' in criteria):
words = [or_(Submission.title.ilike('%'+x+'%')) \
words = [or_(Post.title.ilike('%'+x+'%')) \
for x in criteria['q']]
else:
words = [or_(
Submission.title.ilike('%'+x+'%'),
Submission.body.ilike('%'+x+'%'),
Submission.url.ilike('%'+x+'%'),
Post.title.ilike('%'+x+'%'),
Post.body.ilike('%'+x+'%'),
Post.url.ilike('%'+x+'%'),
) for x in criteria['q']]
posts = posts.filter(*words)
if 'over18' in criteria: posts = posts.filter(Submission.over_18==True)
if 'over18' in criteria: posts = posts.filter(Post.over_18==True)
if 'domain' in criteria:
domain=criteria['domain']
@ -120,23 +120,23 @@ def searchposts(v:User):
posts=posts.filter(
or_(
Submission.url.ilike("https://"+domain+'/%'),
Submission.url.ilike("https://"+domain+'/%'),
Submission.url.ilike("https://"+domain),
Submission.url.ilike("https://"+domain),
Submission.url.ilike("https://www."+domain+'/%'),
Submission.url.ilike("https://www."+domain+'/%'),
Submission.url.ilike("https://www."+domain),
Submission.url.ilike("https://www."+domain),
Submission.url.ilike("https://old." + domain + '/%'),
Submission.url.ilike("https://old." + domain + '/%'),
Submission.url.ilike("https://old." + domain),
Submission.url.ilike("https://old." + domain)
Post.url.ilike("https://"+domain+'/%'),
Post.url.ilike("https://"+domain+'/%'),
Post.url.ilike("https://"+domain),
Post.url.ilike("https://"+domain),
Post.url.ilike("https://www."+domain+'/%'),
Post.url.ilike("https://www."+domain+'/%'),
Post.url.ilike("https://www."+domain),
Post.url.ilike("https://www."+domain),
Post.url.ilike("https://old." + domain + '/%'),
Post.url.ilike("https://old." + domain + '/%'),
Post.url.ilike("https://old." + domain),
Post.url.ilike("https://old." + domain)
)
)
if search_operator_hole in criteria:
posts = posts.filter(Submission.sub == criteria[search_operator_hole])
posts = posts.filter(Post.sub == criteria[search_operator_hole])
if 'after' in criteria:
after = criteria['after']
@ -144,7 +144,7 @@ def searchposts(v:User):
except:
try: after = timegm(time.strptime(after, "%Y-%m-%d"))
except: abort(400)
posts = posts.filter(Submission.created_utc > after)
posts = posts.filter(Post.created_utc > after)
if 'before' in criteria:
before = criteria['before']
@ -152,16 +152,16 @@ def searchposts(v:User):
except:
try: before = timegm(time.strptime(before, "%Y-%m-%d"))
except: abort(400)
posts = posts.filter(Submission.created_utc < before)
posts = posts.filter(Post.created_utc < before)
posts = apply_time_filter(t, posts, Submission)
posts = apply_time_filter(t, posts, Post)
if not v.can_see_shadowbanned:
posts = posts.join(Submission.author).filter(User.shadowbanned == None)
posts = posts.join(Post.author).filter(User.shadowbanned == None)
total = posts.count()
posts = sort_objects(sort, posts, Submission)
posts = sort_objects(sort, posts, Post)
posts = posts.offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE).all()
@ -234,12 +234,12 @@ def searchcomments(v:User):
if 'over18' in criteria: comments = comments.filter(Comment.over_18 == True)
if search_operator_hole in criteria:
comments = comments.filter(Submission.sub == criteria[search_operator_hole])
comments = comments.filter(Post.sub == criteria[search_operator_hole])
comments = apply_time_filter(t, comments, Comment)
if v.admin_level < PERMS['POST_COMMENT_MODERATION']:
private = [x[0] for x in g.db.query(Submission.id).filter(Submission.private == True).all()]
private = [x[0] for x in g.db.query(Post.id).filter(Post.private == True).all()]
comments = comments.filter(
Comment.is_banned==False,

View File

@ -11,16 +11,16 @@ from files.__main__ import app, cache, limiter
_special_leaderboard_query = text("""
WITH bet_options AS (
SELECT p.id AS parent_id, so.id AS option_id, so.exclusive, cnt.count
FROM submission_options so
JOIN submissions p ON so.parent_id = p.id
FROM post_options so
JOIN posts p ON so.parent_id = p.id
JOIN (
SELECT option_id, COUNT(*) FROM submission_option_votes
SELECT option_id, COUNT(*) FROM post_option_votes
GROUP BY option_id
) AS cnt ON so.id = cnt.option_id
WHERE p.author_id in (30,152) AND p.created_utc > 1668953400
AND so.exclusive IN (2, 3)
),
submission_payouts AS (
post_payouts AS (
SELECT
sq_total.parent_id,
sq_winners.sum AS bettors,
@ -41,13 +41,13 @@ bet_votes AS (
sov.user_id,
CASE
WHEN opt.exclusive = 2 THEN -200
WHEN opt.exclusive = 3 THEN (submission_payouts.winner_payout - 200)
WHEN opt.exclusive = 3 THEN (post_payouts.winner_payout - 200)
END payout
FROM submission_option_votes sov
FROM post_option_votes sov
LEFT OUTER JOIN bet_options AS opt
ON opt.option_id = sov.option_id
LEFT OUTER JOIN submission_payouts
ON opt.parent_id = submission_payouts.parent_id
LEFT OUTER JOIN post_payouts
ON opt.parent_id = post_payouts.parent_id
WHERE opt.option_id IS NOT NULL
),
bettors AS (

View File

@ -419,7 +419,7 @@ def kick(v:User, pid):
sub=old,
kind='kick_post',
user_id=v.id,
target_submission_id=post.id
target_post_id=post.id
)
g.db.add(ma)
@ -674,7 +674,7 @@ def sub_marsey(v:User, sub):
@limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID)
@auth_required
def subs(v:User):
subs = g.db.query(Sub, func.count(Submission.sub)).outerjoin(Submission, Sub.name == Submission.sub).group_by(Sub.name).order_by(func.count(Submission.sub).desc()).all()
subs = g.db.query(Sub, func.count(Post.sub)).outerjoin(Post, Sub.name == Post.sub).group_by(Sub.name).order_by(func.count(Post.sub).desc()).all()
total_users = g.db.query(User).count()
return render_template('sub/subs.html', v=v, subs=subs, total_users=total_users)
@ -691,7 +691,7 @@ def hole_pin(v:User, pid):
if not v.mods(p.sub): abort(403)
num = g.db.query(Submission).filter(Submission.sub == p.sub, Submission.hole_pinned != None).count()
num = g.db.query(Post).filter(Post.sub == p.sub, Post.hole_pinned != None).count()
if num >= 2:
abort(403, f"You can only pin 2 posts to /h/{p.sub}")
@ -706,7 +706,7 @@ def hole_pin(v:User, pid):
sub=p.sub,
kind='pin_post',
user_id=v.id,
target_submission_id=p.id
target_post_id=p.id
)
g.db.add(ma)
@ -738,7 +738,7 @@ def hole_unpin(v:User, pid):
sub=p.sub,
kind='unpin_post',
user_id=v.id,
target_submission_id=p.id
target_post_id=p.id
)
g.db.add(ma)

View File

@ -52,7 +52,7 @@ def upvoters_downvoters(v, username, uid, cls, vote_cls, vote_dir, template, sta
listing = listing.order_by(cls.created_utc.desc()).offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE).all()
listing = [x.id for x in listing]
if cls == Submission:
if cls == Post:
listing = get_posts(listing, v=v, eager=True)
elif cls == Comment:
listing = get_comments(listing, v=v)
@ -66,7 +66,7 @@ def upvoters_downvoters(v, username, uid, cls, vote_cls, vote_dir, template, sta
@limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID)
@auth_required
def upvoters_posts(v:User, username, uid):
return upvoters_downvoters(v, username, uid, Submission, Vote, 1, "userpage/voted_posts.html", None)
return upvoters_downvoters(v, username, uid, Post, Vote, 1, "userpage/voted_posts.html", None)
@app.get("/@<username>/upvoters/<int:uid>/comments")
@ -82,7 +82,7 @@ def upvoters_comments(v:User, username, uid):
@limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID)
@auth_required
def downvoters_posts(v:User, username, uid):
return upvoters_downvoters(v, username, uid, Submission, Vote, -1, "userpage/voted_posts.html", None)
return upvoters_downvoters(v, username, uid, Post, Vote, -1, "userpage/voted_posts.html", None)
@app.get("/@<username>/downvoters/<int:uid>/comments")
@ -118,7 +118,7 @@ def upvoting_downvoting(v, username, uid, cls, vote_cls, vote_dir, template, sta
listing = listing.order_by(cls.created_utc.desc()).offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE).all()
listing = [x.id for x in listing]
if cls == Submission:
if cls == Post:
listing = get_posts(listing, v=v, eager=True)
elif cls == Comment:
listing = get_comments(listing, v=v)
@ -132,7 +132,7 @@ def upvoting_downvoting(v, username, uid, cls, vote_cls, vote_dir, template, sta
@limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID)
@auth_required
def upvoting_posts(v:User, username, uid):
return upvoting_downvoting(v, username, uid, Submission, Vote, 1, "userpage/voted_posts.html", None)
return upvoting_downvoting(v, username, uid, Post, Vote, 1, "userpage/voted_posts.html", None)
@app.get("/@<username>/upvoting/<int:uid>/comments")
@ -148,7 +148,7 @@ def upvoting_comments(v:User, username, uid):
@limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID)
@auth_required
def downvoting_posts(v:User, username, uid):
return upvoting_downvoting(v, username, uid, Submission, Vote, -1, "userpage/voted_posts.html", None)
return upvoting_downvoting(v, username, uid, Post, Vote, -1, "userpage/voted_posts.html", None)
@app.get("/@<username>/downvoting/<int:uid>/comments")
@ -178,7 +178,7 @@ def user_voted(v, username, cls, vote_cls, template, standalone):
listing = listing.order_by(cls.created_utc.desc()).offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE).all()
listing = [x.id for x in listing]
if cls == Submission:
if cls == Post:
listing = get_posts(listing, v=v, eager=True)
elif cls == Comment:
listing = get_comments(listing, v=v)
@ -192,7 +192,7 @@ def user_voted(v, username, cls, vote_cls, template, standalone):
@limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID)
@auth_required
def user_voted_posts(v:User, username):
return user_voted(v, username, Submission, Vote, "userpage/voted_posts.html", None)
return user_voted(v, username, Post, Vote, "userpage/voted_posts.html", None)
@app.get("/@<username>/voted/comments")
@ -263,10 +263,10 @@ def all_upvoters_downvoters(v:User, username:str, vote_dir:int, is_who_simps_hat
votes = []
votes2 = []
if is_who_simps_hates:
votes = g.db.query(Submission.author_id, func.count(Submission.author_id)).join(Vote).filter(Submission.ghost == False, Submission.is_banned == False, Submission.deleted_utc == 0, Vote.vote_type==vote_dir, Vote.user_id==id).group_by(Submission.author_id).order_by(func.count(Submission.author_id).desc()).all()
votes = g.db.query(Post.author_id, func.count(Post.author_id)).join(Vote).filter(Post.ghost == False, Post.is_banned == False, Post.deleted_utc == 0, Vote.vote_type==vote_dir, Vote.user_id==id).group_by(Post.author_id).order_by(func.count(Post.author_id).desc()).all()
votes2 = g.db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote).filter(Comment.ghost == False, Comment.is_banned == False, Comment.deleted_utc == 0, CommentVote.vote_type==vote_dir, CommentVote.user_id==id).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).all()
else:
votes = g.db.query(Vote.user_id, func.count(Vote.user_id)).join(Submission).filter(Submission.ghost == False, Submission.is_banned == False, Submission.deleted_utc == 0, Vote.vote_type==vote_dir, Submission.author_id==id).group_by(Vote.user_id).order_by(func.count(Vote.user_id).desc()).all()
votes = g.db.query(Vote.user_id, func.count(Vote.user_id)).join(Post).filter(Post.ghost == False, Post.is_banned == False, Post.deleted_utc == 0, Vote.vote_type==vote_dir, Post.author_id==id).group_by(Vote.user_id).order_by(func.count(Vote.user_id).desc()).all()
votes2 = g.db.query(CommentVote.user_id, func.count(CommentVote.user_id)).join(Comment).filter(Comment.ghost == False, Comment.is_banned == False, Comment.deleted_utc == 0, CommentVote.vote_type==vote_dir, Comment.author_id==id).group_by(CommentVote.user_id).order_by(func.count(CommentVote.user_id).desc()).all()
votes = Counter(dict(votes)) + Counter(dict(votes2))
total_items = sum(votes.values())
@ -504,9 +504,9 @@ def usersong(username:str):
@limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID)
@auth_required
def subscribe(v, post_id):
existing = g.db.query(Subscription).filter_by(user_id=v.id, submission_id=post_id).one_or_none()
existing = g.db.query(Subscription).filter_by(user_id=v.id, post_id=post_id).one_or_none()
if not existing:
new_sub = Subscription(user_id=v.id, submission_id=post_id)
new_sub = Subscription(user_id=v.id, post_id=post_id)
g.db.add(new_sub)
return {"message": "Subscribed to post successfully!"}
@ -517,7 +517,7 @@ def subscribe(v, post_id):
@limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID)
@auth_required
def unsubscribe(v, post_id):
existing = g.db.query(Subscription).filter_by(user_id=v.id, submission_id=post_id).one_or_none()
existing = g.db.query(Subscription).filter_by(user_id=v.id, post_id=post_id).one_or_none()
if existing:
g.db.delete(existing)
return {"message": "Unsubscribed from post successfully!"}
@ -818,12 +818,12 @@ def visitors(v:User, username:str):
@cache.memoize()
def userpagelisting(user:User, v=None, page:int=1, sort="new", t="all"):
posts = g.db.query(Submission).filter_by(author_id=user.id, is_pinned=False).options(load_only(Submission.id))
posts = g.db.query(Post).filter_by(author_id=user.id, is_pinned=False).options(load_only(Post.id))
if not (v and (v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or v.id == user.id)):
posts = posts.filter_by(is_banned=False, private=False, ghost=False, deleted_utc=0)
posts = apply_time_filter(t, posts, Submission)
posts = apply_time_filter(t, posts, Post)
total = posts.count()
posts = sort_objects(sort, posts, Submission)
posts = sort_objects(sort, posts, Post)
posts = posts.offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE).all()
return [x.id for x in posts], total
@ -959,7 +959,7 @@ def u_username(v:Optional[User], username:str):
if page == 1 and sort == 'new':
sticky = []
sticky = g.db.query(Submission).filter_by(is_pinned=True, author_id=u.id, is_banned=False).all()
sticky = g.db.query(Post).filter_by(is_pinned=True, author_id=u.id, is_banned=False).all()
if sticky:
for p in sticky:
ids = [p.id] + ids
@ -970,7 +970,7 @@ def u_username(v:Optional[User], username:str):
if v and v.client:
return {"data": [x.json(g.db) for x in listing]}
return render_template("userpage/submissions.html",
return render_template("userpage/posts.html",
unban=u.unban_string,
u=u,
v=v,
@ -984,7 +984,7 @@ def u_username(v:Optional[User], username:str):
if v and v.client:
return {"data": [x.json(g.db) for x in listing]}
return render_template("userpage/submissions.html",
return render_template("userpage/posts.html",
u=u,
v=v,
listing=listing,
@ -1029,7 +1029,7 @@ def u_username_comments(username, v=None):
comment_post_author = aliased(User)
comments = g.db.query(Comment).options(load_only(Comment.id)) \
.outerjoin(Comment.post) \
.outerjoin(comment_post_author, Submission.author) \
.outerjoin(comment_post_author, Post.author) \
.filter(
Comment.author_id == u.id,
or_(Comment.parent_submission != None, Comment.wall_user_id != None),
@ -1188,9 +1188,9 @@ def user_profile_name(username):
def get_saves_and_subscribes(v, template, relationship_cls, page:int, standalone=False):
if relationship_cls in {SaveRelationship, Subscription}:
query = relationship_cls.submission_id
query = relationship_cls.post_id
join = relationship_cls.post
cls = Submission
cls = Post
elif relationship_cls is CommentSaveRelationship:
query = relationship_cls.comment_id
join = relationship_cls.comment
@ -1210,12 +1210,12 @@ def get_saves_and_subscribes(v, template, relationship_cls, page:int, standalone
if not v.admin_level >= PERMS['POST_COMMENT_MODERATION']:
extra = lambda q:q.filter(cls.is_banned == False, cls.deleted_utc == 0)
if cls is Submission:
if cls is Post:
listing = get_posts(ids, v=v, eager=True, extra=extra)
elif cls is Comment:
listing = get_comments(ids, v=v, extra=extra)
else:
raise TypeError("Only supports Submissions and Comments. This is probably the result of a bug with *this* function")
raise TypeError("Only supports Posts and Comments. This is probably the result of a bug with *this* function")
if v.client: return {"data": [x.json(g.db) for x in listing]}
return render_template(template, u=v, v=v, listing=listing, page=page, total=total, standalone=standalone)
@ -1227,7 +1227,7 @@ def get_saves_and_subscribes(v, template, relationship_cls, page:int, standalone
def saved_posts(v:User, username):
page = get_page()
return get_saves_and_subscribes(v, "userpage/submissions.html", SaveRelationship, page, False)
return get_saves_and_subscribes(v, "userpage/posts.html", SaveRelationship, page, False)
@app.get("/@<username>/saved/comments")
@limiter.limit(DEFAULT_RATELIMIT)
@ -1245,7 +1245,7 @@ def saved_comments(v:User, username):
def subscribed_posts(v:User, username):
page = get_page()
return get_saves_and_subscribes(v, "userpage/submissions.html", Subscription, page, False)
return get_saves_and_subscribes(v, "userpage/posts.html", Subscription, page, False)
@app.post("/fp/<fp>")
@limiter.limit('1/second', scope=rpath)

View File

@ -25,9 +25,9 @@ def vote_info_get(v, link):
if thing.author.shadowbanned and not (v and v.admin_level >= PERMS['USER_SHADOWBAN']):
abort(500)
if isinstance(thing, Submission):
if isinstance(thing, Post):
query = g.db.query(Vote).join(Vote.user).filter(
Vote.submission_id == thing.id,
Vote.post_id == thing.id,
).order_by(Vote.created_utc)
ups = query.filter(Vote.vote_type == 1).all()
@ -56,7 +56,7 @@ def vote_post_comment(target_id, new, v, cls, vote_cls):
if v.client and v.id not in PRIVILEGED_USER_BOTS: abort(403)
new = int(new)
target = None
if cls == Submission:
if cls == Post:
target = get_post(target_id)
elif cls == Comment:
target = get_comment(target_id)
@ -79,7 +79,7 @@ def vote_post_comment(target_id, new, v, cls, vote_cls):
existing = g.db.query(vote_cls).filter_by(user_id=v.id)
if vote_cls == Vote:
existing = existing.filter_by(submission_id=target.id)
existing = existing.filter_by(post_id=target.id)
elif vote_cls == CommentVote:
existing = existing.filter_by(comment_id=target.id)
else:
@ -121,7 +121,7 @@ def vote_post_comment(target_id, new, v, cls, vote_cls):
if vote_cls == Vote:
vote = Vote(user_id=v.id,
vote_type=new,
submission_id=target_id,
post_id=target_id,
app_id=v.client.application.id if v.client else None,
real=real,
coins=coin_value
@ -146,7 +146,7 @@ def vote_post_comment(target_id, new, v, cls, vote_cls):
votes = votes.filter(vote_cls.vote_type == dir)
if vote_cls == Vote:
votes = votes.filter(vote_cls.submission_id == target.id)
votes = votes.filter(vote_cls.post_id == target.id)
elif vote_cls == CommentVote:
votes = votes.filter(vote_cls.comment_id == target.id)
else:
@ -164,12 +164,12 @@ def vote_post_comment(target_id, new, v, cls, vote_cls):
mul = 1
if target.is_approved == PROGSTACK_ID:
mul = PROGSTACK_MUL
elif cls == Submission and (any(i in target.title.lower() for i in ENCOURAGED) or any(i in str(target.url).lower() for i in ENCOURAGED2)):
elif cls == Post and (any(i in target.title.lower() for i in ENCOURAGED) or any(i in str(target.url).lower() for i in ENCOURAGED2)):
mul = PROGSTACK_MUL
send_notification(AEVANN_ID, target.permalink)
elif target.author.progressivestack or (target.author.admin_level and target.author.id not in {CARP_ID, SCHIZO_ID}):
mul = 2
elif SITE == 'rdrama.net' and cls == Submission:
elif SITE == 'rdrama.net' and cls == Post:
if (target.domain.endswith('.win') or 'forum' in target.domain or 'chan' in target.domain
or (target.domain in BOOSTED_SITES and not target.url.startswith('/'))):
mul = 2
@ -195,7 +195,7 @@ def vote_post_comment(target_id, new, v, cls, vote_cls):
@limiter.limit("60/minute;1000/hour;2000/day", key_func=get_ID)
@is_not_permabanned
def vote_post(post_id, new, v):
return vote_post_comment(post_id, new, v, Submission, Vote)
return vote_post_comment(post_id, new, v, Post, Vote)
@app.post("/vote/comment/<int:comment_id>/<new>")
@limiter.limit('1/second', scope=rpath)

View File

@ -55,7 +55,7 @@
</ul>
{% if listing %}
{% include "submission_listing.html" %}
{% include "post_listing.html" %}
{% elif comments %}
{% include "comments.html" %}
{% endif %}

View File

@ -9,7 +9,7 @@
<div class="col">
{% block listing %}
<div class="posts">
{% include "submission_listing.html" %}
{% include "post_listing.html" %}
</div>
{% endblock %}
</div>

View File

@ -21,7 +21,7 @@
<div class="col">
{% block listing %}
<div class="posts">
{% include "submission_listing.html" %}
{% include "post_listing.html" %}
</div>
{% endblock %}
</div>

View File

@ -22,7 +22,7 @@
<div class="col">
{% block listing %}
<div class="posts">
{% include "submission_listing.html" %}
{% include "post_listing.html" %}
</div>
{% endblock %}
</div>

View File

@ -785,7 +785,7 @@
<script defer src="{{'js/admin/comments.js' | asset}}"></script>
{% endif %}
<script defer src="{{'js/comments+submission_listing.js' | asset}}"></script>
<script defer src="{{'js/comments+post_listing.js' | asset}}"></script>
<script defer src="{{'js/comments.js' | asset}}"></script>
<script defer src="{{'js/more_comments.js' | asset}}"></script>
{% endif %}

View File

@ -146,7 +146,7 @@
<div class="row no-gutters {% if listing %}mt-md-3{% elif not listing %}my-md-3{% endif %}">
<div class="col-12">
<div class="posts" id="posts">
{% include "submission_listing.html" %}
{% include "post_listing.html" %}
</div>
</div>
</div>

View File

@ -57,7 +57,7 @@
{% if request.path == '/notifications/posts' %}
{% with listing=notifications %}
<div class="mt-4">
{% include "submission_listing.html" %}
{% include "post_listing.html" %}
</div>
{% endwith %}
{% elif request.path == '/notifications/modactions' %}

View File

@ -356,14 +356,14 @@
<input hidden class="twoattrs" value="{{p.id}},{{p.comment_count}}">
<script defer src="{{'js/new_comments.js' | asset}}"></script>
<script defer src="{{'js/submission.js' | asset}}"></script>
<script defer src="{{'js/post.js' | asset}}"></script>
{% if fart and not (v and v.has_badge(128)) %}
<script defer src="{{'js/fart.js' | asset}}"></script>
{% endif %}
{% if v and v.admin_level >= PERMS['POST_COMMENT_MODERATION'] %}
<script defer src="{{'js/admin/submission.js' | asset}}"></script>
<script defer src="{{'js/admin/post.js' | asset}}"></script>
{% endif %}
{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "submission.html" %}
{% extends "post.html" %}
{% set score=p.score %}
{% if v %}

View File

@ -280,10 +280,10 @@
{% endif %}
<script defer src="{{'js/vendor/clipboard.js' | asset}}"></script>
<script defer src="{{'js/comments+submission_listing.js' | asset}}"></script>
<script defer src="{{'js/submission_listing.js' | asset}}"></script>
<script defer src="{{'js/comments+post_listing.js' | asset}}"></script>
<script defer src="{{'js/post_listing.js' | asset}}"></script>
{% if v and v.admin_level >= PERMS['POST_COMMENT_MODERATION'] %}
<script defer src="{{'js/admin/submission.js' | asset}}"></script>
<script defer src="{{'js/admin/post.js' | asset}}"></script>
{% endif %}
<script defer src="{{'js/new_comments.js' | asset}}"></script>

View File

@ -198,7 +198,7 @@
<div class="col-12">
<div class="posts" id="posts">
{% block listing_template %}
{% include "submission_listing.html" %}
{% include "post_listing.html" %}
{% endblock %}
</div>
</div>

View File

@ -1,9 +1,9 @@
{%- extends 'userpage/userpage.html' -%}
{% block userpage_content %}
<div class="row no-gutters {% if listing %}mt-md-3{% elif not listing %}my-md-3{% endif %} userpage-submissions" style="margin-top: 10px;">
<div class="row no-gutters {% if listing %}mt-md-3{% elif not listing %}my-md-3{% endif %} userpage-posts" style="margin-top: 10px;">
<div class="col">
<div class="posts">
{% include "submission_listing.html" %}
{% include "post_listing.html" %}
</div>
</div>
</div>

View File

@ -21,7 +21,7 @@
<div class="col">
{% block listing %}
<div class="posts">
{% include "submission_listing.html" %}
{% include "post_listing.html" %}
</div>
{% endblock %}
</div>

View File

@ -0,0 +1,12 @@
alter table submissions rename to posts;
alter table submission_options rename to post_options;
alter table submission_option_votes rename to post_option_votes;
alter table award_relationships rename column submission_id to post_id;
alter table save_relationship rename column submission_id to post_id;
alter table post_option_votes rename column submission_id to post_id;
alter table subscriptions rename column submission_id to post_id;
alter table votes rename column submission_id to post_id;
alter table modactions rename column target_submission_id to target_post_id;
alter table subactions rename column target_submission_id to target_post_id;