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


Python MActivity.new_comment_like方法代码示例

本文整理汇总了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,
        })
开发者ID:superchink,项目名称:NewsBlur,代码行数:46,代码来源:views.py

示例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})
开发者ID:yoyo2k,项目名称:NewsBlur,代码行数:43,代码来源:views.py


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