mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
add moderator kwarg to moderation methods.
This commit is contained in:
parent
63e96b2fd5
commit
1d98a50bdc
@ -286,16 +286,20 @@ class WebSupport(object):
|
||||
"""
|
||||
self.storage.update_username(old_username, new_username)
|
||||
|
||||
def accept_comment(self, comment_id):
|
||||
def accept_comment(self, comment_id, moderator=False):
|
||||
"""Accept a comment that is pending moderation.
|
||||
|
||||
:param comment_id: The id of the comment that was accepted.
|
||||
"""
|
||||
if not moderator:
|
||||
raise UserNotAuthorizedError()
|
||||
self.storage.accept_comment(comment_id)
|
||||
|
||||
def reject_comment(self, comment_id):
|
||||
def reject_comment(self, comment_id, moderator=False):
|
||||
"""Reject a comment that is pending moderation.
|
||||
|
||||
:param comment_id: The id of the comment that was accepted.
|
||||
"""
|
||||
if not moderator:
|
||||
raise UserNotAuthorizedError()
|
||||
self.storage.reject_comment(comment_id)
|
||||
|
@ -142,6 +142,7 @@ class Comment(Base):
|
||||
'node': node,
|
||||
'parent': parent,
|
||||
'rating': self.rating,
|
||||
'displayed': self.displayed,
|
||||
'age': delta.seconds,
|
||||
'time': time,
|
||||
'vote': vote or 0,
|
||||
|
@ -234,8 +234,11 @@ def test_moderation(support):
|
||||
displayed=False)
|
||||
# Make sure the moderation_callback is called.
|
||||
assert called == True
|
||||
support.accept_comment(accepted['id'])
|
||||
support.reject_comment(rejected['id'])
|
||||
# Make sure the user must be a moderator.
|
||||
raises(UserNotAuthorizedError, support.accept_comment, accepted['id'])
|
||||
raises(UserNotAuthorizedError, support.reject_comment, accepted['id'])
|
||||
support.accept_comment(accepted['id'], moderator=True)
|
||||
support.reject_comment(rejected['id'], moderator=True)
|
||||
comments = support.get_data(3)['comments']
|
||||
assert len(comments) == 1
|
||||
comments = support.get_data(3, moderator=True)['comments']
|
||||
|
Loading…
Reference in New Issue
Block a user