本文整理汇总了Python中apps.social.models.MActivity.new_comment_like方法的典型用法代码示例。如果您正苦于以下问题:Python MActivity.new_comment_like方法的具体用法?Python MActivity.new_comment_like怎么用?Python MActivity.new_comment_like使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apps.social.models.MActivity
的用法示例。
在下文中一共展示了MActivity.new_comment_like方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: like_comment
# 需要导入模块: from apps.social.models import MActivity [as 别名]
# 或者: from apps.social.models.MActivity import new_comment_like [as 别名]
def like_comment(request):
code = 1
feed_id = int(request.POST['story_feed_id'])
story_id = request.POST['story_id']
comment_user_id = request.POST['comment_user_id']
format = request.REQUEST.get('format', 'json')
if comment_user_id == request.user.pk:
return json.json_response(request, {'code': -1, 'message': 'You cannot favorite your own shared story comment.'})
shared_story = MSharedStory.objects.get(user_id=comment_user_id,
story_feed_id=feed_id,
story_guid=story_id)
shared_story.add_liking_user(request.user.pk)
comment, profiles = shared_story.comment_with_author_and_profiles()
comment_user = User.objects.get(pk=shared_story.user_id)
logging.user(request, "~BB~FMLiking comment by ~SB%s~SN: %s" % (
comment_user.username,
shared_story.comments[:30],
))
MActivity.new_comment_like(liking_user_id=request.user.pk,
comment_user_id=comment['user_id'],
story_id=story_id,
story_title=shared_story.story_title,
comments=shared_story.comments)
MInteraction.new_comment_like(liking_user_id=request.user.pk,
comment_user_id=comment['user_id'],
story_id=story_id,
story_title=shared_story.story_title,
comments=shared_story.comments)
if format == 'html':
comment = MSharedStory.attach_users_to_comment(comment, profiles)
return render_to_response('social/story_comment.xhtml', {
'comment': comment,
}, context_instance=RequestContext(request))
else:
return json.json_response(request, {
'code': code,
'comment': comment,
'user_profiles': profiles,
})
示例2: like_comment
# 需要导入模块: from apps.social.models import MActivity [as 别名]
# 或者: from apps.social.models.MActivity import new_comment_like [as 别名]
def like_comment(request):
code = 1
feed_id = int(request.POST["story_feed_id"])
story_id = request.POST["story_id"]
comment_user_id = request.POST["comment_user_id"]
format = request.REQUEST.get("format", "json")
if comment_user_id == request.user.pk:
return json.json_response(
request, {"code": -1, "message": "You cannot favorite your own shared story comment."}
)
shared_story = MSharedStory.objects.get(user_id=comment_user_id, story_feed_id=feed_id, story_guid=story_id)
shared_story.add_liking_user(request.user.pk)
comment, profiles = shared_story.comment_with_author_and_profiles()
comment_user = User.objects.get(pk=shared_story.user_id)
logging.user(request, "~BB~FMLiking comment by ~SB%s~SN: %s" % (comment_user.username, shared_story.comments[:30]))
MActivity.new_comment_like(
liking_user_id=request.user.pk,
comment_user_id=comment["user_id"],
story_id=story_id,
story_title=shared_story.story_title,
comments=shared_story.comments,
)
MInteraction.new_comment_like(
liking_user_id=request.user.pk,
comment_user_id=comment["user_id"],
story_id=story_id,
story_title=shared_story.story_title,
comments=shared_story.comments,
)
if format == "html":
comment = MSharedStory.attach_users_to_comment(comment, profiles)
return render_to_response(
"social/story_comment.xhtml", {"comment": comment}, context_instance=RequestContext(request)
)
else:
return json.json_response(request, {"code": code, "comment": comment, "user_profiles": profiles})