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


Python GsuserManager.get_user_by_name方法代码示例

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


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

示例1: __get_uniq_username

# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_name [as 别名]
def __get_uniq_username(tp_username):
    if tp_username is not None and not tp_username.startswith('-'):
        user = GsuserManager.get_user_by_name(tp_username)
        if user is None:
            return tp_username
    for i in range(0, 1000):
        random_username = '%8x' % random.getrandbits(64)
        user = GsuserManager.get_user_by_name(random_username)
        if user is None:
            return random_username
    return None
开发者ID:ZheYuan,项目名称:gitshell,代码行数:13,代码来源:views.py

示例2: watch_user

# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_name [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

示例3: update

# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_name [as 别名]
def update(request, user_name, repo_name, issue_id, attr):
    repo = RepoManager.get_repo_by_name(user_name, repo_name)
    if repo is None:
        raise Http404
    issue = IssueManager.get_issue(repo.id, issue_id)
    if issue is None:
        return _json_failed()
    has_issue_modify_right = _has_issue_modify_right(request, issue, repo)
    if not has_issue_modify_right:
        return _json_failed()
    orgi_issue = copy.copy(issue)
    (key, value) = attr.split('___', 1)
    if key == 'assigned':
        user = GsuserManager.get_user_by_name(value)
        if user is None:
            return _json_failed()
        repoMember = RepoManager.get_repo_member(repo.id, user.id)
        if repoMember is None:
            return _json_failed()
        issue.assigned = repoMember.user_id
        issue.save()
        FeedManager.notif_issue_status(request.user, issue, ISSUE_STATUS.ASSIGNED)
        FeedManager.feed_issue_change(request.user, repo, orgi_issue, issue.id)
        return _json_ok()
    value = int(value)
    if key == 'tracker':
        issue.tracker = value
    elif key == 'status':
        issue.status = value
    elif key == 'priority':
        issue.priority = value
    issue.save()
    FeedManager.feed_issue_change(request.user, repo, orgi_issue, issue.id)
    return _json_ok()
开发者ID:ZheYuan,项目名称:gitshell,代码行数:36,代码来源:views.py

示例4: _do_event

# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_name [as 别名]
 def _do_event(self, event):
     username = event['username']
     reponame = event['reponame']
     remote_git_url = event['remote_git_url']
     local_user = GsuserManager.get_user_by_name(username)
     local_repo = RepoManager.get_repo_by_name(username, reponame)
     if local_user is None or local_repo is None or local_repo.status == 0:
         return
     local_repo_path = local_repo.get_abs_repopath()
     if os.path.exists(local_repo_path):
         return
     args = ['/bin/bash', '/opt/bin/git-import-remote-repo.sh'] + [local_repo_path, remote_git_url]
     try:
         popen = Popen(args, stdout=PIPE, shell=False, close_fds=True)
         output = popen.communicate()[0].strip()
         returncode = popen.returncode
         if returncode == 0:
             RepoManager.check_export_ok_file(local_repo)
             diff_size = long(output)
             RepoManager.update_user_repo_quote(local_user, local_repo, diff_size)
             local_repo.status = 0
             local_repo.save()
         else:
             local_repo.status = 500
             local_repo.save()
     except Exception, e:
         local_repo.status = 500
         local_repo.save()
         logger.exception(e)
开发者ID:ZheYuan,项目名称:gitshell,代码行数:31,代码来源:importrepoworker.py

示例5: notif_at

# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_name [as 别名]
    def notif_at(self, notif_type, from_user_id, relative_id, message):
        at_name_list = FeedUtils.list_atname(message)
        user_unread_message_dict = {}

        for at_name in at_name_list:
            at_user = GsuserManager.get_user_by_name(at_name)
            if at_user is not None:
                to_user_id = at_user.id
                notifMessage = None
                # disable duplicate notify
                exists_notifMessage = self.get_notifmessage_by_userId_notifType_relativeId(to_user_id, notif_type, relative_id)
                if exists_notifMessage is not None:
                    continue
                if notif_type == NOTIF_TYPE.AT_COMMIT:
                    notifMessage = NotifMessage.create_at_commit(from_user_id, to_user_id, relative_id)
                elif notif_type == NOTIF_TYPE.AT_MERGE:
                    notifMessage = NotifMessage.create_at_merge(from_user_id, to_user_id, relative_id)
                elif notif_type == NOTIF_TYPE.AT_ISSUE:
                    notifMessage = NotifMessage.create_at_issue(from_user_id, to_user_id, relative_id)
                elif notif_type == NOTIF_TYPE.AT_ISSUE_COMMENT:
                    notifMessage = NotifMessage.create_at_issue_comment(from_user_id, to_user_id, relative_id)
                if notifMessage is None:
                    continue
                self.message_save_and_notif(notifMessage)
                if to_user_id not in user_unread_message_dict:
                    user_unread_message_dict[to_user_id] = 0
                user_unread_message_dict[to_user_id] = user_unread_message_dict[to_user_id] + 1

        for to_user_id, unread_message in user_unread_message_dict.items():
            at_userprofile = GsuserManager.get_userprofile_by_id(to_user_id)
            at_userprofile.unread_message = at_userprofile.unread_message + unread_message
            at_userprofile.save()
