Locking: Remove for archived posts

Do not allow archived posts to be locked or unlocked, since they
cannot receive new comments or votes.
This commit is contained in:
Florence Yeun
2015-09-16 16:58:58 -07:00
parent 66d8a68fe7
commit 71de14d57b
2 changed files with 9 additions and 2 deletions

View File

@@ -1457,6 +1457,9 @@ class ApiController(RedditController):
subreddit=thing.subreddit_slow.name):
abort(404, 'not found')
if thing.archived:
return abort(400, "Bad Request")
thing.locked = True
thing._commit()
@@ -1480,6 +1483,9 @@ class ApiController(RedditController):
subreddit=thing.subreddit_slow.name):
abort(404, 'not found')
if thing.archived:
return abort(400, "Bad Request")
thing.locked = False
thing._commit()

View File

@@ -97,8 +97,9 @@ class LinkButtons(PrintableButtons):
editable = is_author and thing_editable and not thing_takendown
show_lock = show_unlock = False
if thing.can_ban and feature.is_enabled('thread_locking',
subreddit=thing.subreddit.name):
lockable = thing.can_ban and not thing.archived
if (lockable and feature.is_enabled('thread_locking',
subreddit=thing.subreddit.name)):
show_lock = not thing.locked
show_unlock = not show_lock