],
MODERATION_SET, dict(
label = _("Canned comments"),
-help_text = _("Create some canned comments to be used for easier moderation."),
+help_text = _("""
+<p>Create some canned comments to be used for easier moderation. You can access the {{ post }} and {{ settings }} variables.</p>
+<p>If you want to access the current post author username you can use {{ post.author }}, for the question title use {{ post.title }}.</p>
+<p>To get the application title use {{ settings.APP_TITLE }}. All settings are accessible through the settings object.</p>
+"""),
widget=StringListWidget))
FLAG_TYPES = Setting('FLAG_TYPES',
* We do not want the CSRF protection enabled for the AJAX post requests, it causes only trouble.\r
* Get the csrftoken cookie and pass it to the X-CSRFToken HTTP request property.\r
*/\r
+\r
$('html').ajaxSend(function(event, xhr, settings) {\r
function getCookie(name) {\r
var cookieValue = null;\r
}\r
});\r
\r
+function canned_comment(post_id, comment) {\r
+ $('#comment-' + post_id + '-form textarea').val(comment);\r
+}\r
+\r
var response_commands = {\r
refresh_page: function() {\r
window.location.reload(true)\r
$('#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
tag_link.attr('rel','tag');\r
tag_link.attr('href', scriptUrl + $.i18n._('tags/') + tagname + '/');\r
tag_link.html(tagname);\r
- var del_link = $('<img></img>');\r
+ var del_link = $('<img />');\r
del_link.addClass('delete-icon');\r
del_link.attr('src', mediaUrl('media/images/close-small-dark.png'));\r
\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="jQuery('#hidden_comment_wrapper').val(jQuery(this).val())" 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
<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
+ <span id="post-{{ post.id }}-menu" class="context-menu">\r
+ <span id="post-{{ post.id }}-menu-trigger" class="action-link context-menu-trigger">{% trans "Use canned comment" %}</span>\r
+ <ul id="post-{{ post.id }}-menu-dropdown" class="context-menu-dropdown" style="width: 275px;">\r
+ {% for canned_comment in canned_comments %}\r
+ <li class="item">\r
+ <a style="white-space: pre-wrap;" href="javascript:void(0);" onclick="canned_comment({{ post.id }}, jQuery(this).text())">{{ canned_comment }}</a>\r
+ </li>\r
+ {% endfor %}\r
+ </ul>\r
+ </span>\r
</div>\r
{% endif %}\r
</div>\r
import re\r
\r
from forum.models import Question, Action\r
+from django.template import Template, Context\r
from django.utils.translation import ungettext, ugettext as _\r
from django.utils.html import strip_tags\r
from django.utils.encoding import smart_unicode\r
context.update(dict(c.__dict__))\r
comments.append(context)\r
\r
+ # Generate canned comments\r
+ canned_comments = []\r
+ for comment in settings.CANNED_COMMENTS:\r
+ t = Template(smart_unicode(comment))\r
+ c = Context({\r
+ 'post' : post,\r
+ 'settings' : settings,\r
+ })\r
+ canned_comments.append(t.render(c))\r
+\r
return {\r
'comments': comments,\r
+ 'canned_comments': canned_comments,\r
'post': post,\r
'can_comment': user.can_comment(post),\r
'max_length': settings.FORM_MAX_COMMENT_BODY,\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'),
}
}
-@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