mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-04-27 03:00:12 -04:00
Lockable comment threads
Disable new comments and comment replies when a post is locked.
This commit is contained in:
@@ -1980,8 +1980,10 @@ class ApiController(RedditController):
|
||||
not sr.should_ratelimit(c.user, 'comment')):
|
||||
should_ratelimit = False
|
||||
|
||||
if link._age > sr.archive_age:
|
||||
c.errors.add(errors.TOO_OLD, field = "parent")
|
||||
if link.archived:
|
||||
c.errors.add(errors.TOO_OLD, field="parent")
|
||||
elif link.locked:
|
||||
c.errors.add(errors.THREAD_LOCKED, field="parent")
|
||||
|
||||
hooks.get_hook("comment.validate").call(sr=sr, link=link,
|
||||
parent_comment=parent_comment)
|
||||
@@ -1995,7 +1997,8 @@ class ApiController(RedditController):
|
||||
commentform.has_errors("ratelimit", errors.RATELIMIT) or
|
||||
commentform.has_errors("parent", errors.DELETED_COMMENT,
|
||||
errors.DELETED_LINK, errors.TOO_OLD, errors.USER_BLOCKED,
|
||||
errors.USER_MUTED, errors.MUTED_FROM_SUBREDDIT)
|
||||
errors.USER_MUTED, errors.MUTED_FROM_SUBREDDIT,
|
||||
errors.THREAD_LOCKED)
|
||||
):
|
||||
return
|
||||
|
||||
|
||||
@@ -357,7 +357,7 @@ class FrontController(RedditController):
|
||||
if c.user_is_loggedin and can_comment_link(article) and not is_api():
|
||||
#no comment box for permalinks
|
||||
display = False
|
||||
if not comment and not article.archived:
|
||||
if not comment and not article.archived and not article.locked:
|
||||
display = True
|
||||
|
||||
if article.promoted:
|
||||
|
||||
@@ -113,6 +113,7 @@ error_list = dict((
|
||||
('NO_SELFS', _("that subreddit doesn't allow text posts")),
|
||||
('NO_LINKS', _("that subreddit only allows text posts")),
|
||||
('TOO_OLD', _("that's a piece of history now; it's too late to reply to it")),
|
||||
('THREAD_LOCKED', _("Comments are locked.")),
|
||||
('BAD_CSS_NAME', _('invalid css name')),
|
||||
('BAD_CSS', _('invalid css')),
|
||||
('BAD_COLOR', _('invalid color')),
|
||||
|
||||
@@ -1869,7 +1869,7 @@ class CommentPane(Templated):
|
||||
# buttons and do the same for loggedout users so they can use the
|
||||
# same cached page. reply buttons will be hidden client side for
|
||||
# loggedout users
|
||||
self.can_reply = article._age < article.subreddit_slow.archive_age
|
||||
self.can_reply = not article.archived and not article.locked
|
||||
|
||||
builder = CommentBuilder(
|
||||
article, sort, comment=comment, context=context, num=num, **kw)
|
||||
|
||||
@@ -112,6 +112,7 @@ class Link(Thing, Printable):
|
||||
managed_promo=False,
|
||||
pending=False,
|
||||
disable_comments=False,
|
||||
locked=False,
|
||||
selftext='',
|
||||
sendreplies=True,
|
||||
ip='0.0.0.0',
|
||||
@@ -1406,7 +1407,7 @@ class Comment(Thing, Printable):
|
||||
else:
|
||||
item.parent_permalink = None
|
||||
|
||||
item.can_reply = item.link._age < item.subreddit.archive_age
|
||||
item.can_reply = not item.link.archived and not item.link.locked
|
||||
if c.user_is_loggedin:
|
||||
item.can_reply &= item.sr_id in can_reply_srs
|
||||
|
||||
|
||||
@@ -159,6 +159,7 @@
|
||||
${error_field("RATELIMIT", "ratelimit", "span")}
|
||||
${error_field("NO_TEXT", thing.name, "span")}
|
||||
${error_field("TOO_OLD", "parent", "span")}
|
||||
${error_field("THREAD_LOCKED", "parent", "span")}
|
||||
${error_field("DELETED_COMMENT", "parent", "span")}
|
||||
${error_field("DELETED_LINK", "parent", "span")}
|
||||
${error_field("USER_BLOCKED", "parent", "span")}
|
||||
|
||||
Reference in New Issue
Block a user