本文整理汇总了Python中blog.models.Comment.karma方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.karma方法的具体用法?Python Comment.karma怎么用?Python Comment.karma使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blog.models.Comment
的用法示例。
在下文中一共展示了Comment.karma方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: entry_detail
# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import karma [as 别名]
def entry_detail(request, year, month, day, slug, draft=False):
date = datetime.date(*time.strptime(year+month+day, '%Y'+'%b'+'%d')[:3])
entry = get_object_or_404(Entry, slug=slug,
created_on__range=(
datetime.datetime.combine(date, datetime.time.min),
datetime.datetime.combine(date, datetime.time.max)
), is_draft=draft)
if request.method == 'POST' and entry.comments_allowed():
form = CommentForm(request.POST)
if form.is_valid():
comment = Comment(**form.cleaned_data)
comment.entry = entry
if request.META['REMOTE_ADDR'] != '':
comment.ip = request.META['REMOTE_ADDR']
else:
comment.ip = request.META['REMOTE_HOST']
comment.date = datetime.datetime.now()
comment.karma = 0
comment.spam = akismet(request, comment)
comment.save()
if (not comment.spam) and settings.BLOG_COMMENT_EMAIL:
comment_email = "%s\n--\n%s\n%s\n%s" % (comment.comment,
comment.name, comment.email, comment.website)
send_mail('[Blog] %s' % entry.title, comment_email,
comment.email, [entry.author.email], fail_silently=True)
return HttpResponseRedirect(entry.get_absolute_url())
else:
form = CommentForm()
return render_to_response('blog/entry_detail.html',
{'blog_title': settings.BLOG_TITLE, 'tags': Tag.objects.all(),
'object': entry, 'comment_form': form},
context_instance=RequestContext(request))