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


Python MActivity.user方法代码示例

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


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

示例1: load_activities

# 需要导入模块: from apps.social.models import MActivity [as 别名]
# 或者: from apps.social.models.MActivity import user [as 别名]
def load_activities(request):
    user_id = request.REQUEST.get('user_id', None)
    if user_id:
        user_id = int(user_id)
        user = User.objects.get(pk=user_id)
    else:
        user = get_user(request)
        user_id = user.pk
        
    public = user_id != request.user.pk
    page = max(1, int(request.REQUEST.get('page', 1)))
    limit = request.REQUEST.get('limit', 4)
    activities, has_next_page = MActivity.user(user_id, page=page, limit=limit, public=public)
    format = request.REQUEST.get('format', None)
    
    data = {
        'activities': activities,
        'page': page,
        'has_next_page': has_next_page,
        'username': (user.username if public else 'You'),
    }
    
    if format == 'html':
        return render_to_response('reader/activities_module.xhtml', data,
                                  context_instance=RequestContext(request))
    else:
        return json.json_response(request, data)
开发者ID:superchink,项目名称:NewsBlur,代码行数:29,代码来源:views.py

示例2: profile

# 需要导入模块: from apps.social.models import MActivity [as 别名]
# 或者: from apps.social.models.MActivity import user [as 别名]
def profile(request):
    user = get_user(request.user)
    user_id = request.GET.get('user_id', user.pk)
    include_activities_html = request.REQUEST.get('include_activities_html', None)

    user_profile = MSocialProfile.get_user(user_id)
    user_profile.count_follows()
    user_profile = user_profile.to_json(include_follows=True, common_follows_with_user=user.pk)
    profile_ids = set(user_profile['followers_youknow'] + user_profile['followers_everybody'] + 
                      user_profile['following_youknow'] + user_profile['following_everybody'])
    profiles = MSocialProfile.profiles(profile_ids)
    activities, _ = MActivity.user(user_id, page=1, public=True)
    logging.user(request, "~BB~FRLoading social profile: %s" % user_profile['username'])
        
    payload = {
        'user_profile': user_profile,
        # XXX TODO: Remove following 4 vestigial params.
        'followers_youknow': user_profile['followers_youknow'],
        'followers_everybody': user_profile['followers_everybody'],
        'following_youknow': user_profile['following_youknow'],
        'following_everybody': user_profile['following_everybody'],
        'profiles': dict([(p.user_id, p.to_json(compact=True)) for p in profiles]),
        'activities': activities,
    }
    
    if include_activities_html:
        payload['activities_html'] = render_to_string('reader/activities_module.xhtml', {
            'activities': activities,
            'username': user_profile['username'],
            'public': True,
        })
    
    return payload
开发者ID:superchink,项目名称:NewsBlur,代码行数:35,代码来源:views.py

示例3: load_activities

# 需要导入模块: from apps.social.models import MActivity [as 别名]
# 或者: from apps.social.models.MActivity import user [as 别名]
def load_activities(request):
    user_id = request.REQUEST.get("user_id", None)
    if user_id:
        user_id = int(user_id)
        user = User.objects.get(pk=user_id)
    else:
        user = get_user(request)
        user_id = user.pk

    public = user_id != request.user.pk
    page = max(1, int(request.REQUEST.get("page", 1)))
    limit = request.REQUEST.get("limit", 4)
    activities, has_next_page = MActivity.user(user_id, page=page, limit=limit, public=public)
    format = request.REQUEST.get("format", None)

    data = {
        "activities": activities,
        "page": page,
        "has_next_page": has_next_page,
        "username": (user.username if public else "You"),
    }

    if format == "html":
        return render_to_response("reader/activities_module.xhtml", data, context_instance=RequestContext(request))
    else:
        return json.json_response(request, data)
开发者ID:yoyo2k,项目名称:NewsBlur,代码行数:28,代码来源:views.py

示例4: load_activities

# 需要导入模块: from apps.social.models import MActivity [as 别名]
# 或者: from apps.social.models.MActivity import user [as 别名]
def load_activities(request):
    user = get_user(request)
    page = max(1, int(request.REQUEST.get('page', 1)))
    activities, has_next_page = MActivity.user(user.pk, page=page)

    return {
        'activities': activities,
        'page': page,
        'has_next_page': has_next_page,
        'username': '你',
    }
开发者ID:linuxayn,项目名称:NewsBlur,代码行数:13,代码来源:views.py

示例5: render_activities_module

# 需要导入模块: from apps.social.models import MActivity [as 别名]
# 或者: from apps.social.models.MActivity import user [as 别名]
def render_activities_module(context, page=1):
    user = get_user(context['user'])
    activities, has_next_page = MActivity.user(user.pk, page)
    
    return {
        'user': user,
        'activities': activities,
        'page': page,
        'has_next_page': has_next_page,
        'username': 'You',
        'MEDIA_URL': context['MEDIA_URL'],
    }
开发者ID:0077cc,项目名称:NewsBlur,代码行数:14,代码来源:utils_tags.py

示例6: profile

# 需要导入模块: from apps.social.models import MActivity [as 别名]
# 或者: from apps.social.models.MActivity import user [as 别名]
def profile(request):
    user = get_user(request.user)
    user_id = request.GET.get("user_id", user.pk)
    categories = request.GET.getlist("category")
    include_activities_html = request.REQUEST.get("include_activities_html", None)

    user_profile = MSocialProfile.get_user(user_id)
    user_profile.count_follows()
    user_profile = user_profile.to_json(include_follows=True, common_follows_with_user=user.pk)
    profile_ids = set(
        user_profile["followers_youknow"]
        + user_profile["followers_everybody"]
        + user_profile["following_youknow"]
        + user_profile["following_everybody"]
    )
    profiles = MSocialProfile.profiles(profile_ids)
    activities, _ = MActivity.user(user_id, page=1, public=True, categories=categories)
    logging.user(request, "~BB~FRLoading social profile: %s" % user_profile["username"])

    payload = {
        "user_profile": user_profile,
        # XXX TODO: Remove following 4 vestigial params.
        "followers_youknow": user_profile["followers_youknow"],
        "followers_everybody": user_profile["followers_everybody"],
        "following_youknow": user_profile["following_youknow"],
        "following_everybody": user_profile["following_everybody"],
        "profiles": dict([(p.user_id, p.to_json(compact=True)) for p in profiles]),
        "activities": activities,
    }

    if include_activities_html:
        payload["activities_html"] = render_to_string(
            "reader/activities_module.xhtml",
            {"activities": activities, "username": user_profile["username"], "public": True},
        )

    return payload
开发者ID:eric011,项目名称:NewsBlur,代码行数:39,代码来源:views.py

示例7: load_activities

# 需要导入模块: from apps.social.models import MActivity [as 别名]
# 或者: from apps.social.models.MActivity import user [as 别名]
def load_activities(request):
    user = get_user(request)
    page = max(1, int(request.REQUEST.get("page", 1)))
    activities, has_next_page = MActivity.user(user.pk, page=page)

    return {"activities": activities, "page": page, "has_next_page": has_next_page, "username": "You"}
开发者ID:jmorahan,项目名称:NewsBlur,代码行数:8,代码来源:views.py


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