开发者ID:ZheYuan,项目名称:gitshell,代码行数:34,代码来源:models.py

示例6: recommend_delete

# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_name [as 别名]
def recommend_delete(request, user_name, recommend_id):
    gsuser = GsuserManager.get_user_by_name(user_name)
    if gsuser is None:
        raise Http404
    recommend = GsuserManager.get_recommend_by_id(recommend_id)
    if recommend.user_id == request.user.id:
        recommend.visibly = 1
        recommend.save()
    return json_success(u'成功删除评论')
开发者ID:ZheYuan,项目名称:gitshell,代码行数:11,代码来源:views.py

示例7: group_add_member

# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_name [as 别名]
def group_add_member(request, username):
    teamUser = GsuserManager.get_user_by_name(username)
    team_group_id = int(request.POST.get('team_group_id', '0'))
    teamGroup = TeamManager.get_teamGroup_by_id(team_group_id)
    if not teamGroup or teamGroup.team_user_id != teamUser.id:
        return _response_not_manage_rights(request)
    member_username = request.POST.get('member_username', '')
    member_user = GsuserManager.get_user_by_name(member_username)
    if not member_user:
        return json_failed(500, u'没有该用户名')
    teamMember = TeamManager.get_teamMember_by_teamUserId_userId(teamUser.id, member_user.id)
    if not teamMember:
        return json_failed(500, u'用户 %s 还没有加入团队帐号 %s' % (member_user.username, teamUser.username))
    groupMember = TeamManager.get_groupMember_by_teamGroupId_memberUserId(teamGroup.id, member_user.id)
    if groupMember:
        return json_success(u'用户 %s 已经在该组' % member_user.username)
    groupMember = GroupMember(team_user_id=teamUser.id, group_id=teamGroup.id, member_user_id=member_user.id)
    groupMember.save()
    return json_success(u'成功添加用户 %s 到组 %s' % (member_user.username, teamGroup.name))
开发者ID:ZheYuan,项目名称:gitshell,代码行数:21,代码来源:views.py

示例8: permission_grant

# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_name [as 别名]
def permission_grant(request, username):
    teamUser = GsuserManager.get_user_by_name(username)
    grant_type = request.POST.get('grant_type', 'global')
    permission = int(request.POST.get('permission', '0'))
    if grant_type == 'global':
        TeamManager.grant_team_global_permission(teamUser.id, permission)
    elif grant_type == 'user':
        user_id = int(request.POST.get('user_id', '0'))
        TeamManager.grant_team_user_permission(teamUser.id, user_id, permission)
    return json_success(u'赋予权限成功')
开发者ID:ZheYuan,项目名称:gitshell,代码行数:12,代码来源:views.py

示例9: groups

# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_name [as 别名]
def groups(request, username):
    teamUser = GsuserManager.get_user_by_name(username)
    teamUserprofile = GsuserManager.get_userprofile_by_id(teamUser.id)
    teamGroups = TeamManager.list_teamGroup_by_teamUserId(teamUser.id)
    current = 'settings'; sub_nav = 'groups'; title = u'%s / 设置 / 组管理' % (teamUser.username)
    response_dictionary = {'current': current, 'sub_nav': sub_nav, 'title': title, 'teamGroups': teamGroups}
    response_dictionary.update(_get_common_team_dict(request, teamUser, teamUserprofile))
    return render_to_response('team/groups.html',
                          response_dictionary,
                          context_instance=RequestContext(request))
