diff --git a/r2/r2/controllers/api.py b/r2/r2/controllers/api.py index 496eeaaeb..2513f8595 100644 --- a/r2/r2/controllers/api.py +++ b/r2/r2/controllers/api.py @@ -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 diff --git a/r2/r2/controllers/front.py b/r2/r2/controllers/front.py index bef9f96c7..2049f6a87 100644 --- a/r2/r2/controllers/front.py +++ b/r2/r2/controllers/front.py @@ -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: diff --git a/r2/r2/lib/errors.py b/r2/r2/lib/errors.py index 38017d0db..206f951fd 100644 --- a/r2/r2/lib/errors.py +++ b/r2/r2/lib/errors.py @@ -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')), diff --git a/r2/r2/lib/pages/pages.py b/r2/r2/lib/pages/pages.py index d3d49a383..417e583c2 100644 --- a/r2/r2/lib/pages/pages.py +++ b/r2/r2/lib/pages/pages.py @@ -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) diff --git a/r2/r2/models/link.py b/r2/r2/models/link.py index df35cc9ac..2123fbb64 100644 --- a/r2/r2/models/link.py +++ b/r2/r2/models/link.py @@ -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 diff --git a/r2/r2/templates/usertext.html b/r2/r2/templates/usertext.html index 0b13bc1b0..7ff16999a 100644 --- a/r2/r2/templates/usertext.html +++ b/r2/r2/templates/usertext.html @@ -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")}