Lockable comment threads

Disable new comments and comment replies when a post is locked.
This commit is contained in:
Florence Yeun
2015-08-28 15:58:30 -07:00
parent 4a38e25a20
commit ac5bec35b3
6 changed files with 12 additions and 6 deletions

View File

@@ -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

View File

@@ -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:

View File

@@ -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')),

View File

@@ -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)

View File

@@ -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

View File

@@ -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")}