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


Python team.Team类代码示例

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


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

示例1: add_team

def add_team(request):
    user = request.user
    if not user:
        return request.redirect("/")

    uid = request.get_form_var('uid') or ''
    name = request.get_form_var('name') or ''
    description = request.get_form_var('description') or ''

    errors = ""
    if request.method == "POST":
        teams = Team.gets()
        team_uid_pattern = re.compile(r'[a-zA-Z0-9\_]*')
        if not uid:
            error = 'uid_not_exists'
        elif not name:
            error = 'name_not_exists'
        elif uid != re.findall(team_uid_pattern, uid)[0]:
            error = 'invilid_uid'
        elif uid in [team.uid for team in teams]:
            error = 'uid_existed'
        elif User.check_exist(uid):
            error = 'user_id_existed'
        elif name in [team.name for team in teams]:
            error = 'name_existed'
        else:
            team = Team.add(uid, name, description)
            if team:
                team_created_signal.send(user.name,
                                         team_name=team.name,
                                         team_uid=team.uid)
                team.add_user(user, TEAM_OWNER)
                return request.redirect(team.url)

    return st('/teams/add_team.html', **locals())
开发者ID:000fan000,项目名称:code,代码行数:35,代码来源:__init__.py

示例2: settings

    def settings(self, request):
        user = request.user
        team = Team.get_by_uid(self.team_uid)
        if not team:
            raise TraversalError
        projects = team.projects

        input_uid = request.get_form_var("uid", "")
        input_name = request.get_form_var("name", "")
        input_description = request.get_form_var("description", "")

        error = ""
        if request.method == "POST":
            if not user:
                return request.redirect("/")

            if not team.is_owner(user.name):
                return request.redirect(team.url)

            teams = Team.gets()
            team_uid_pattern = re.compile(r"[a-zA-Z0-9\_]*")
            if not input_uid:
                error = "uid_not_exists"
            elif not input_name:
                error = "name_not_exists"
            elif input_uid != re.findall(team_uid_pattern, input_uid)[0]:
                error = "invilid_uid"
            elif input_uid in [t.uid for t in teams] and team.uid != input_uid:
                error = "uid_existed"
            elif input_name in [t.name for t in teams] and team.name != input_name:
                error = "name_existed"
            else:
                team.update(input_uid, input_name, input_description)
                return request.redirect("/hub/team/%s/settings" % input_uid)
        return st("/teams/team_settings.html", **locals())
开发者ID:leeccong,项目名称:code,代码行数:35,代码来源:team.py

示例3: _q_index

    def _q_index(self, request):
        page = request.get_form_var('page', 1)
        start = TEAMS_COUNT_PER_PAGE * (int(page) - 1)
        teams = Team.gets_by_page(start=start, limit=TEAMS_COUNT_PER_PAGE)
        total_teams = len(Team.gets())
        n_pages = (total_teams - 1) / TEAMS_COUNT_PER_PAGE + 1 if total_teams else 1  # noqa

        return st('/teams/teams.html', **locals())
开发者ID:000fan000,项目名称:code,代码行数:8,代码来源:__init__.py

示例4: test_add_and_delete_team

 def test_add_and_delete_team(self):
     team_id = "test_team"
     team_name = "测试team"
     description = "测试"
     n_team = len(Team.gets())
     team = Team.add(team_id, team_name, description)
     new_n_team = len(Team.gets())
     ok_(new_n_team == n_team + 1)
     ok_(team_id == team.uid)
     team.delete()
     new_n_team = len(Team.gets())
     ok_(new_n_team == n_team)
开发者ID:leeccong,项目名称:code,代码行数:12,代码来源:test_team.py

示例5: test_new_team_issue_participant_count

    def test_new_team_issue_participant_count(self):
        app = TestApp(M.app)
        for team in Team.gets():
            if team:
                team.delete()
        team = Team.add("test_team", "test team", "test")
        issue = TeamIssue.add('test', 'test description', 'test', team=team.id)
        resp = app.get(issue.url)

        assert resp.status_int == 200
        assert 'Issues' in resp.body
        assert '<strong>1</strong> participant' in resp.text
        assert '<strong>1</strong> participants' not in resp.text
