diff options
-rw-r--r-- | mediagoblin/config_spec.ini | 3 | ||||
-rw-r--r-- | mediagoblin/templates/mediagoblin/user_pages/media.html | 14 | ||||
-rw-r--r-- | mediagoblin/user_pages/views.py | 8 |
3 files changed, 18 insertions, 7 deletions
diff --git a/mediagoblin/config_spec.ini b/mediagoblin/config_spec.ini index b7c6f29a..6c00aa58 100644 --- a/mediagoblin/config_spec.ini +++ b/mediagoblin/config_spec.ini @@ -34,6 +34,9 @@ allow_registration = boolean(default=True) # tag parsing tags_max_length = integer(default=255) +# Enable/disable comments +allow_comments = boolean(default=True) + # Whether comments are ascending or descending comments_ascending = boolean(default=True) diff --git a/mediagoblin/templates/mediagoblin/user_pages/media.html b/mediagoblin/templates/mediagoblin/user_pages/media.html index 7dea3f09..6d32d009 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/media.html +++ b/mediagoblin/templates/mediagoblin/user_pages/media.html @@ -43,7 +43,7 @@ {%- endtrans -%} </p> {% include "mediagoblin/utils/prev_next.html" %} - <div class="media_pane"> + <div class="media_pane"> <div class="media_image_container"> {% block mediagoblin_media %} {% set display_media = request.app.public_store.file_url( @@ -71,7 +71,7 @@ {{ media.title }} </h2> {% if request.user and - (media.uploader == request.user.id or + (media.uploader == request.user.id or request.user.is_admin) %} {% set edit_url = request.urlgen('mediagoblin.edit.edit_media', user= media.get_uploader.username, @@ -90,11 +90,13 @@ {% if not request.user %} href="{{ request.urlgen('mediagoblin.auth.login') }}" {% endif %} - class="button_action" id="button_addcomment" title="Add a comment"> - {% trans %}Add a comment{% endtrans %} + {% if app_config['allow_comments'] %} + class="button_action" id="button_addcomment" title="Add a comment"> + {% trans %}Add a comment{% endtrans %} + {% endif %} </a> {% if request.user %} - <form action="{{ request.urlgen('mediagoblin.user_pages.media_post_comment', + <form action="{{ request.urlgen('mediagoblin.user_pages.media_post_comment', user= media.get_uploader.username, media_id=media.id) }}" method="POST" id="form_comment"> {{ wtforms_util.render_divs(comment_form) }} @@ -160,7 +162,7 @@ {% include "mediagoblin/utils/license.html" %} {% include "mediagoblin/utils/exif.html" %} - + {%- if media.attachment_files|count %} <h3>{% trans %}Attachments{% endtrans %}</h3> <ul> diff --git a/mediagoblin/user_pages/views.py b/mediagoblin/user_pages/views.py index 52745be2..738cc054 100644 --- a/mediagoblin/user_pages/views.py +++ b/mediagoblin/user_pages/views.py @@ -161,7 +161,13 @@ def media_post_comment(request, media): comment.author = request.user.id 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( request, messages.ERROR, |