Permalink
Browse files

Rename comments_are_closed to comments_are_open

Makes the API call names similar to django-fluent-blogs
  • Loading branch information...
vdboor committed Nov 11, 2012
1 parent 0bb7b76 commit 45354652fcc7f4ec91c409b1b0229839c57116db
@@ -2,7 +2,6 @@
from django.contrib.comments.moderation import CommentModerator, moderator
from django.contrib.sites.models import get_current_site
from django.core.exceptions import ImproperlyConfigured
-from django.http import HttpRequest
from django.utils.encoding import smart_str
from akismet import Akismet
from fluent_comments import appsettings
@@ -13,7 +12,7 @@
'FluentCommentsModerator',
'moderate_model',
'get_model_moderator',
- 'comments_are_closed',
+ 'comments_are_open',
'comments_are_moderated',
)
@@ -166,18 +165,17 @@ def get_model_moderator(model):
return None
-def comments_are_closed(content_object):
+def comments_are_open(content_object):
"""
- Return whether comments are closed for a given target object.
+ Return whether comments are still open for a given target object.
"""
moderator = get_model_moderator(content_object.__class__)
if moderator is None:
- return False
+ return True
# Check the 'enable_field', 'auto_close_field' and 'close_after',
# by reusing the basic Django policies.
- request = HttpRequest()
- return not CommentModerator.allow(moderator, None, content_object, request)
+ return CommentModerator.allow(moderator, None, content_object, None)
def comments_are_moderated(content_object):
@@ -190,5 +188,4 @@ def comments_are_moderated(content_object):
# Check the 'auto_moderate_field', 'moderate_after',
# by reusing the basic Django policies.
- request = HttpRequest()
- return CommentModerator.moderate(moderator, None, content_object, request)
+ return CommentModerator.moderate(moderator, None, content_object, None)
@@ -1,6 +1,6 @@
{% load comments i18n crispy_forms_tags fluent_comments_tags %}{% load url from future %}
-{% if form.target_object|comments_are_closed %}
+{% if not form.target_object|comments_are_open %}
<p>{% trans "Comments are closed." %}</p>
{% else %}
<form action="{% comment_form_target %}" method="post" class="js-comments-form comments-form form-horizontal"
@@ -1,6 +1,6 @@
from django.template import Library
from django.core import context_processors
-from fluent_comments.moderation import comments_are_closed, comments_are_moderated
+from fluent_comments.moderation import comments_are_open, comments_are_moderated
register = Library()
@@ -16,5 +16,5 @@ def ajax_comment_tags(context):
return new_context
-register.filter('comments_are_closed', comments_are_closed)
+register.filter('comments_are_open', comments_are_open)
register.filter('comments_are_moderated', comments_are_moderated)

0 comments on commit 4535465

Please sign in to comment.