开发者ID:000fan000,项目名称:code,代码行数:13,代码来源:test_participant_count.py

示例6: add_user

    def add_user(self, request):
        user = request.user
        team = Team.get_by_uid(self.team_uid)
        if not user or not team:
            return dict(r=1, error="team不存在")

        user_id = request.get_form_var("user_id", "")
        identity = int(request.get_form_var("identity", 0))

        if not team.is_owner(user.name) or identity not in TEAM_IDENTITY_INFO.keys():
            return dict(r=1, error="没有权限")

        rl = TeamUserRelationship.get(team_id=team.id, user_id=user_id)
        if not rl:
            team.add_user(User(user_id), identity)
        elif identity == rl.identity:
            return dict(r=1, error="该用户已存在")
        elif rl.is_owner and team.n_owners == 1:
            return dict(r=1, error="只剩一个creator, 不能改变身份")
        else:
            rl.identity = identity
            rl.save()

        avatar_url = User(user_id).avatar_url
        team_add_member_signal.send(
            user.name,
            team_uid=team.uid,
            team_name=team.name,
            receiver=user_id,
            identity=TEAM_IDENTITY_INFO[identity]["name"],
        )
        return dict(r=0, uid=user_id, avatar_url=avatar_url)
开发者ID:leeccong,项目名称:code,代码行数:32,代码来源:team.py

示例7: comment

    def comment(self, request):
        target = self.target
        issue = self.issue
        issue_id = self.issue_id
        current_user = request.user

        if request.method == 'POST':
            content = request.get_form_var('content', '').decode('utf-8')
            user = request.user
            user = user.name if user else None
            if user:
                author = user
                if content.strip():
                    comment = issue.add_comment(content, user)
                    issue.add_participant(user)
                    html = st('/widgets/issue/issue_comment.html', **locals())
                else:
                    return {'error': 'Content is empty'}

                if request.get_form_var('comment_and_close'):
                    issue.close(author)
                    # TODO: 重构feed后取消信号发送
                    issue_signal.send(author=author, content=content,
                                      issue_id=issue_id)
                    dispatch('issue', data={
                             'sender': author,
                             'content': content,
                             'issue': issue,
                             })
                    return dict(r=0, reload=1, redirect_to=issue.url)
                elif request.get_form_var('comment_and_open'):
                    issue.open()
                    # TODO: 重构feed后取消信号发送
                    issue_signal.send(author=author, content=content,
                                      issue_id=issue_id)
                    dispatch('issue', data={
                             'sender': author,
                             'content': content,
                             'issue': issue,
                             })
                    return dict(r=0, reload=1, redirect_to=issue.url)
                elif content:
                    issue_comment_signal.send(author=author,
                                              content=comment.content,
                                              issue_id=comment.issue_id,
                                              comment_id=comment.id)
                    dispatch('issue_comment', data={
                             'sender': author,
                             'content': comment.content,
                             'issue': issue,
                             'comment': comment})
                participants = issue.participants

                teams = Team.get_all_team_uids()

                participants_html = st('/widgets/participation.html',
                                       **locals())  # FIXME: locals()?
                return dict(
                    r=0, html=html, participants_html=participants_html)
        return request.redirect(issue.url)
开发者ID:000fan000,项目名称:code,代码行数:60,代码来源:issue.py

示例8: card_info

def card_info(request):
    user_or_team_id = request.get_form_var('user')
    team = Team.get_by_uid(user_or_team_id)
    user_existed = User.check_exist(user_or_team_id)
    if not team or user_existed:
        user = User(user_or_team_id)
        data = {
            'user': {'name': user_or_team_id, 'avatar': user.avatar_url,
                     'url': user.url,
                     'badges': [{'img': item.badge.get_image_url(),
                                 'name': item.badge.name,
                                 'reason': item.reason or item.badge.summary}
                                for item in user.get_badge_items()]}
        }
    else:
        members = team.user_ids[::-1]  # 根据团队的时间排序
        displayed_users = [User(uid) for uid in team.user_ids[:8]]
        data = {
            'team': {
                'id': team.uid,
                'name': team.name,
                'url': team.url,
                'desc': team.short_description,
                'profile_url': team.profile_url(),
                'members': [{'uid': u.name, 'avatar_url': u.avatar_url}
                            for u in displayed_users],
                'member_count': len(members)
            }
        }
    return json.dumps(data)
