本文整理汇总了Python中comments.models.Comment.removed方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.removed方法的具体用法?Python Comment.removed怎么用?Python Comment.removed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类comments.models.Comment
的用法示例。
在下文中一共展示了Comment.removed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_comment
# 需要导入模块: from comments.models import Comment [as 别名]
# 或者: from comments.models.Comment import removed [as 别名]
def update_comment(self):
"""
Creates the shadow comment object to hold this document's place in a
commment thread, if this document is a reply to comments.
"""
# Create comment objects only when the doc is public. That way,
# subscription signals are fired at the right moment -- the comment is
# public and viewable.
parent = None
if self.in_reply_to:
try:
parent = self.in_reply_to.document
except Document.DoesNotExist:
pass
if parent and self.is_public():
# Only create a comment object if we are public.
try:
comment = self.comment
except Comment.DoesNotExist:
comment = Comment()
comment.user = self.author
comment.removed = False
comment.document = parent
comment.comment_doc = self
comment.save()
else:
# If we've gone non-public, mark the comment removed rather
# than deleting. That way, we don't re-fire subscriptions if
# the doc is only temporarily un-published.
try:
self.comment.removed = True
self.comment.save()
except Comment.DoesNotExist:
pass