diff --git a/files/classes/comment.py b/files/classes/comment.py index efbb09e44..b2de17581 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -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 diff --git a/files/classes/cron/submission.py b/files/classes/cron/submission.py index 8022b8f50..a29c720ab 100644 --- a/files/classes/cron/submission.py +++ b/files/classes/cron/submission.py @@ -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: diff --git a/files/classes/submission.py b/files/classes/submission.py index d24bf205c..c3cc7f881 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -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 diff --git a/files/classes/user.py b/files/classes/user.py index 0ed209d0d..11f2bfbcb 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -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('%

New site mention: = 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)) diff --git a/files/routes/comments.py b/files/routes/comments.py index 973ab9eb6..25a628538 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -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() diff --git a/files/routes/front.py b/files/routes/front.py index 75800883f..3e9de9bb8 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -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('%

New site mention: 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) diff --git a/files/routes/search.py b/files/routes/search.py index f52be14f4..d6b9b2cea 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -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): diff --git a/files/routes/static.py b/files/routes/static.py index 9458d916f..f3876ad2d 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -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(), diff --git a/files/routes/users.py b/files/routes/users.py index 89fd0f5ea..b31e6accb 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -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') diff --git a/files/routes/volunteer_janitor.py b/files/routes/volunteer_janitor.py index 31130a22b..836a11ee4 100644 --- a/files/routes/volunteer_janitor.py +++ b/files/routes/volunteer_janitor.py @@ -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) diff --git a/files/templates/comments.html b/files/templates/comments.html index 2f54cc65c..dd1df2faf 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -81,7 +81,7 @@ {%- include 'component/comment/user_info.html' -%}

-
+
{%- include 'component/comment/reports.html'-%} {% if c.is_banned and c.ban_reason %} {# TODO: shouldn't be visible. See #359 #}
removed by @{{c.ban_reason}}
diff --git a/files/templates/component/comment/actions_desktop.html b/files/templates/component/comment/actions_desktop.html index 75521f7a2..29af4d993 100644 --- a/files/templates/component/comment/actions_desktop.html +++ b/files/templates/component/comment/actions_desktop.html @@ -12,8 +12,8 @@ {% if c.parent_submission %} {% if v and c.author_id == v.id %} - - + + {% elif v and c.body %} {% endif %} diff --git a/files/templates/component/comment/actions_mobile.html b/files/templates/component/comment/actions_mobile.html index 9b5b00fa0..8b5f047cb 100644 --- a/files/templates/component/comment/actions_mobile.html +++ b/files/templates/component/comment/actions_mobile.html @@ -28,9 +28,9 @@
Undistinguish {% endif %} - Undelete + Undelete - Delete + Delete Mark +18 Unmark +18 diff --git a/files/templates/component/post/actions.html b/files/templates/component/post/actions.html index a9202ca16..12012c69c 100644 --- a/files/templates/component/post/actions.html +++ b/files/templates/component/post/actions.html @@ -30,9 +30,9 @@ Unpin from profile {% endif %} - Undelete + Undelete - Delete + Delete {% endif %} {% if v and v.admin_level > 1 and p.filter_state == 'filtered' %} diff --git a/files/templates/component/post/actions_mobile.html b/files/templates/component/post/actions_mobile.html index 19568df86..df47e3d05 100644 --- a/files/templates/component/post/actions_mobile.html +++ b/files/templates/component/post/actions_mobile.html @@ -32,9 +32,9 @@ {% endif %} - + - + {# diff --git a/files/templates/submission.html b/files/templates/submission.html index 1f790652f..43d0fbc53 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -38,7 +38,7 @@ -{% 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 %} {{'@'+comment_info.author_name}} comments on "{{p.plaintitle(v)}} - {{SITE_TITLE}}" @@ -133,9 +133,9 @@
-
+
-
+