开发者ID:000fan000,项目名称:code,代码行数:30,代码来源:__init__.py

示例9: test_at_team

    def test_at_team(self):
        mention = "test_team"
        team_name = "测试team"
        description = "测试"
        team = Team.add(mention, team_name, description)
        ok_(team.uid == mention)

        content = "@test_team code"
        users = get_mentions_from_text(content)
        ok_(len(users) == 0)

        team_id = team.id
        user_id = "chengeng"
        identity = 2
        rl = TeamUserRelationship.create(team_id=team_id,
                                         user_id=user_id,
                                         identity=identity)
        ok_(rl.user_id == user_id)

        users = get_mentions_from_text(content)
        ok_(users[0] == user_id)

        rl.delete()

        users = get_mentions_from_text(content)
        ok_(len(users) == 0)

        team.delete()

        users = get_mentions_from_text(content)
        ok_(users[0] == mention)
开发者ID:leeccong,项目名称:code,代码行数:31,代码来源:test_team.py

示例10: _q_index

def _q_index(request):
    user = request.user
    my_issues = []
    if user:
        username = user.username

        your_projects = CodeDoubanProject.get_projects(owner=username,
                                                       sortby='lru')
        watched_projects = CodeDoubanProject.get_watched_others_projects_by_user(  # noqa
            user=username,
            sortby='lru')

        teams = Team.get_by_user_id(user.name)
        actions = get_user_inbox(username).get_actions(
            stop=PAGE_ACTIONS_COUNT - 1)
        badge_items = user.get_badge_items()

        # pull request
        # your_tickets = user.get_user_pull_requests_rank(limit=5)
        your_tickets = user.get_user_submit_pull_requests(limit=5)

        # issue
        project_ids = CodeDoubanProject.get_ids(user.name)
        dt = {
            'state': "open",
            'limit': 5,
            'start': 0,
        }
        my_issues = ProjectIssue.gets_by_project_ids(project_ids, **dt)

        return st('newsfeed.html', **locals())
    return request.redirect("/teams/")
开发者ID:000fan000,项目名称:code,代码行数:32,代码来源:__init__.py

示例11: leave

    def leave(self, request):
        user = request.user
        team = Team.get_by_uid(self.team_uid)
        if not user or not team:
            return dict(r=1)

        team.remove_user(user)
        return dict(r=0)
开发者ID:leeccong,项目名称:code,代码行数:8,代码来源:team.py

示例12: new

 def new(self, request):
     user = request.user
     current_user = request.user
     team = self.team
     tags = team.tags
     error = request.get_form_var("error")
     teams = Team.get_all_team_uids()
     return st("issue/new_team_issue.html", **locals())
开发者ID:leeccong,项目名称:code,代码行数:8,代码来源:team.py

示例13: __init__

    def __init__(self, team_uid, issue_number):
        self.target = Team.get_by_uid(team_uid)
        self.issue_number = issue_number

        team_issue = TeamIssue.get(self.target.id, number=self.issue_number)
        self.issue_id = team_issue.issue_id
        self.issue = Issue.get_cached_issue(self.issue_id)
        self.issue_template = "issue/team_issue.html"
开发者ID:leeccong,项目名称:code,代码行数:8,代码来源:team.py

示例14: _get_team_by_uid

def _get_team_by_uid(uid):
    _team = Team.get_by_uid(uid)
    team = dict(
        id=_team.id,
        uid=_team.uid,
        name=_team.name,
    )
    return team
开发者ID:000fan000,项目名称:code,代码行数:8,代码来源:timeline.py

示例15: new

 def new(self, request):
     project_name = self.proj_name
     project = self.project
     user = request.user
     tags = project.tags
     error = request.get_form_var('error')
     teams = Team.get_all_team_uids()
     return st('issue/new.html', **locals())
开发者ID:000fan000,项目名称:code,代码行数:8,代码来源:issue.py


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