Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: e212b22a33
Fetching contributors…

Cannot retrieve contributors at this time

42 lines (32 sloc) 1.346 kb
from django.conf import settings
from django.template import Library
from django.core import context_processors
from fluent_comments.models import get_comments_for_model
from fluent_comments.moderation import comments_are_open, comments_are_moderated
register = Library()
@register.inclusion_tag("fluent_comments/templatetags/ajax_comment_tags.html", takes_context=True)
def ajax_comment_tags(context):
"""
Display the required ``<div>`` elements to let the Ajax comment functionality work with your form.
"""
new_context = {
'STATIC_URL': context.get('STATIC_URL', None)
}
# Be configuration independent:
if new_context['STATIC_URL'] is None:
try:
request = context['request']
except KeyError:
new_context.update({'STATIC_URL': settings.STATIC_URL})
else:
new_context.update(context_processors.static(request))
return new_context
register.filter('comments_are_open', comments_are_open)
register.filter('comments_are_moderated', comments_are_moderated)
@register.filter
def comments_count(content_object):
"""
Return the number of comments posted at a target object.
You can use this instead of the ``{% get_comment_count for [object] as [varname] %}`` tag.
"""
return get_comments_for_model(content_object).count()
Jump to Line
Something went wrong with that request. Please try again.