add moderator kwarg to moderation methods.

This commit is contained in:
Jacob Mason 2010-08-06 21:13:06 -05:00
parent 63e96b2fd5
commit 1d98a50bdc
3 changed files with 12 additions and 4 deletions

View File

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

View File

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

View File

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