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


Python Team.add方法代码示例

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


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

示例1: test_at_team

# 需要导入模块: from vilya.models.team import Team [as 别名]
# 或者: from vilya.models.team.Team import add [as 别名]
    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,代码行数:33,代码来源:test_team.py

示例2: add_team

# 需要导入模块: from vilya.models.team import Team [as 别名]
# 或者: from vilya.models.team.Team import add [as 别名]
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,代码行数:37,代码来源:__init__.py

示例3: test_new_team_issue_participant_count

# 需要导入模块: from vilya.models.team import Team [as 别名]
# 或者: from vilya.models.team.Team import add [as 别名]
    def test_new_team_issue_participant_count(self):
        app = TestApp(M.app)
        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:mozillazg,项目名称:code,代码行数:12,代码来源:test_participant_count.py

示例4: test_add_and_delete_team

# 需要导入模块: from vilya.models.team import Team [as 别名]
# 或者: from vilya.models.team.Team import add [as 别名]
 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,代码行数:14,代码来源:test_team.py


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