本文整理匯總了Python中comments.models.Comment.get_content_object_type方法的典型用法代碼示例。如果您正苦於以下問題:Python Comment.get_content_object_type方法的具體用法?Python Comment.get_content_object_type怎麽用?Python Comment.get_content_object_type使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類comments.models.Comment
的用法示例。
在下文中一共展示了Comment.get_content_object_type方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_all_tags
# 需要導入模塊: from comments.models import Comment [as 別名]
# 或者: from comments.models.Comment import get_content_object_type [as 別名]
def get_all_tags(cls, assessment, json_encode=True):
root = SummaryText.objects.get(title='assessment-{pk}'.format(pk=assessment.pk))
tags = SummaryText.dump_bulk(root)
if root.assessment.comment_settings.public_comments:
descendants=root.get_descendants()
obj_type = Comment.get_content_object_type('summary_text')
comments=Comment.objects.filter(content_type=obj_type,
object_id__in=descendants)
tags[0]['data']['comments'] = Comment.get_jsons(comments, json_encode=False)
if json_encode:
return json.dumps(tags, cls=HAWCDjangoJSONEncoder)
else:
return tags
示例2: get_assessment_descendants
# 需要導入模塊: from comments.models import Comment [as 別名]
# 或者: from comments.models.Comment import get_content_object_type [as 別名]
def get_assessment_descendants(cls, assessment_id, json_encode=True):
"""
Return all, excluding root
"""
root = cls.get_assessment_root_node(assessment_id)
tags = SummaryText.dump_bulk(root)
if root.assessment.comment_settings.public_comments:
descendants = root.get_descendants()
obj_type = Comment.get_content_object_type('summary_text')
comments = Comment.objects.filter(
content_type=obj_type,
object_id__in=descendants
)
tags[0]['data']['comments'] = Comment.get_jsons(comments, json_encode=False)
if json_encode:
return json.dumps(tags, cls=HAWCDjangoJSONEncoder)
else:
return tags