本文整理匯總了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