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


Python models.GsuserManager类代码示例

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


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

示例1: notif_pull_request_status

 def notif_pull_request_status(self, pullRequest, pullStatus):
     notif_type = NOTIF_TYPE.MERGE_CREATE_PULL_REQUEST
     message = ''
     if pullStatus == PULL_STATUS.NEW:
         message = u'新建了'
         merge_user_profile = GsuserManager.get_userprofile_by_id(pullRequest.merge_user_id)
         if merge_user_profile is not None:
             notifMessage = NotifMessage.create(NOTIF_CATE.MERGE, NOTIF_TYPE.MERGE_CREATE_PULL_REQUEST, pullRequest.pull_user_id, pullRequest.merge_user_id, pullRequest.id)
             notifMessage.message = message
             self.message_save_and_notif(notifMessage)
         merge_user_profile.unread_message = merge_user_profile.unread_message + 1
         merge_user_profile.save()
         return
     if pullStatus == PULL_STATUS.MERGED_FAILED:
         notif_type = NOTIF_TYPE.MERGE_MERGED_FAILED_PULL_REQUEST
         message = u'合并失败'
     elif pullStatus == PULL_STATUS.MERGED:
         notif_type = NOTIF_TYPE.MERGE_MERGED_PULL_REQUEST
         message = u'合并了'
     elif pullStatus == PULL_STATUS.REJECTED:
         notif_type = NOTIF_TYPE.MERGE_REJECTED_PULL_REQUEST
         message = u'拒绝了'
     elif pullStatus == PULL_STATUS.CLOSE:
         notif_type = NOTIF_TYPE.MERGE_CLOSE_PULL_REQUEST
         message = u'关闭了'
     pull_user_profile = GsuserManager.get_userprofile_by_id(pullRequest.pull_user_id)
     if pull_user_profile is not None:
         notifMessage = NotifMessage.create(NOTIF_CATE.MERGE, notif_type, pullRequest.merge_user_id, pullRequest.pull_user_id, pullRequest.id)
         notifMessage.message = message
         self.message_save_and_notif(notifMessage)
     pull_user_profile.unread_message = pull_user_profile.unread_message + 1
     pull_user_profile.save()
开发者ID:ZheYuan,项目名称:gitshell,代码行数:32,代码来源:models.py

示例2: fillwith

 def fillwith(self):
     self.short_refname = self.refname
     if self.refname and '/' in self.refname:
         self.short_refname = self.refname[self.refname.rfind('/')+1:]
     self.repo = RepoManager.get_repo_by_id(self.repo_id)
     self.committer_userprofile = GsuserManager.get_userprofile_by_name(self.committer)
     self.author_userprofile = GsuserManager.get_userprofile_by_name(self.author)
开发者ID:ZheYuan,项目名称:gitshell,代码行数:7,代码来源:models.py

示例3: watch_user

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,代码行数:33,代码来源:views.py

示例4: github_authenticate

def github_authenticate(thirdpartyUser):
    tp_id, tp_username, tp_email, github_user_info = thirdpartyUser.tp_id, thirdpartyUser.tp_username, thirdpartyUser.tp_email, thirdpartyUser.github_user_info
    thirdpartyUser_find = GsuserManager.get_thirdpartyUser_by_type_tpId(ThirdpartyUser.GITHUB, tp_id)
    if thirdpartyUser_find is not None:
        if thirdpartyUser_find.access_token != thirdpartyUser.access_token:
            thirdpartyUser_find.access_token = thirdpartyUser.access_token
            thirdpartyUser_find.save()
        user_id = thirdpartyUser_find.id
        user = GsuserManager.get_user_by_id(user_id)
        return user
    username = __get_uniq_username(tp_username)
    email = __get_uniq_email(tp_email)
    password = __get_random_password()
    if username is None or email is None or password is None:
        return None
    create_user = None
    try:
        create_user = User.objects.create_user(username, email, password)
        if create_user is not None and create_user.is_active:
            userprofile = Userprofile(username = create_user.username, email = create_user.email, imgurl = hashlib.md5(create_user.email.lower()).hexdigest())
            _fill_github_user_info(userprofile, github_user_info)
            userprofile.id = create_user.id
            userprofile.save()
            if username == tp_username and email == tp_email:
                thirdpartyUser.init = 1
            thirdpartyUser.user_type = ThirdpartyUser.GITHUB
            thirdpartyUser.id = create_user.id
            thirdpartyUser.save()
    except IntegrityError, e:
        logger.exception(e)
