Merge remote-tracking branch 'refs/remotes/dthompson/453_disable_comments'

This commit is contained in:
Christopher Allan Webber 2013-05-10 16:33:52 -05:00
commit 94fadafe09
3 changed files with 18 additions and 7 deletions

View File

@ -34,6 +34,9 @@ allow_registration = boolean(default=True)
# tag parsing # tag parsing
tags_max_length = integer(default=255) tags_max_length = integer(default=255)
# Enable/disable comments
allow_comments = boolean(default=True)
# Whether comments are ascending or descending # Whether comments are ascending or descending
comments_ascending = boolean(default=True) comments_ascending = boolean(default=True)

View File

@ -90,8 +90,10 @@
{% if not request.user %} {% if not request.user %}
href="{{ request.urlgen('mediagoblin.auth.login') }}" href="{{ request.urlgen('mediagoblin.auth.login') }}"
{% endif %} {% endif %}
{% if app_config['allow_comments'] %}
class="button_action" id="button_addcomment" title="Add a comment"> class="button_action" id="button_addcomment" title="Add a comment">
{% trans %}Add a comment{% endtrans %} {% trans %}Add a comment{% endtrans %}
{% endif %}
</a> </a>
{% if request.user %} {% if request.user %}
<form action="{{ request.urlgen('mediagoblin.user_pages.media_post_comment', <form action="{{ request.urlgen('mediagoblin.user_pages.media_post_comment',

View File

@ -161,7 +161,13 @@ def media_post_comment(request, media):
comment.author = request.user.id comment.author = request.user.id
comment.content = unicode(request.form['comment_content']) comment.content = unicode(request.form['comment_content'])
if not comment.content.strip(): # Show error message if commenting is disabled.
if not mg_globals.app_config['allow_comments']:
messages.add_message(
request,
messages.ERROR,
_("Sorry, comments are disabled."))
elif not comment.content.strip():
messages.add_message( messages.add_message(
request, request,
messages.ERROR, messages.ERROR,