Move 'deleted_utc' into 'state_user_deleted_utc' and change types.
This commit is contained in:
parent
e9ca6e3239
commit
75689d88d5
24 changed files with 141 additions and 83 deletions
|
@ -31,7 +31,6 @@ class Comment(CreatedBase):
|
|||
ghost = Column(Boolean, default=False, nullable=False)
|
||||
bannedfor = Column(Boolean)
|
||||
distinguish_level = Column(Integer, default=0, nullable=False)
|
||||
deleted_utc = Column(Integer, default=0, nullable=False)
|
||||
is_approved = Column(Integer, ForeignKey("users.id"))
|
||||
level = Column(Integer, default=1, nullable=False)
|
||||
parent_comment_id = Column(Integer, ForeignKey("comments.id"))
|
||||
|
@ -52,6 +51,12 @@ class Comment(CreatedBase):
|
|||
filter_state = Column(String, nullable=False)
|
||||
volunteer_janitor_badness = Column(Float, default=0.5, nullable=False)
|
||||
|
||||
# Visibility states here
|
||||
state_user_deleted_utc = Column(DateTime, nullable=True) # null if it hasn't been deleted by the user
|
||||
# TBD: state_mod
|
||||
# TBD: state_mod_set_by
|
||||
# TBD: state_report
|
||||
|
||||
Index('comment_parent_index', parent_comment_id)
|
||||
Index('comment_post_id_index', parent_submission)
|
||||
Index('comments_user_index', author_id)
|
||||
|
@ -230,7 +235,7 @@ class Comment(CreatedBase):
|
|||
'created_utc': self.created_utc,
|
||||
'edited_utc': self.edited_utc or 0,
|
||||
'is_banned': bool(self.is_banned),
|
||||
'deleted_utc': self.deleted_utc,
|
||||
'state_user_deleted_utc': self.state_user_deleted_utc,
|
||||
'is_nsfw': self.over_18,
|
||||
'permalink': f'/comment/{self.id}',
|
||||
'is_pinned': self.is_pinned,
|
||||
|
@ -263,8 +268,8 @@ class Comment(CreatedBase):
|
|||
'level': self.level,
|
||||
'parent': self.parent_fullname
|
||||
}
|
||||
elif self.deleted_utc:
|
||||
data = {'deleted_utc': self.deleted_utc,
|
||||
elif self.state_user_deleted_utc:
|
||||
data = {'state_user_deleted_utc': self.state_user_deleted_utc,
|
||||
'id': self.id,
|
||||
'post': self.post.id if self.post else 0,
|
||||
'level': self.level,
|
||||
|
@ -282,7 +287,7 @@ class Comment(CreatedBase):
|
|||
@lazy
|
||||
def json(self):
|
||||
data = self.json_core
|
||||
if self.deleted_utc or self.is_banned: return data
|
||||
if self.state_user_deleted_utc or self.is_banned: return data
|
||||
data["author"] = '👻' if self.ghost else self.author.json_core
|
||||
data["post"] = self.post.json_core if self.post else ''
|
||||
return data
|
||||
|
|
|
@ -80,8 +80,8 @@ class ScheduledSubmissionTask(RepeatableTask):
|
|||
# HTML template for previewing a submitted task
|
||||
|
||||
@property
|
||||
def deleted_utc(self) -> int:
|
||||
return int(not self.task.enabled)
|
||||
def state_user_deleted_utc(self) -> int:
|
||||
return self.task.enabled and 1 or None
|
||||
|
||||
@functools.cached_property
|
||||
def title_html(self) -> str:
|
||||
|
|
|
@ -27,7 +27,6 @@ class Submission(CreatedBase):
|
|||
bannedfor = Column(Boolean)
|
||||
ghost = Column(Boolean, default=False, nullable=False)
|
||||
views = Column(Integer, default=0, nullable=False)
|
||||
deleted_utc = Column(Integer, default=0, nullable=False)
|
||||
distinguish_level = Column(Integer, default=0, nullable=False)
|
||||
stickied = Column(String)
|
||||
stickied_utc = Column(Integer)
|
||||
|
@ -53,15 +52,21 @@ class Submission(CreatedBase):
|
|||
filter_state = Column(String, nullable=False)
|
||||
task_id = Column(Integer, ForeignKey("tasks_repeatable_scheduled_submissions.id"))
|
||||
|
||||
# Visibility states here
|
||||
state_user_deleted_utc = Column(DateTime, nullable=True) # null if it hasn't been deleted by the user
|
||||
# TBD: state_mod
|
||||
# TBD: state_mod_set_by
|
||||
# TBD: state_report
|
||||
|
||||
Index('fki_submissions_approver_fkey', is_approved)
|
||||
Index('post_app_id_idx', app_id)
|
||||
Index('subimssion_binary_group_idx', is_banned, deleted_utc, over_18)
|
||||
Index('subimssion_binary_group_idx', is_banned, state_user_deleted_utc, over_18)
|
||||
Index('submission_isbanned_idx', is_banned)
|
||||
Index('submission_isdeleted_idx', deleted_utc)
|
||||
Index('submission_isdeleted_idx', state_user_deleted_utc)
|
||||
|
||||
@declared_attr
|
||||
def submission_new_sort_idx(self):
|
||||
return Index('submission_new_sort_idx', self.is_banned, self.deleted_utc, self.created_utc.desc(), self.over_18)
|
||||
return Index('submission_new_sort_idx', self.is_banned, self.state_user_deleted_utc, self.created_utc.desc(), self.over_18)
|
||||
|
||||
Index('submission_pinned_idx', is_pinned)
|
||||
Index('submissions_author_index', author_id)
|
||||
|
@ -103,7 +108,7 @@ class Submission(CreatedBase):
|
|||
author.post_count = db.query(Submission.id).filter_by(
|
||||
author_id=self.author_id,
|
||||
is_banned=False,
|
||||
deleted_utc=0).count()
|
||||
state_user_deleted_utc=None).count()
|
||||
db.add(author)
|
||||
|
||||
def publish(self):
|
||||
|
@ -231,7 +236,7 @@ class Submission(CreatedBase):
|
|||
'permalink': self.permalink,
|
||||
'shortlink': self.shortlink,
|
||||
'is_banned': bool(self.is_banned),
|
||||
'deleted_utc': self.deleted_utc,
|
||||
'state_user_deleted_utc': self.state_user_deleted_utc,
|
||||
'created_utc': self.created_utc,
|
||||
'id': self.id,
|
||||
'title': self.title,
|
||||
|
@ -266,15 +271,15 @@ class Submission(CreatedBase):
|
|||
def json_core(self):
|
||||
if self.is_banned:
|
||||
return {'is_banned': True,
|
||||
'deleted_utc': self.deleted_utc,
|
||||
'state_user_deleted_utc': self.state_user_deleted_utc,
|
||||
'ban_reason': self.ban_reason,
|
||||
'id': self.id,
|
||||
'title': self.title,
|
||||
'permalink': self.permalink,
|
||||
}
|
||||
elif self.deleted_utc:
|
||||
elif self.state_user_deleted_utc:
|
||||
return {'is_banned': bool(self.is_banned),
|
||||
'deleted_utc': True,
|
||||
'state_user_deleted_utc': self.state_user_deleted_utc,
|
||||
'id': self.id,
|
||||
'title': self.title,
|
||||
'permalink': self.permalink,
|
||||
|
@ -287,7 +292,7 @@ class Submission(CreatedBase):
|
|||
def json(self):
|
||||
data=self.json_core
|
||||
|
||||
if self.deleted_utc or self.is_banned:
|
||||
if self.state_user_deleted_utc or self.is_banned:
|
||||
return data
|
||||
|
||||
data["author"]='👻' if self.ghost else self.author.json_core
|
||||
|
|
|
@ -335,7 +335,7 @@ class User(CreatedBase):
|
|||
@property
|
||||
@lazy
|
||||
def notifications_count(self):
|
||||
notifs = g.db.query(Notification.user_id).join(Comment).filter(Notification.user_id == self.id, Notification.read == False, Comment.is_banned == False, Comment.deleted_utc == 0)
|
||||
notifs = g.db.query(Notification.user_id).join(Comment).filter(Notification.user_id == self.id, Notification.read == False, Comment.is_banned == False, Comment.state_user_deleted_utc == None)
|
||||
|
||||
if not self.shadowbanned and self.admin_level < 3:
|
||||
notifs = notifs.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None)
|
||||
|
@ -350,7 +350,7 @@ class User(CreatedBase):
|
|||
@property
|
||||
@lazy
|
||||
def reddit_notifications_count(self):
|
||||
return g.db.query(Notification.user_id).join(Comment).filter(Notification.user_id == self.id, Notification.read == False, Comment.is_banned == False, Comment.deleted_utc == 0, Comment.body_html.like('%<p>New site mention: <a href="https://old.reddit.com/r/%'), Comment.parent_submission == None, Comment.author_id == NOTIFICATIONS_ID).count()
|
||||
return g.db.query(Notification.user_id).join(Comment).filter(Notification.user_id == self.id, Notification.read == False, Comment.is_banned == False, Comment.state_user_deleted_utc == None, Comment.body_html.like('%<p>New site mention: <a href="https://old.reddit.com/r/%'), Comment.parent_submission == None, Comment.author_id == NOTIFICATIONS_ID).count()
|
||||
|
||||
@property
|
||||
@lazy
|
||||
|
@ -528,7 +528,7 @@ class User(CreatedBase):
|
|||
@lazy
|
||||
def saved_idlist(self, page=1):
|
||||
saved = [x[0] for x in g.db.query(SaveRelationship.submission_id).filter_by(user_id=self.id).all()]
|
||||
posts = g.db.query(Submission.id).filter(Submission.id.in_(saved), Submission.is_banned == False, Submission.deleted_utc == 0)
|
||||
posts = g.db.query(Submission.id).filter(Submission.id.in_(saved), Submission.is_banned == False, Submission.state_user_deleted_utc == None)
|
||||
|
||||
if self.admin_level < 2:
|
||||
posts = posts.filter(Submission.author_id.notin_(self.userblocks))
|
||||
|
@ -538,7 +538,7 @@ class User(CreatedBase):
|
|||
@lazy
|
||||
def saved_comment_idlist(self, page=1):
|
||||
saved = [x[0] for x in g.db.query(CommentSaveRelationship.comment_id).filter_by(user_id=self.id).all()]
|
||||
comments = g.db.query(Comment.id).filter(Comment.id.in_(saved), Comment.is_banned == False, Comment.deleted_utc == 0)
|
||||
comments = g.db.query(Comment.id).filter(Comment.id.in_(saved), Comment.is_banned == False, Comment.state_user_deleted_utc == None)
|
||||
|
||||
if self.admin_level < 2:
|
||||
comments = comments.filter(Comment.author_id.notin_(self.userblocks))
|
||||
|
|
|
@ -28,14 +28,14 @@ def _compile_records(db):
|
|||
|
||||
# get the info we need for all mentioned posts
|
||||
reported_comment_ids = {record.comment_id for record in vrecords}
|
||||
reported_comments = db.query(Comment).where(Comment.id.in_(reported_comment_ids)).options(sqlalchemy.orm.load_only('id', 'deleted_utc'))
|
||||
reported_comments = db.query(Comment).where(Comment.id.in_(reported_comment_ids)).options(sqlalchemy.orm.load_only('id', 'state_user_deleted_utc'))
|
||||
reported_comments = {comment.id: comment for comment in reported_comments}
|
||||
|
||||
# get our compiled data
|
||||
records_compiled = {}
|
||||
for record in vrecords:
|
||||
# we're just going to ignore deleted comments entirely
|
||||
if reported_comments[record.comment_id].deleted_utc != 0:
|
||||
if reported_comments[record.comment_id].state_user_deleted_utc != None:
|
||||
continue
|
||||
|
||||
# unique identifier for user/comment report pair
|
||||
|
|
|
@ -66,7 +66,7 @@ def update_author_comment_count(comment, delta):
|
|||
Comment.author_id == comment.author_id,
|
||||
Comment.parent_submission != None,
|
||||
Comment.is_banned == False,
|
||||
Comment.deleted_utc == 0,
|
||||
Comment.state_user_deleted_utc == None,
|
||||
).count()
|
||||
g.db.add(comment.author)
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ class ModerationState:
|
|||
return cls(
|
||||
removed=bool(target.is_banned or target.filter_state == 'removed'),
|
||||
removed_by_name=target.ban_reason, # type: ignore
|
||||
deleted=bool(target.deleted_utc != 0),
|
||||
deleted=bool(target.state_user_deleted_utc != None),
|
||||
reports_ignored=bool(target.filter_state == 'ignored'),
|
||||
filtered=bool(target.filter_state == 'filtered'),
|
||||
op_shadowbanned=bool(target.author.shadowbanned),
|
||||
|
|
|
@ -7,6 +7,7 @@ from typing import Final
|
|||
|
||||
from flask import g
|
||||
from sqlalchemy.sql.expression import not_
|
||||
from sqlalchemy import func
|
||||
|
||||
from files.__main__ import cache
|
||||
from files.classes.submission import Submission
|
||||
|
@ -43,7 +44,7 @@ def frontlist(v=None, sort='new', page=1, t="all", ids_only=True, ccmode="false"
|
|||
if (ccmode == "true"):
|
||||
posts = posts.filter(Submission.club == True)
|
||||
|
||||
posts = posts.filter_by(is_banned=False, private=False, deleted_utc = 0)
|
||||
posts = posts.filter_by(is_banned=False, private=False, state_user_deleted_utc=None)
|
||||
|
||||
if ccmode == "false" and not gt and not lt:
|
||||
posts = posts.filter_by(stickied=None)
|
||||
|
@ -106,7 +107,7 @@ def userpagelisting(u:User, v=None, page=1, sort="new", t="all"):
|
|||
posts = g.db.query(Submission.id).filter_by(author_id=u.id, is_pinned=False)
|
||||
|
||||
if not (v and (v.admin_level >= 2 or v.id == u.id)):
|
||||
posts = posts.filter_by(deleted_utc=0, is_banned=False, private=False, ghost=False)
|
||||
posts = posts.filter_by(state_user_deleted_utc=None, is_banned=False, private=False, ghost=False)
|
||||
|
||||
posts = apply_time_filter(posts, t, Submission)
|
||||
posts = sort_objects(posts, sort, Submission)
|
||||
|
@ -118,7 +119,7 @@ def userpagelisting(u:User, v=None, page=1, sort="new", t="all"):
|
|||
|
||||
@cache.memoize(timeout=CHANGELOGLIST_TIMEOUT_SECS)
|
||||
def changeloglist(v=None, sort="new", page=1, t="all"):
|
||||
posts = g.db.query(Submission.id).filter_by(is_banned=False, private=False,).filter(Submission.deleted_utc == 0)
|
||||
posts = g.db.query(Submission.id).filter_by(is_banned=False, private=False,).filter(Submission.state_user_deleted_utc == None)
|
||||
|
||||
if v.admin_level < 2:
|
||||
posts = posts.filter(Submission.author_id.notin_(v.userblocks))
|
||||
|
|
|
@ -149,7 +149,7 @@ def api_comment(v):
|
|||
|
||||
existing = g.db.query(Comment.id).filter(
|
||||
Comment.author_id == v.id,
|
||||
Comment.deleted_utc == 0,
|
||||
Comment.state_user_deleted_utc == None,
|
||||
Comment.parent_comment_id == parent_comment_id,
|
||||
Comment.parent_submission == parent_post.id,
|
||||
Comment.body_html == body_html
|
||||
|
@ -332,9 +332,9 @@ def edit_comment(cid, v):
|
|||
@auth_required
|
||||
def delete_comment(cid, v):
|
||||
c = get_comment(cid, v=v)
|
||||
if c.deleted_utc: abort(409)
|
||||
if c.state_user_deleted_utc: abort(409)
|
||||
if c.author_id != v.id: abort(403)
|
||||
c.deleted_utc = int(time.time())
|
||||
c.state_user_deleted_utc = time.time()
|
||||
# TODO: update stateful counters
|
||||
g.db.add(c)
|
||||
g.db.commit()
|
||||
|
@ -346,9 +346,9 @@ def delete_comment(cid, v):
|
|||
@auth_required
|
||||
def undelete_comment(cid, v):
|
||||
c = get_comment(cid, v=v)
|
||||
if not c.deleted_utc: abort(409)
|
||||
if not c.state_user_deleted_utc: abort(409)
|
||||
if c.author_id != v.id: abort(403)
|
||||
c.deleted_utc = 0
|
||||
c.state_user_deleted_utc = None
|
||||
# TODO: update stateful counters
|
||||
g.db.add(c)
|
||||
g.db.commit()
|
||||
|
|
|
@ -27,7 +27,7 @@ def unread(v):
|
|||
Notification.read == False,
|
||||
Notification.user_id == v.id,
|
||||
Comment.is_banned == False,
|
||||
Comment.deleted_utc == 0,
|
||||
Comment.state_user_deleted_utc == None,
|
||||
Comment.author_id != AUTOJANNY_ID,
|
||||
).order_by(Notification.created_utc.desc()).all()
|
||||
|
||||
|
@ -101,7 +101,7 @@ def notifications(v):
|
|||
comments = g.db.query(Comment, Notification).join(Notification, Notification.comment_id == Comment.id).filter(
|
||||
Notification.user_id == v.id,
|
||||
Comment.is_banned == False,
|
||||
Comment.deleted_utc == 0,
|
||||
Comment.state_user_deleted_utc == None,
|
||||
Comment.author_id != AUTOJANNY_ID,
|
||||
Comment.body_html.notlike('%<p>New site mention: <a href="https://old.reddit.com/r/%')
|
||||
).order_by(Notification.created_utc.desc())
|
||||
|
@ -250,7 +250,7 @@ def changelog(v):
|
|||
|
||||
@app.get("/random_post")
|
||||
def random_post():
|
||||
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(Submission.id).filter(Submission.state_user_deleted_utc == None, Submission.is_banned == False, Submission.private == False).order_by(func.random()).first()
|
||||
|
||||
if p: p = p[0]
|
||||
else: abort(404)
|
||||
|
@ -308,7 +308,7 @@ def get_comments_idlist(page=1, v=None, sort="new", t="all", gt=0, lt=0):
|
|||
comments = comments.filter(
|
||||
Comment.author_id.notin_(v.userblocks),
|
||||
Comment.is_banned == False,
|
||||
Comment.deleted_utc == 0,
|
||||
Comment.state_user_deleted_utc == None,
|
||||
Submission.private == False, # comment parent post not private
|
||||
User.shadowbanned == None, # comment author not shadowbanned
|
||||
Comment.filter_state.notin_(('filtered', 'removed')),
|
||||
|
|
|
@ -428,7 +428,7 @@ def api_is_repost():
|
|||
search_url = sql_ilike_clean(url)
|
||||
repost = g.db.query(Submission).filter(
|
||||
Submission.url.ilike(search_url),
|
||||
Submission.deleted_utc == 0,
|
||||
Submission.state_user_deleted_utc == None,
|
||||
Submission.is_banned == False
|
||||
).first()
|
||||
if repost: return {'permalink': repost.permalink}
|
||||
|
@ -494,7 +494,7 @@ def _duplicate_check(search_url:Optional[str]) -> Optional[werkzeug.wrappers.Res
|
|||
if not search_url: return None
|
||||
repost = g.db.query(Submission).filter(
|
||||
func.lower(Submission.url) == search_url.lower(),
|
||||
Submission.deleted_utc == 0,
|
||||
Submission.state_user_deleted_utc == None,
|
||||
Submission.is_banned == False
|
||||
).first()
|
||||
if repost and SITE != 'localhost':
|
||||
|
@ -507,7 +507,7 @@ def _duplicate_check2(
|
|||
validated_post:validators.ValidatedSubmissionLike) -> Optional[werkzeug.wrappers.Response]:
|
||||
dup = g.db.query(Submission).filter(
|
||||
Submission.author_id == user_id,
|
||||
Submission.deleted_utc == 0,
|
||||
Submission.state_user_deleted_utc == None,
|
||||
Submission.title == validated_post.title,
|
||||
Submission.url == validated_post.url,
|
||||
Submission.body == validated_post.body
|
||||
|
@ -603,7 +603,7 @@ def delete_post_pid(pid, v):
|
|||
if post.author_id != v.id:
|
||||
abort(403)
|
||||
|
||||
post.deleted_utc = int(time.time())
|
||||
post.state_user_deleted_utc = datetime.now()
|
||||
post.is_pinned = False
|
||||
post.stickied = None
|
||||
|
||||
|
@ -621,7 +621,7 @@ def delete_post_pid(pid, v):
|
|||
def undelete_post_pid(pid, v):
|
||||
post = get_post(pid)
|
||||
if post.author_id != v.id: abort(403)
|
||||
post.deleted_utc = 0
|
||||
post.state_user_deleted_utc = None
|
||||
|
||||
g.db.add(post)
|
||||
|
||||
|
|
|
@ -44,9 +44,9 @@ def searchposts(v):
|
|||
if not (v and v.paid_dues): posts = posts.filter_by(club=False)
|
||||
|
||||
if v and v.admin_level < 2:
|
||||
posts = posts.filter(Submission.deleted_utc == 0, Submission.is_banned == False, Submission.private == False, Submission.author_id.notin_(v.userblocks))
|
||||
posts = posts.filter(Submission.state_user_deleted_utc == None, Submission.is_banned == False, Submission.private == False, Submission.author_id.notin_(v.userblocks))
|
||||
elif not v:
|
||||
posts = posts.filter(Submission.deleted_utc == 0, Submission.is_banned == False, Submission.private == False)
|
||||
posts = posts.filter(Submission.state_user_deleted_utc == None, Submission.is_banned == False, Submission.private == False)
|
||||
|
||||
|
||||
if 'author' in criteria:
|
||||
|
@ -168,10 +168,10 @@ def searchcomments(v):
|
|||
|
||||
if v and v.admin_level < 2:
|
||||
private = [x[0] for x in g.db.query(Submission.id).filter(Submission.private == True).all()]
|
||||
comments = comments.filter(Comment.author_id.notin_(v.userblocks), Comment.is_banned==False, Comment.deleted_utc == 0, Comment.parent_submission.notin_(private))
|
||||
comments = comments.filter(Comment.author_id.notin_(v.userblocks), Comment.is_banned==False, Comment.state_user_deleted_utc == None, Comment.parent_submission.notin_(private))
|
||||
elif not v:
|
||||
private = [x[0] for x in g.db.query(Submission.id).filter(Submission.private == True).all()]
|
||||
comments = comments.filter(Comment.is_banned==False, Comment.deleted_utc == 0, Comment.parent_submission.notin_(private))
|
||||
comments = comments.filter(Comment.is_banned==False, Comment.state_user_deleted_utc == None, Comment.parent_submission.notin_(private))
|
||||
|
||||
|
||||
if not (v and v.paid_dues):
|
||||
|
|
|
@ -77,14 +77,14 @@ def participation_stats(v):
|
|||
"signups last 24h": users.filter(User.created_utc > day).count(),
|
||||
"total posts": submissions.count(),
|
||||
"posting users": g.db.query(Submission.author_id).distinct().count(),
|
||||
"listed posts": submissions.filter_by(is_banned=False).filter(Submission.deleted_utc == 0).count(),
|
||||
"listed posts": submissions.filter_by(is_banned=False).filter(Submission.state_user_deleted_utc == None).count(),
|
||||
"removed posts (by admins)": submissions.filter_by(is_banned=True).count(),
|
||||
"deleted posts (by author)": submissions.filter(Submission.deleted_utc > 0).count(),
|
||||
"deleted posts (by author)": submissions.filter(Submission.state_user_deleted_utc != None).count(),
|
||||
"posts last 24h": submissions.filter(Submission.created_utc > day).count(),
|
||||
"total comments": comments.filter(Comment.author_id.notin_((AUTOJANNY_ID,NOTIFICATIONS_ID))).count(),
|
||||
"commenting users": g.db.query(Comment.author_id).distinct().count(),
|
||||
"removed comments (by admins)": comments.filter_by(is_banned=True).count(),
|
||||
"deleted comments (by author)": comments.filter(Comment.deleted_utc > 0).count(),
|
||||
"deleted comments (by author)": comments.filter(Comment.state_user_deleted_utc != None).count(),
|
||||
"comments last_24h": comments.filter(Comment.created_utc > day, Comment.author_id.notin_((AUTOJANNY_ID,NOTIFICATIONS_ID))).count(),
|
||||
"post votes": g.db.query(Vote.submission_id).count(),
|
||||
"post voting users": g.db.query(Vote.user_id).distinct().count(),
|
||||
|
|
|
@ -39,7 +39,7 @@ def upvoters_posts(v, username, uid):
|
|||
|
||||
page = max(1, int(request.values.get("page", 1)))
|
||||
|
||||
listing = g.db.query(Submission).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.deleted_utc == 0, Vote.vote_type==1, Submission.author_id==id, Vote.user_id==uid).order_by(Submission.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
listing = g.db.query(Submission).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.state_user_deleted_utc == None, Vote.vote_type==1, Submission.author_id==id, Vote.user_id==uid).order_by(Submission.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
|
||||
listing = [p.id for p in listing]
|
||||
next_exists = len(listing) > 25
|
||||
|
@ -60,7 +60,7 @@ def upvoters_comments(v, username, uid):
|
|||
|
||||
page = max(1, int(request.values.get("page", 1)))
|
||||
|
||||
listing = g.db.query(Comment).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.deleted_utc == 0, CommentVote.vote_type==1, Comment.author_id==id, CommentVote.user_id==uid).order_by(Comment.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
listing = g.db.query(Comment).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.state_user_deleted_utc == None, CommentVote.vote_type==1, Comment.author_id==id, CommentVote.user_id==uid).order_by(Comment.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
|
||||
listing = [c.id for c in listing]
|
||||
next_exists = len(listing) > 25
|
||||
|
@ -81,7 +81,7 @@ def downvoters_posts(v, username, uid):
|
|||
|
||||
page = max(1, int(request.values.get("page", 1)))
|
||||
|
||||
listing = g.db.query(Submission).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.deleted_utc == 0, Vote.vote_type==-1, Submission.author_id==id, Vote.user_id==uid).order_by(Submission.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
listing = g.db.query(Submission).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.state_user_deleted_utc == None, Vote.vote_type==-1, Submission.author_id==id, Vote.user_id==uid).order_by(Submission.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
|
||||
listing = [p.id for p in listing]
|
||||
next_exists = len(listing) > 25
|
||||
|
@ -102,7 +102,7 @@ def downvoters_comments(v, username, uid):
|
|||
|
||||
page = max(1, int(request.values.get("page", 1)))
|
||||
|
||||
listing = g.db.query(Comment).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.deleted_utc == 0, CommentVote.vote_type==-1, Comment.author_id==id, CommentVote.user_id==uid).order_by(Comment.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
listing = g.db.query(Comment).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.state_user_deleted_utc == None, CommentVote.vote_type==-1, Comment.author_id==id, CommentVote.user_id==uid).order_by(Comment.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
|
||||
listing = [c.id for c in listing]
|
||||
next_exists = len(listing) > 25
|
||||
|
@ -122,7 +122,7 @@ def upvoting_posts(v, username, uid):
|
|||
|
||||
page = max(1, int(request.values.get("page", 1)))
|
||||
|
||||
listing = g.db.query(Submission).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.deleted_utc == 0, Vote.vote_type==1, Vote.user_id==id, Submission.author_id==uid).order_by(Submission.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
listing = g.db.query(Submission).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.state_user_deleted_utc == None, Vote.vote_type==1, Vote.user_id==id, Submission.author_id==uid).order_by(Submission.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
|
||||
listing = [p.id for p in listing]
|
||||
next_exists = len(listing) > 25
|
||||
|
@ -143,7 +143,7 @@ def upvoting_comments(v, username, uid):
|
|||
|
||||
page = max(1, int(request.values.get("page", 1)))
|
||||
|
||||
listing = g.db.query(Comment).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.deleted_utc == 0, CommentVote.vote_type==1, CommentVote.user_id==id, Comment.author_id==uid).order_by(Comment.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
listing = g.db.query(Comment).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.state_user_deleted_utc == None, CommentVote.vote_type==1, CommentVote.user_id==id, Comment.author_id==uid).order_by(Comment.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
|
||||
listing = [c.id for c in listing]
|
||||
next_exists = len(listing) > 25
|
||||
|
@ -164,7 +164,7 @@ def downvoting_posts(v, username, uid):
|
|||
|
||||
page = max(1, int(request.values.get("page", 1)))
|
||||
|
||||
listing = g.db.query(Submission).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.deleted_utc == 0, Vote.vote_type==-1, Vote.user_id==id, Submission.author_id==uid).order_by(Submission.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
listing = g.db.query(Submission).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.state_user_deleted_utc == None, Vote.vote_type==-1, Vote.user_id==id, Submission.author_id==uid).order_by(Submission.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
|
||||
listing = [p.id for p in listing]
|
||||
next_exists = len(listing) > 25
|
||||
|
@ -185,7 +185,7 @@ def downvoting_comments(v, username, uid):
|
|||
|
||||
page = max(1, int(request.values.get("page", 1)))
|
||||
|
||||
listing = g.db.query(Comment).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.deleted_utc == 0, CommentVote.vote_type==-1, CommentVote.user_id==id, Comment.author_id==uid).order_by(Comment.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
listing = g.db.query(Comment).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.state_user_deleted_utc == None, CommentVote.vote_type==-1, CommentVote.user_id==id, Comment.author_id==uid).order_by(Comment.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
|
||||
listing = [c.id for c in listing]
|
||||
next_exists = len(listing) > 25
|
||||
|
@ -200,9 +200,9 @@ def downvoting_comments(v, username, uid):
|
|||
def upvoters(v, username):
|
||||
id = get_user(username).id
|
||||
|
||||
votes = g.db.query(Vote.user_id, func.count(Vote.user_id)).join(Submission, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.deleted_utc == 0, Vote.vote_type==1, 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(Submission, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.state_user_deleted_utc == None, Vote.vote_type==1, Submission.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, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.deleted_utc == 0, CommentVote.vote_type==1, Comment.author_id==id).group_by(CommentVote.user_id).order_by(func.count(CommentVote.user_id).desc()).all()
|
||||
votes2 = g.db.query(CommentVote.user_id, func.count(CommentVote.user_id)).join(Comment, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.state_user_deleted_utc == None, CommentVote.vote_type==1, 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))
|
||||
|
||||
|
@ -226,9 +226,9 @@ def upvoters(v, username):
|
|||
def downvoters(v, username):
|
||||
id = get_user(username).id
|
||||
|
||||
votes = g.db.query(Vote.user_id, func.count(Vote.user_id)).join(Submission, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.deleted_utc == 0, Vote.vote_type==-1, 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(Submission, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.state_user_deleted_utc == None, Vote.vote_type==-1, Submission.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, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.deleted_utc == 0, CommentVote.vote_type==-1, Comment.author_id==id).group_by(CommentVote.user_id).order_by(func.count(CommentVote.user_id).desc()).all()
|
||||
votes2 = g.db.query(CommentVote.user_id, func.count(CommentVote.user_id)).join(Comment, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.state_user_deleted_utc == None, CommentVote.vote_type==-1, 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))
|
||||
|
||||
|
@ -250,9 +250,9 @@ def downvoters(v, username):
|
|||
def upvoting(v, username):
|
||||
id = get_user(username).id
|
||||
|
||||
votes = g.db.query(Submission.author_id, func.count(Submission.author_id)).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.deleted_utc == 0, Vote.vote_type==1, Vote.user_id==id).group_by(Submission.author_id).order_by(func.count(Submission.author_id).desc()).all()
|
||||
votes = g.db.query(Submission.author_id, func.count(Submission.author_id)).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.state_user_deleted_utc == None, Vote.vote_type==1, Vote.user_id==id).group_by(Submission.author_id).order_by(func.count(Submission.author_id).desc()).all()
|
||||
|
||||
votes2 = g.db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.deleted_utc == 0, CommentVote.vote_type==1, CommentVote.user_id==id).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).all()
|
||||
votes2 = g.db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.state_user_deleted_utc == None, CommentVote.vote_type==1, CommentVote.user_id==id).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).all()
|
||||
|
||||
votes = Counter(dict(votes)) + Counter(dict(votes2))
|
||||
|
||||
|
@ -274,9 +274,9 @@ def upvoting(v, username):
|
|||
def downvoting(v, username):
|
||||
id = get_user(username).id
|
||||
|
||||
votes = g.db.query(Submission.author_id, func.count(Submission.author_id)).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.deleted_utc == 0, Vote.vote_type==-1, Vote.user_id==id).group_by(Submission.author_id).order_by(func.count(Submission.author_id).desc()).all()
|
||||
votes = g.db.query(Submission.author_id, func.count(Submission.author_id)).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost == False, Submission.is_banned == False, Submission.state_user_deleted_utc == None, Vote.vote_type==-1, Vote.user_id==id).group_by(Submission.author_id).order_by(func.count(Submission.author_id).desc()).all()
|
||||
|
||||
votes2 = g.db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.deleted_utc == 0, CommentVote.vote_type==-1, CommentVote.user_id==id).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).all()
|
||||
votes2 = g.db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost == False, Comment.is_banned == False, Comment.state_user_deleted_utc == None, CommentVote.vote_type==-1, CommentVote.user_id==id).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).all()
|
||||
|
||||
votes = Counter(dict(votes)) + Counter(dict(votes2))
|
||||
|
||||
|
@ -754,7 +754,7 @@ def u_username_comments(username, v=None):
|
|||
|
||||
if not v or (v.id != u.id and v.admin_level < 2):
|
||||
comments = comments.filter(
|
||||
Comment.deleted_utc == 0,
|
||||
Comment.state_user_deleted_utc == None,
|
||||
Comment.is_banned == False,
|
||||
Comment.ghost == False,
|
||||
(Comment.filter_state != 'filtered') & (Comment.filter_state != 'removed')
|
||||
|
|
|
@ -44,8 +44,7 @@ def get_duty(u: User) -> Optional[VolunteerDutyJanitor]:
|
|||
# find reported not-deleted comments not made by the current user
|
||||
reported_comments = g.db.query(Comment) \
|
||||
.where(Comment.filter_state == 'reported') \
|
||||
.where(Comment.deleted_utc == 0) \
|
||||
.where(Comment.is_approved == None) \
|
||||
.where(Comment.state_user_deleted_utc == None) \
|
||||
.where(Comment.author_id != u.id) \
|
||||
.with_entities(Comment.id)
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
{%- include 'component/comment/user_info.html' -%}
|
||||
|
||||
<div class="comment-body">
|
||||
<div id="{% if comment_info and comment_info.id == c.id %}context{%else%}comment-{{c.id}}-only{% endif %}" class="{% if c.unread %}unread{% endif %} comment-{{c.id}}-only comment-anchor {% if comment_info and comment_info.id == c.id %}context{%endif%}{% if c.is_banned %} banned{% endif %}{% if c.deleted_utc %} deleted{% endif %}">
|
||||
<div id="{% if comment_info and comment_info.id == c.id %}context{%else%}comment-{{c.id}}-only{% endif %}" class="{% if c.unread %}unread{% endif %} comment-{{c.id}}-only comment-anchor {% if comment_info and comment_info.id == c.id %}context{%endif%}{% if c.is_banned %} banned{% endif %}{% if c.state_user_deleted_utc %} deleted{% endif %}">
|
||||
{%- include 'component/comment/reports.html'-%}
|
||||
{% if c.is_banned and c.ban_reason %} {# TODO: shouldn't be visible. See #359 #}
|
||||
<div id="comment-banned-warning" class="comment-text text-removed mb-0">removed by @{{c.ban_reason}}</div>
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
{% if c.parent_submission %}
|
||||
{% if v and c.author_id == v.id %}
|
||||
<button class="btn caction py-0 nobackground px-1 text-muted" onclick="toggleEdit('{{c.id}}')"><i class="fas fa-edit fa-fw"></i>Edit</button>
|
||||
<button id="undelete-{{c.id}}" class="btn caction py-0 nobackground px-1 text-muted {% if not c.deleted_utc %}d-none{% endif %}" onclick="post_toast2(this,'/undelete/comment/{{c.id}}','delete-{{c.id}}','undelete-{{c.id}}');document.getElementById('comment-{{c.id}}').classList.remove('deleted')"><i class="fas fa-trash-alt fa-fw"></i>Undelete</button>
|
||||
<button id="delete-{{c.id}}" class="btn caction py-0 nobackground px-1 text-muted {% if c.deleted_utc %}d-none{% endif %}" data-bs-toggle="modal" data-bs-target="#deleteCommentModal" onclick="delete_commentModal('{{c.id}}')"><i class="fas fa-trash-alt fa-fw"></i>Delete</button>
|
||||
<button id="undelete-{{c.id}}" class="btn caction py-0 nobackground px-1 text-muted {% if not c.state_user_deleted_utc %}d-none{% endif %}" onclick="post_toast2(this,'/undelete/comment/{{c.id}}','delete-{{c.id}}','undelete-{{c.id}}');document.getElementById('comment-{{c.id}}').classList.remove('deleted')"><i class="fas fa-trash-alt fa-fw"></i>Undelete</button>
|
||||
<button id="delete-{{c.id}}" class="btn caction py-0 nobackground px-1 text-muted {% if c.state_user_deleted_utc %}d-none{% endif %}" data-bs-toggle="modal" data-bs-target="#deleteCommentModal" onclick="delete_commentModal('{{c.id}}')"><i class="fas fa-trash-alt fa-fw"></i>Delete</button>
|
||||
{% elif v and c.body %}
|
||||
<button class="btn caction py-0 nobackground px-1 text-muted" onclick="expandMarkdown(this,'{{c.id}}')"><i class="fas text-expand-icon-{{c.id}} fa-expand-alt"></i><span>View source</span></button>
|
||||
{% endif %}
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
<a id="undistinguish2-{{c.id}}" class="list-group-item {% if not c.distinguish_level %}d-none{% endif %} text-info" role="button" onclick="post_toast2(this,'/distinguish_comment/{{c.id}}','distinguish2-{{c.id}}','undistinguish2-{{c.id}}')" data-bs-dismiss="modal"><i class="fas fa-id-badge text-info mr-2"></i>Undistinguish</a>
|
||||
{% endif %}
|
||||
|
||||
<a id="undelete2-{{c.id}}" class="{% if not c.deleted_utc %}d-none{% endif %} list-group-item text-success" role="button" onclick="post_toast2(this,'/undelete/comment/{{c.id}}', 'delete2-{{c.id}}', 'undelete2-{{c.id}}');document.getElementById('comment-{{c.id}}').classList.remove('deleted')" data-bs-dismiss="modal"><i class="far fa-trash-alt text-success mr-2"></i>Undelete</a>
|
||||
<a id="undelete2-{{c.id}}" class="{% if not c.state_user_deleted_utc %}d-none{% endif %} list-group-item text-success" role="button" onclick="post_toast2(this,'/undelete/comment/{{c.id}}', 'delete2-{{c.id}}', 'undelete2-{{c.id}}');document.getElementById('comment-{{c.id}}').classList.remove('deleted')" data-bs-dismiss="modal"><i class="far fa-trash-alt text-success mr-2"></i>Undelete</a>
|
||||
|
||||
<a id="delete2-{{c.id}}" class="{% if c.deleted_utc %}d-none{% endif %} list-group-item text-danger" role="button" data-bs-toggle="modal" data-bs-dismiss="modal" data-bs-target="#deleteCommentModal" onclick="delete_commentModal('{{c.id}}')"><i class="far fa-trash-alt text-danger mr-2"></i>Delete</a>
|
||||
<a id="delete2-{{c.id}}" class="{% if c.state_user_deleted_utc %}d-none{% endif %} list-group-item text-danger" role="button" data-bs-toggle="modal" data-bs-dismiss="modal" data-bs-target="#deleteCommentModal" onclick="delete_commentModal('{{c.id}}')"><i class="far fa-trash-alt text-danger mr-2"></i>Delete</a>
|
||||
|
||||
<a id="mark2-{{c.id}}" class="{% if c.over_18 %}d-none{% endif %} list-group-item text-danger" role="button" onclick="post_toast2(this,'/toggle_comment_nsfw/{{c.id}}','mark2-{{c.id}}','unmark2-{{c.id}}')" data-bs-dismiss="modal"><i class="fas fa-eye-evil text-danger mr-2"></i>Mark +18</a>
|
||||
<a id="unmark2-{{c.id}}" class="{% if not c.over_18 %}d-none{% endif %} list-group-item text-danger" role="button" onclick="post_toast2(this,'/toggle_comment_nsfw/{{c.id}}','mark2-{{c.id}}','unmark2-{{c.id}}')" data-bs-dismiss="modal"><i class="fas fa-eye-evil text-danger mr-2"></i>Unmark +18</a>
|
||||
|
|
|
@ -30,9 +30,9 @@
|
|||
<a id="unpin-profile-{{p.id}}" class="{% if not p.is_pinned %}d-none{% endif %} list-inline-item text-muted" role="button" onclick="post_toast2(this,'/pin/{{p.id}}','unpin-profile-{{p.id}}','pin-profile-{{p.id}}')"><i class="fas fa-thumbtack fa-rotate--45"></i>Unpin from profile</a>
|
||||
{% endif %}
|
||||
|
||||
<a id="undelete2-{{p.id}}" class="{% if not p.deleted_utc %}d-none{% endif %} list-inline-item" role="button" onclick="post_toast2(this,'/undelete_post/{{p.id}}', 'delete2-{{p.id}}', 'undelete2-{{p.id}}');document.getElementById('post-{{p.id}}').classList.remove('deleted')"><i class="fas fa-trash-alt"></i>Undelete</a>
|
||||
<a id="undelete2-{{p.id}}" class="{% if not p.state_user_deleted_utc %}d-none{% endif %} list-inline-item" role="button" onclick="post_toast2(this,'/undelete_post/{{p.id}}', 'delete2-{{p.id}}', 'undelete2-{{p.id}}');document.getElementById('post-{{p.id}}').classList.remove('deleted')"><i class="fas fa-trash-alt"></i>Undelete</a>
|
||||
|
||||
<a id="delete2-{{p.id}}" class="{% if p.deleted_utc %}d-none{% endif %} list-inline-item" role="button" data-bs-toggle="modal" data-bs-dismiss="modal" data-bs-target="#deletePostModal" onclick="delete_postModal('{{p.id}}')"><i class="fas fa-trash-alt"></i>Delete</a>
|
||||
<a id="delete2-{{p.id}}" class="{% if p.state_user_deleted_utc %}d-none{% endif %} list-inline-item" role="button" data-bs-toggle="modal" data-bs-dismiss="modal" data-bs-target="#deletePostModal" onclick="delete_postModal('{{p.id}}')"><i class="fas fa-trash-alt"></i>Delete</a>
|
||||
{% endif %}
|
||||
|
||||
{% if v and v.admin_level > 1 and p.filter_state == 'filtered' %}
|
||||
|
|
|
@ -32,9 +32,9 @@
|
|||
{% endif %}
|
||||
|
||||
|
||||
<button id="undelete-{{p.id}}" class="{% if not p.deleted_utc %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-success" role="button" onclick="post_toast2(this,'/undelete_post/{{p.id}}', 'delete-{{p.id}}', 'undelete-{{p.id}}');document.getElementById('post-{{p.id}}').classList.remove('deleted')" data-bs-dismiss="modal"><i class="far fa-trash-alt text-center mr-3"></i>Undelete</button>
|
||||
<button id="undelete-{{p.id}}" class="{% if not p.state_user_deleted_utc %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-success" role="button" onclick="post_toast2(this,'/undelete_post/{{p.id}}', 'delete-{{p.id}}', 'undelete-{{p.id}}');document.getElementById('post-{{p.id}}').classList.remove('deleted')" data-bs-dismiss="modal"><i class="far fa-trash-alt text-center mr-3"></i>Undelete</button>
|
||||
|
||||
<button id="delete-{{p.id}}" class="{% if p.deleted_utc %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-danger" data-bs-toggle="modal" data-bs-dismiss="modal" data-bs-target="#deletePostModal" onclick="delete_postModal('{{p.id}}')"><i class="far fa-trash-alt mr-3"></i>Delete</button>
|
||||
<button id="delete-{{p.id}}" class="{% if p.state_user_deleted_utc %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-danger" data-bs-toggle="modal" data-bs-dismiss="modal" data-bs-target="#deletePostModal" onclick="delete_postModal('{{p.id}}')"><i class="far fa-trash-alt mr-3"></i>Delete</button>
|
||||
|
||||
|
||||
{# <button id="club3-{{p.id}}" class="{% if p.club %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-danger text-left" role="button" onclick="post_toast2(this,'/toggle_club/{{p.id}}','club3-{{p.id}}','unclub3-{{p.id}}')" data-bs-dismiss="modal"><i class="fas fa-eye-slash mr-3"></i>Mark club</button>
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
<meta charset="utf-8">
|
||||
<meta property="og:type" content="article">
|
||||
|
||||
{% if comment_info and not comment_info.is_banned and not comment_info.deleted_utc %}
|
||||
{% if comment_info and not comment_info.is_banned and not comment_info.state_user_deleted_utc %}
|
||||
<title>{{'@'+comment_info.author_name}} comments on "{{p.plaintitle(v)}} - {{SITE_TITLE}}"</title>
|
||||
|
||||
|
||||
|
@ -133,9 +133,9 @@
|
|||
<div class="row mb-3" style="background-color:var(--gray-600)">
|
||||
<div id="post-root" class="col-12">
|
||||
<div class="card border-0 mt-3{% if p.is_banned %} banned{% endif %}{% if p.stickied %} stickied{% endif %}{% if voted==1 %} upvoted{% elif voted==-1 %} downvoted{% endif %}">
|
||||
<div id="post-{{p.id}}" class="{% if p.deleted_utc %}deleted {% endif %}d-flex flex-row-reverse flex-nowrap justify-content-end">
|
||||
<div id="post-{{p.id}}" class="{% if p.state_user_deleted_utc %}deleted {% endif %}d-flex flex-row-reverse flex-nowrap justify-content-end">
|
||||
|
||||
<div id="post-content" class="{% if p.deleted_utc %}deleted {% endif %}card-block w-100 my-md-auto">
|
||||
<div id="post-content" class="{% if p.state_user_deleted_utc %}deleted {% endif %}card-block w-100 my-md-auto">
|
||||
|
||||
<div class="post-meta text-left mb-2">
|
||||
{% if p.bannedfor %}
|
||||
|
@ -512,7 +512,7 @@
|
|||
</script>
|
||||
{% endif %}
|
||||
|
||||
{% elif not p.replies and p.deleted_utc == 0 %}
|
||||
{% elif not p.replies and p.state_user_deleted_utc == None %}
|
||||
<div class="comment-section text-center py-7" id="replies-of-{{p.id}}">
|
||||
<div class="row no-gutters" id="placeholder-comment">
|
||||
<div class="col">
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div id="post-{{p.id}}" class="card{% if p.is_banned %} banned{% endif %}{% if p.deleted_utc %} deleted{% endif %}{% if p.stickied %} stickied{% endif %}{% if voted==1 %} upvoted{% elif voted==-1 %} downvoted{% endif %}{% if p.over_18 %} nsfw{% endif %}">
|
||||
<div id="post-{{p.id}}" class="card{% if p.is_banned %} banned{% endif %}{% if p.state_user_deleted_utc %} deleted{% endif %}{% if p.stickied %} stickied{% endif %}{% if voted==1 %} upvoted{% elif voted==-1 %} downvoted{% endif %}{% if p.over_18 %} nsfw{% endif %}">
|
||||
|
||||
<div class="d-flex flex-row flex-nowrap justify-content-end align-items-center">
|
||||
|
||||
|
|
|
@ -19,7 +19,9 @@ depends_on = None
|
|||
|
||||
|
||||
def upgrade():
|
||||
volunteer_janitor_recalc_all_comments(Session(bind=op.get_bind()))
|
||||
# this is now disabled because this code is no longer compatible with this version of the DB
|
||||
#volunteer_janitor_recalc_all_comments(Session(bind=op.get_bind()))
|
||||
pass
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
"""Move 'deleted_utc' into 'state_user_deleted_utc'.
|
||||
|
||||
Revision ID: 8337558f4f36
|
||||
Revises: 6403c9151c12
|
||||
Create Date: 2023-06-11 09:09:00.235602+00:00
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '8337558f4f36'
|
||||
down_revision = '6403c9151c12'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('comments', sa.Column('state_user_deleted_utc', sa.DateTime(), nullable=True))
|
||||
op.drop_column('comments', 'deleted_utc')
|
||||
op.add_column('submissions', sa.Column('state_user_deleted_utc', sa.DateTime(), nullable=True))
|
||||
op.drop_index('subimssion_binary_group_idx', table_name='submissions')
|
||||
op.create_index('subimssion_binary_group_idx', 'submissions', ['is_banned', 'state_user_deleted_utc', 'over_18'], unique=False)
|
||||
op.drop_index('submission_isdeleted_idx', table_name='submissions')
|
||||
op.create_index('submission_isdeleted_idx', 'submissions', ['state_user_deleted_utc'], unique=False)
|
||||
op.drop_index('submission_new_sort_idx', table_name='submissions')
|
||||
op.create_index('submission_new_sort_idx', 'submissions', ['is_banned', 'state_user_deleted_utc', sa.text('created_utc DESC'), 'over_18'], unique=False)
|
||||
op.drop_column('submissions', 'deleted_utc')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('submissions', sa.Column('deleted_utc', sa.INTEGER(), server_default=sa.text('0'), autoincrement=False, nullable=False))
|
||||
op.drop_index('submission_new_sort_idx', table_name='submissions')
|
||||
op.create_index('submission_new_sort_idx', 'submissions', ['is_banned', 'deleted_utc', 'created_utc', 'over_18'], unique=False)
|
||||
op.drop_index('submission_isdeleted_idx', table_name='submissions')
|
||||
op.create_index('submission_isdeleted_idx', 'submissions', ['deleted_utc'], unique=False)
|
||||
op.drop_index('subimssion_binary_group_idx', table_name='submissions')
|
||||
op.create_index('subimssion_binary_group_idx', 'submissions', ['is_banned', 'deleted_utc', 'over_18'], unique=False)
|
||||
op.drop_column('submissions', 'state_user_deleted_utc')
|
||||
op.add_column('comments', sa.Column('deleted_utc', sa.INTEGER(), server_default=sa.text('0'), autoincrement=False, nullable=False))
|
||||
op.drop_column('comments', 'state_user_deleted_utc')
|
||||
# ### end Alembic commands ###
|
Loading…
Add table
Add a link
Reference in a new issue