开发者ID:ZheYuan,项目名称:gitshell,代码行数:12,代码来源:views.py

示例10: group_add

# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_name [as 别名]
def group_add(request, username):
    teamUser = GsuserManager.get_user_by_name(username)
    group_name = request.POST.get('group_name', '')
    if not re.match('^[ 0-9a-zA-Z_-]+$', group_name):
        return json_failed(403, u'组名不符合规范,只允许[ 0-9a-zA-Z_-]之内的字符')
    teamGroup = TeamManager.get_teamGroup_by_teamUserId_name(teamUser.id, group_name)
    if teamGroup:
        return json_failed(500, u'组名已经存在')
    teamGroup = TeamGroup(team_user_id = teamUser.id, name = group_name, desc = '')
    teamGroup.save()
    return json_success(u'成功创建组 %s' % group_name)
开发者ID:ZheYuan,项目名称:gitshell,代码行数:13,代码来源:views.py

示例11: _get_team_user_userprofile

# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_name [as 别名]
def _get_team_user_userprofile(request, username):
    current_user = GsuserManager.get_user_by_name(username)
    if not current_user:
        return (request.user, request.userprofile)
    teamMember = TeamManager.get_teamMember_by_teamUserId_userId(current_user.id, request.user.id)
    if not teamMember:
        return (request.user, request.userprofile)
    current_userprofile = GsuserManager.get_userprofile_by_id(current_user.id)
    if current_userprofile:
        return (current_user, current_userprofile)
    return (request.user, request.userprofile)
开发者ID:ZheYuan,项目名称:gitshell,代码行数:13,代码来源:views.py

示例12: stats

# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_name [as 别名]
def stats(request, user_name):
    user = GsuserManager.get_user_by_name(user_name)
    if user is None:
        raise Http404
    stats_dict = get_stats_dict(request, user)
    gsuserprofile = GsuserManager.get_userprofile_by_id(user.id)
    response_dictionary = {'title': u'%s / 最近统计' % (user.username), 'gsuserprofile': gsuserprofile}
    response_dictionary.update(stats_dict)
    return render_to_response('user/stats.html',
                          response_dictionary,
                          context_instance=RequestContext(request))
开发者ID:ZheYuan,项目名称:gitshell,代码行数:13,代码来源:views.py

示例13: star_repo

# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_name [as 别名]
def star_repo(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)
    star_repos = RepoManager.list_star_repo(gsuser.id, 0, 500)
    response_dictionary = {'mainnav': 'user', 'title': title, 'star_repos': star_repos}
    response_dictionary.update(get_common_user_dict(request, gsuser, gsuserprofile))
    return render_to_response('user/star_repo.html',
                          response_dictionary,
                          context_instance=RequestContext(request))
开发者ID:ZheYuan,项目名称:gitshell,代码行数:14,代码来源:views.py

示例14: group_remove_member

# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_name [as 别名]
def group_remove_member(request, username):
    teamUser = GsuserManager.get_user_by_name(username)
    team_group_id = int(request.POST.get('team_group_id', '0'))
    teamGroup = TeamManager.get_teamGroup_by_id(team_group_id)
    if not teamGroup or teamGroup.team_user_id != teamUser.id:
        return _response_not_manage_rights(request)
    member_user_id = int(request.POST.get('member_user_id', '0'))
    groupMember = TeamManager.get_groupMember_by_teamGroupId_memberUserId(teamGroup.id, member_user_id)
    if groupMember:
        groupMember.visibly = 1
        groupMember.save()
    return json_success(u'从 %s 组移除用户' % (teamGroup.name))
开发者ID:ZheYuan,项目名称:gitshell,代码行数:14,代码来源:views.py

示例15: wrap

# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_name [as 别名]
 def wrap(request, *args, **kwargs):
     if len(args) >= 1:
         username = args[0]
         teamUser = GsuserManager.get_user_by_name(username)
         if not teamUser:
             return _response_not_admin_rights(request)
         if not request.user.is_authenticated():
             return HttpResponseRedirect('/login/?next=' + urlquote(request.path))
         teamMember = TeamManager.get_teamMember_by_teamUserId_userId(teamUser.id, request.user.id)
         if not teamMember or not teamMember.has_admin_rights():
             return _response_not_admin_rights(request)
     return function(request, *args, **kwargs)
开发者ID:ZheYuan,项目名称:gitshell,代码行数:14,代码来源:decorators.py


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