本文整理汇总了Python中comments.models.Comment.way方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.way方法的具体用法?Python Comment.way怎么用?Python Comment.way使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类comments.models.Comment
的用法示例。
在下文中一共展示了Comment.way方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post_comment
# 需要导入模块: from comments.models import Comment [as 别名]
# 或者: from comments.models.Comment import way [as 别名]
def post_comment(user, content, obj, parent=None):
'''
'''
comment = Comment(id=get_available_id(),
user=user,
content=content,
content_object=obj)
if parent and isinstance(parent, Comment):
comment.parent_comment = parent
parent.n_comment += 1
parent.save()
topics = obj.topics.all()
if isinstance(obj, Link):
comment.way = 'l'
for topic in topics:
topic_ship_update(topic=topic, user=user,
domain=obj.domain, is_comment=True)
elif isinstance(obj, Discuss):
comment.way = 'd'
for topic in topics:
topic_ship_update(topic=topic, user=user,
is_comment=True)
else:
return False
comment.save()
if parent and isinstance(parent, Comment):
if user != parent.user:
creat_remind(parent.user, user, REMIND_NEW_COMMENT, comment)
else:
if user != obj.user:
creat_remind(obj.user, user, REMIND_NEW_COMMENT, comment)
if isinstance(obj, Link):
Dynamic.objects.create(column=user.userprofile.get_column(),
way=WAY_LINK_COMMENT,
content_object=comment,
comment_object=obj)
elif isinstance(obj, Discuss):
Dynamic.objects.create(column=user.userprofile.get_column(),
way=WAY_DISCUSS_COMMENT,
content_object=comment,
comment_object=obj)
DiscussIndex.objects.filter(discuss=obj).update(
last_active_time=timezone.now(),
last_active_user=user)
obj.last_active_time = timezone.now()
obj.last_active_user = user
if not user.userdata.discusses.filter(id=obj.id).count():
user.userdata.discusses.add(obj)
else:
pass
obj.n_comment += 1
obj.save()
UserData.objects.filter(user=user).update(n_comments=F('n_comments') + 1)
return comment