From f9705fc5b7bbfb30870751da40c5f59218d77859 Mon Sep 17 00:00:00 2001
From: Georg Brandl
Date: Sun, 21 Nov 2010 20:47:32 +0100
Subject: [PATCH] Remove comment rejection; delete is fine for that now.
---
sphinx/themes/basic/static/websupport.js | 27 ++-----------------
sphinx/websupport/__init__.py | 13 ---------
.../websupport/storage/sqlalchemystorage.py | 8 ------
3 files changed, 2 insertions(+), 46 deletions(-)
diff --git a/sphinx/themes/basic/static/websupport.js b/sphinx/themes/basic/static/websupport.js
index 198795f00..bf8a85d58 100644
--- a/sphinx/themes/basic/static/websupport.js
+++ b/sphinx/themes/basic/static/websupport.js
@@ -90,10 +90,6 @@
acceptComment($(this).attr('id').substring(2));
return false;
});
- $('a.reject-comment').live("click", function() {
- rejectComment($(this).attr('id').substring(2));
- return false;
- });
$('a.delete-comment').live("click", function() {
deleteComment($(this).attr('id').substring(2));
return false;
@@ -334,23 +330,6 @@
});
}
- function rejectComment(id) {
- $.ajax({
- type: 'POST',
- url: opts.rejectCommentURL,
- data: {id: id},
- success: function(data, textStatus, request) {
- var div = $('#cd' + id);
- div.slideUp('fast', function() {
- div.remove();
- });
- },
- error: function(request, textStatus, error) {
- showError('Oops, there was a problem rejecting the comment.');
- }
- });
- }
-
function deleteComment(id) {
$.ajax({
type: 'POST',
@@ -568,7 +547,7 @@
/** Create a div to display a comment in. */
function createCommentDiv(comment) {
- if (!comment.displayed) {
+ if (!comment.displayed && !opts.moderator) {
return $('Thank you! Your comment will show up once it is has '
+ ' been approved by a moderator.
');
}
@@ -579,7 +558,7 @@
var context = $.extend({}, opts, comment);
var div = $(renderTemplate(commentTemplate, context));
- // If the user has voted on this comment, highlight the correct arrow.
+ // If the user has voted on this comment, highblight the correct arrow.
if (comment.vote) {
var direction = (comment.vote == 1) ? 'u' : 'd';
div.find('#' + direction + 'v' + comment.id).hide();
@@ -679,7 +658,6 @@
addCommentURL: '/_add_comment',
getCommentsURL: '/_get_comments',
acceptCommentURL: '/_accept_comment',
- rejectCommentURL: '/_reject_comment',
deleteCommentURL: '/_delete_comment',
commentImage: '/static/_static/comment.png',
closeCommentImage: '/static/_static/comment-close.png',
@@ -770,7 +748,6 @@
\
\
\
- \
\
\
\
diff --git a/sphinx/websupport/__init__.py b/sphinx/websupport/__init__.py
index 35696c22c..26392b984 100644
--- a/sphinx/websupport/__init__.py
+++ b/sphinx/websupport/__init__.py
@@ -383,19 +383,6 @@ class WebSupport(object):
raise errors.UserNotAuthorizedError()
self.storage.accept_comment(comment_id)
- def reject_comment(self, comment_id, moderator=False):
- """Reject a comment that is pending moderation.
-
- This raises :class:`~sphinx.websupport.errors.UserNotAuthorizedError`
- if moderator is False.
-
- :param comment_id: The id of the comment that was accepted.
- :param moderator: Whether the user making the request is a moderator.
- """
- if not moderator:
- raise errors.UserNotAuthorizedError()
- self.storage.reject_comment(comment_id)
-
def _make_base_comment_options(self):
"""Helper method to create the part of the COMMENT_OPTIONS javascript
that remains the same throughout the lifetime of the
diff --git a/sphinx/websupport/storage/sqlalchemystorage.py b/sphinx/websupport/storage/sqlalchemystorage.py
index 78991639d..b58b1198e 100644
--- a/sphinx/websupport/storage/sqlalchemystorage.py
+++ b/sphinx/websupport/storage/sqlalchemystorage.py
@@ -172,11 +172,3 @@ class SQLAlchemyStorage(StorageBackend):
session.commit()
session.close()
-
- def reject_comment(self, comment_id):
- session = Session()
- comment = session.query(Comment).filter(Comment.id == comment_id).one()
- session.delete(comment)
-
- session.commit()
- session.close()