本文整理汇总了Python中models.Comment.parent_comment方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.parent_comment方法的具体用法?Python Comment.parent_comment怎么用?Python Comment.parent_comment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Comment
的用法示例。
在下文中一共展示了Comment.parent_comment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: view_post
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import parent_comment [as 别名]
def view_post(request, post_id):
post = Post.get_by_id(int(post_id))
if not post:
raise Http404
if not is_admin() and not post.is_published:
raise Http404
if request.method == "POST":
comment = Comment()
comment.content = request.POST["comment"]
comment.author = users.get_current_user()
comment.post = post
if request.POST["parent_comment"] != "":
parent_comment = Comment.get_by_id(int(request.POST["parent_comment"]))
comment.parent_comment = parent_comment
comment.put()
post.comment_count = post.comment_count + 1
post.put()
mail.send_mail(
sender="[email protected]",
to=post.author.email(),
subject=(u"牛逼 - 你的文章%s有了新评论" % post.title).encode("utf8"),
body=(
u"""%s在你的文章%s上留了评论:
%s
点击这个链接回复: http://www.niubi.de/post/%s/"""
% (comment.author.nickname(), post.title, comment.content, post.key().id())
).encode("utf8"),
)
comments = Comment.all().filter("post", post)
sent_users = []
for c in comments:
if not contains_user(sent_users, c.author):
mail.send_mail(
sender="[email protected]",
to=c.author.email(),
subject=(u"牛逼 - 你参与评论的文章%s有了新评论" % post.title).encode("utf8"),
body=(
u"""%s在文章%s上留了评论:
%s
点击这个链接回复: http://www.niubi.de/post/%s/"""
% (comment.author.nickname(), post.title, comment.content, post.key().id())
).encode("utf8"),
)
sent_users.append(c.author)
return HttpResponseRedirect("/post/%s" % post.key().id())
post.read_count = post.read_count + 1
post.put()
post.getComments()
return render_to_response(
"view_post.html",
{"post": post, "is_post_author": is_post_author(post_id)},
context_instance=RequestContext(request),
)
示例2: view_post
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import parent_comment [as 别名]
def view_post(request, post_id):
post = Post.get_by_id(int(post_id))
if not post:
raise Http404
if not is_admin() and not post.is_published:
raise Http404
if request.method == 'POST':
comment = Comment()
comment.content = request.POST['comment']
comment.author = users.get_current_user()
comment.post = post
if request.POST['parent_comment'] != "":
parent_comment = Comment.get_by_id(int(request.POST['parent_comment']))
comment.parent_comment = parent_comment
comment.put()
post.comment_count = post.comment_count + 1
post.put()
mail.send_mail(sender="[email protected]",
to=post.author.email(),
subject=(u'牛逼 - 你的文章%s有了新评论'%post.title).encode('utf8'),
body=(u'''%s在你的文章%s上留了评论:
%s
点击这个链接回复: http://www.niubi.de/post/%s/''' %(comment.author.nickname(), post.title, comment.content, post.key().id())).encode('utf8')
)
comments = Comment.all().filter('post', post)
sent_users = []
for c in comments:
if not contains_user(sent_users, c.author):
mail.send_mail(sender="[email protected]",
to=c.author.email(),
subject=(u'牛逼 - 你参与评论的文章%s有了新评论'%post.title).encode('utf8'),
body=(u'''%s在文章%s上留了评论:
%s
点击这个链接回复: http://www.niubi.de/post/%s/''' %(comment.author.nickname(), post.title, comment.content, post.key().id())).encode('utf8')
)
sent_users.append(c.author)
return HttpResponseRedirect('/post/%s' % post.key().id())
post.read_count = post.read_count + 1
post.put()
post.getComments()
return render_to_response('view_post.html',
{'post':post,'is_post_author':is_post_author(post_id)}, context_instance=RequestContext(request))