开发者ID:ZheYuan,项目名称:gitshell,代码行数:30,代码来源:views.py

示例5: notif_at

    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,代码行数:32,代码来源:models.py

示例6: list_teamMember_by_teamUserId

 def list_teamMember_by_teamUserId(self, team_user_id):
     userprofile = GsuserManager.get_userprofile_by_id(team_user_id)
     if userprofile.is_team_account == 0:
         return []
     teamMembers = query(TeamMember, team_user_id, 'teammember_l_teamUserId', [team_user_id])
     for x in teamMembers:
         x.user = GsuserManager.get_userprofile_by_id(x.user_id)
         x.team_user = userprofile
     return teamMembers
开发者ID:ZheYuan,项目名称:gitshell,代码行数:9,代码来源:models.py

示例7: list_teamMember_by_userId

 def list_teamMember_by_userId(self, user_id):
     userprofile = GsuserManager.get_userprofile_by_id(user_id)
     if userprofile.has_joined_team == 0:
         return []
     teamMembers = query(TeamMember, None, 'teammember_l_userId', [user_id])
     for x in teamMembers:
         x.user = GsuserManager.get_userprofile_by_id(x.user_id)
         x.team_user = GsuserManager.get_userprofile_by_id(x.team_user_id)
     return teamMembers
开发者ID:ZheYuan,项目名称:gitshell,代码行数:9,代码来源:models.py

示例8: recommend_delete

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,代码行数:9,代码来源:views.py

示例9: groups

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,代码行数:10,代码来源:views.py

示例10: __get_uniq_username

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,代码行数:11,代码来源:views.py

示例11: __get_uniq_email

def __get_uniq_email(tp_email):
    if tp_email is not None:
        user = GsuserManager.get_user_by_email(tp_email)
        if user is None:
            return tp_email
    for i in range(0, 1000):
        random_email = ('%8x' % random.getrandbits(64)) + '@example.com'
        user = GsuserManager.get_user_by_email(random_email)
        if user is None:
            return random_email
    return None
开发者ID:ZheYuan,项目名称:gitshell,代码行数:11,代码来源:views.py

示例12: _get_team_user_userprofile

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,代码行数:11,代码来源:views.py

示例13: stats

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,代码行数:11,代码来源:views.py

示例14: email_primary

def email_primary(request, eid):
    usermail = GsuserManager.get_useremail_by_id(eid)
    if not usermail or usermail.user_id != request.user.id:
        return json_failed(500, u'设置失败,没有权限')
    useremails = GsuserManager.list_useremail_by_userId(request.user.id)
    for x in useremails:
        if usermail.id != x.id and x.is_primary == 1:
            x.is_primary = 0
            x.save()
    usermail.is_primary = 1
    usermail.save()
    return json_success(u'成功设置默认邮箱 %s' % usermail.email)
开发者ID:ZheYuan,项目名称:gitshell,代码行数:12,代码来源:views.py

示例15: get_attrs

def get_attrs(username, reponame):
    user = GsuserManager.get_user_by_name(username)
    if not user:
        return_all_none()
    userprofile = GsuserManager.get_userprofile_by_id(user.id)
    if not userprofile:
        return_all_none()
    repo = RepoManager.get_repo_by_userId_name(user.id, reponame)
    if not repo:
        return_all_none()
    abs_repo_path = repo.get_abs_repopath()
    return (user, userprofile, repo, abs_repo_path)
开发者ID:ZheYuan,项目名称:gitshell,代码行数:12,代码来源:hookworker.py


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