本文整理汇总了Python中models.Comment.comment方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.comment方法的具体用法?Python Comment.comment怎么用?Python Comment.comment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Comment
的用法示例。
在下文中一共展示了Comment.comment方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import comment [as 别名]
def execute(self):
invite_attendee = None
if self.invite_attendee_id:
invite_attendee = InviteAttendee.get_by_unique_id(
self.invite_attendee_id
)
invite = Invite.get_by_unique_id(self.invite_unique_id)
if invite is None:
raise InviteNotFoundException()
author = None
if invite_attendee is not None:
author = invite_attendee.name or invite_attendee.email or invite_attendee.phone
if invite.comments is None:
invite.comments = []
comment = Comment()
comment.author = author
comment.comment = self.comment
comment.commented_on = datetime.datetime.now()
invite.comments.append(comment)
invite.put()
return comment
示例2: attach_comment_to_project
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import comment [as 别名]
def attach_comment_to_project(id):
form = CommentForm()
if form.validate_on_submit():
comment = Comment()
comment.user_id = session['id']
comment.project_id = id
comment.comment = form.comment.data
db.session.add(comment)
db.session.commit()
return "success", 201
return render_template("create_comment.html", form=form, url = "/project/add/" + str(id) + "/comment")
示例3: post
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import comment [as 别名]
def post(request, id):
posts = Post.objects.all()
post = Post.objects.get(id=id)
comments = Comment.objects.filter(post = post, approved = True)
teve_comentario = False
if request.method == 'POST':
teve_comentario = True
comment = Comment()
comment.post = post
comment.name = request.POST['nome']
comment.email = request.POST['email']
comment.comment = request.POST['comentario']
comment.save()
return render(request, 'blog/post.html', locals())
示例4: debug
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import comment [as 别名]
lepra_comment_id=comment_id,
author=author,
youtube_url=urls[0],
rating=rating,
comment=text)
session.add(sa_comment)
session.commit()
else:
if sa_comment.rating != rating:
debug(" Comment's rating changed.")
sa_comment.rating = rating
changed = True
if sa_comment.comment != text:
debug(" Comment's text changed.")
sa_comment.comment = text
changed = True
if changed:
debug(" Saving changes to DB...")
session.commit()
reddit_comment_text = REDDIT_COMMENT_SLUG.format(comment=text,
comment_url=lepra_comment_url,
rating=rating,
author_prefix=author_prefix,
author=author,
author_postfix=author_postfix)
if not sa_comment.reddit_comment_id:
debug(" No comment at reddit yet. Posting a comment on Reddit...")