当前位置: 首页>>代码示例>>Python>>正文


Python Comment.document方法代码示例

本文整理汇总了Python中comments.models.Comment.document方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.document方法的具体用法?Python Comment.document怎么用?Python Comment.document使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在comments.models.Comment的用法示例。


在下文中一共展示了Comment.document方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update_comment

# 需要导入模块: from comments.models import Comment [as 别名]
# 或者: from comments.models.Comment import document [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
开发者ID:yourcelf,项目名称:btb,代码行数:36,代码来源:models.py


注:本文中的comments.models.Comment.document方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。