return votes_today
+ def can_use_canned_comments(self):
+ # The canned comments feature is available only for admins and moderators,
+ # and only if the "Use canned comments" setting is activated in the administration.
+ if (self.is_superuser or self.is_staff) and settings.USE_CANNED_COMMENTS:
+ return True
+ else:
+ return False
+
@true_if_is_super_or_staff
def can_view_deleted_post(self, post):
return post.author == self
from base import Setting, SettingSet
from forms import StringListWidget
+from django.utils.encoding import smart_unicode
from django.utils.translation import ugettext_lazy as _
from django.forms.widgets import Textarea
MODERATION_SET = SettingSet('moderation', _('Moderation settings'), _("Define the moderation workflow of your site"), 100)
+USE_CANNED_COMMENTS = Setting('USE_CANNED_COMMENTS', True, MODERATION_SET, dict(
+label = _("Use canned comments"),
+help_text = _("If you check, the canned comments feature will be activated, allowing moderators to use canned patterns for their comments."),
+required=False))
+
+CANNED_COMMENTS = Setting('CANNED_COMMENTS',
+[
+"We require all postings to have a clear, specific QUESTION in the title field. Please edit this right away to rephrase the title as a proper question.",
+],
+MODERATION_SET, dict(
+label = _("Canned comments"),
+help_text = _("Create some canned comments to be used for easier moderation."),
+widget=StringListWidget))
+
FLAG_TYPES = Setting('FLAG_TYPES',
["Spam", "Advertising", "Offensive, Abusive, or Inappropriate", "Content violates terms of use", "Copyright Violation",
"Misleading", "Someone is not being nice", "Not relevant/off-topic", "Other"],
$('#comment-' + comment_id).slideDown('slow');\r
},\r
\r
+ canned_comment: function(post_id, comment) {\r
+ $('#comment-' + post_id + '-form textarea').val(comment);\r
+ },\r
+\r
update_comment: function(comment_id, comment_text) {\r
var $comment = $('#comment-' + comment_id);\r
$comment.find('.comment-text').html(comment_text);\r
--- /dev/null
+{% load i18n %}
+<style type="text/css">
+ table.canned_comments {
+ font-size: 13px;
+ }
+ table.canned_comments td {
+ vertical-align: top;
+ padding: 0 0 5px 3px;
+ }
+</style>
+
+<p>{% trans "Choose from the canned comments." %}</p>
+
+<p>
+<input type="hidden" name="comment" id="hidden_comment_wrapper" value="" />
+<table class="canned_comments" cellpadding="0" cellspacing="0">
+ {% for comment in canned_comments %}
+ <tr>
+ <td><input type="radio" name="comment_radio" onchange="document.getElementById('hidden_comment_wrapper').value=this.value" id="canned_comment_{{ forloop.counter }}" value="{{ comment }}" /></td>
+ <td>
+ <label for="canned_comment_{{ forloop.counter }}">{{ comment }}</label>
+ </td>
+ </tr>
+ {% endfor %}
+</table>
+</p>
\ No newline at end of file
<form id="comment-{{ post.id }}-form" method="post" action="{% url comment id=post.id %}" accept-charset="utf-8">\r
{% csrf_token %}\r
<div class="comment-form-widgets-container">\r
- <textarea name="comment" class="commentBox"></textarea>\r
+ <textarea name="comment" class="commentBox" id="comment"></textarea>\r
<div class="comment-form-buttons">\r
<span id="comment-{{ post.id }}-chars-left" class="comment-chars-left">\r
<span class="comments-char-left-count">{{ min_length }}|{{ max_length }}</span>\r
<input type="submit" class="comment-submit" value="{% trans " comment" %}" />\r
<input type="submit" class="comment-cancel" value="{% trans " cancel" %}" />\r
</div>\r
+ <div class="clear"></div>\r
+ {% if user.can_use_canned_comments %}\r
+ <div class="canned_comment">\r
+ <a href="{% url canned_comments post.id %}" class="ajax-command withprompt">{% trans "Use canned comment" %}</a>\r
+ </div>\r
+ {% endif %}\r
</div>\r
<script type="text/html" class="new-comment-skeleton" id="new-comment-skeleton-{{ post.id }}">\r
<div class="comment{% if not comment.top_scorer %} not_top_scorer{% endif %}" id="comment-%ID%">\r
url(r'^%s(?P<id>\d+)/$' % _('revisions/'), app.readers.revisions, name='revisions'),
url(r'^%s$' % _('questions/'), app.readers.questions, name='questions'),
url(r'^%s%s$' % (_('questions/'), _('ask/')), app.writers.ask, name='ask'),
+ url(r'^canned_comments/(?P<post_id>\d+)/$', app.commands.canned_comments, name='canned_comments'),
url(r'^%s%s$' % (_('questions/'), _('related_questions/')), app.commands.related_questions, name='related_questions'),
-
+
url(r'^%s%s$' % (_('questions/'), _('unanswered/')), app.readers.unanswered, name='unanswered'),
url(r'^%s(?P<mode>[\w\-]+)/(?P<user>\d+)/(?P<slug>.*)/$' % _('questions/'), app.readers.user_questions, name='user_questions'),
}
}
+@decorate.withfn(command)
+def canned_comments(request, post_id):
+ user = request.user
+
+ # Check whether the user has the required permissions to use the tool.
+ if not user.can_use_canned_comments:
+ raise CommandException(_("You cannot use the canned comments tool."))
+
+ if not request.POST:
+ canned_comments = []
+ for comment in settings.CANNED_COMMENTS:
+ canned_comments.append(smart_unicode(comment))
+
+ return render_to_response('node/canned_comments.html', {
+ 'canned_comments' : canned_comments,
+ }, RequestContext(request))
+
+ comment = request.POST.get('comment', '')
+
+ return {
+ 'commands' : {
+ 'canned_comment' : [post_id, comment],
+ }
+ }
+
#internally grouped views - used by the tagging system
@ajax_login_required
def mark_tag(request, tag=None, **kwargs):#tagging system