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


Python GsuserManager.map_users方法代码示例

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


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

示例1: watch_user

# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import map_users [as 别名]
def watch_user(request, user_name):
    title = u'%s / 关注的用户' % user_name
    gsuser = GsuserManager.get_user_by_name(user_name)
    if gsuser is None:
        raise Http404
    gsuserprofile = GsuserManager.get_userprofile_by_id(gsuser.id)

    feedAction = FeedAction()
    raw_watch_users = feedAction.get_watch_users(gsuser.id, 0, 100)
    watch_user_ids = [int(x[0]) for x in raw_watch_users]
    watch_users_map = GsuserManager.map_users(watch_user_ids)
    watch_users = [watch_users_map[x] for x in watch_user_ids if x in watch_users_map]

    raw_bewatch_users = feedAction.get_bewatch_users(gsuser.id, 0, 100)
    bewatch_user_ids = [int(x[0]) for x in raw_bewatch_users]
    bewatch_users_map = GsuserManager.map_users(bewatch_user_ids)
    bewatch_users = [bewatch_users_map[x] for x in bewatch_user_ids if x in bewatch_users_map]
    # fixed on detect
    need_fix = False
    if len(watch_users) != gsuserprofile.watch:
        gsuserprofile.watch = len(watch_users)
        need_fix = True
    if len(bewatch_users) < 100 and len(bewatch_users) != gsuserprofile.be_watched:
        gsuserprofile.be_watched = len(bewatch_users) 
        need_fix = True
    if need_fix:
        gsuserprofile.save()

    response_dictionary = {'mainnav': 'user', 'title': title, 'watch_users': watch_users, 'bewatch_users': bewatch_users}
    response_dictionary.update(get_common_user_dict(request, gsuser, gsuserprofile))
    return render_to_response('user/watch_user.html',
                          response_dictionary,
                          context_instance=RequestContext(request))
开发者ID:ZheYuan,项目名称:gitshell,代码行数:35,代码来源:views.py

示例2: get_common_user_dict

# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import map_users [as 别名]
def get_common_user_dict(request, gsuser, gsuserprofile):
    feedAction = FeedAction()
    raw_watch_users = feedAction.get_watch_users(gsuser.id, 0, 10)
    raw_bewatch_users = feedAction.get_bewatch_users(gsuser.id, 0, 10)
    watch_user_ids = [int(x[0]) for x in raw_watch_users]
    bewatch_user_ids = [int(x[0]) for x in raw_bewatch_users]
    watch_users_map = GsuserManager.map_users(watch_user_ids)
    bewatch_users_map = GsuserManager.map_users(bewatch_user_ids)
    watch_users = [watch_users_map[x] for x in watch_user_ids if x in watch_users_map]
    bewatch_users = [bewatch_users_map[x] for x in bewatch_user_ids if x in bewatch_users_map]
    raw_recommends = GsuserManager.list_recommend_by_userid(gsuser.id, 0, 20)
    recommends = __conver_to_recommends_vo(raw_recommends)

    is_watched_user = False
    if request.user.is_authenticated():
        is_watched_user = RepoManager.is_watched_user(request.user.id, gsuser.id)
    return {'gsuser': gsuser, 'gsuserprofile': gsuserprofile, 'watch_users': watch_users, 'bewatch_users': bewatch_users, 'recommends': recommends, 'is_watched_user': is_watched_user, 'show_common': True}
开发者ID:ZheYuan,项目名称:gitshell,代码行数:19,代码来源:views.py

示例3: list_watch_user

# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import map_users [as 别名]
 def list_watch_user(self, repo_id):
     watchHistory = query(WatchHistory, None, 'watchhistory_l_repoId', [repo_id])
     user_ids = [o.user_id for o in watchHistory]
     user_map = GsuserManager.map_users(user_ids)
     watch_user = []
     for user_id in user_ids:
         if user_id in user_map:
             watch_user.append(user_map[user_id])
     return watch_user
开发者ID:ZheYuan,项目名称:gitshell,代码行数:11,代码来源:models.py

示例4: __conver_to_recommends_vo

# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import map_users [as 别名]
def __conver_to_recommends_vo(raw_recommends):
    user_ids = [x.from_user_id for x in raw_recommends]
    users_map = GsuserManager.map_users(user_ids)
    recommends_vo = [x.to_recommend_vo(users_map) for x in raw_recommends]
    return recommends_vo
开发者ID:ZheYuan,项目名称:gitshell,代码行数:7,代码来源:views.py


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