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


Python UserApi.create_user方法代码示例

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


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

示例1: test_mark_read

# 需要导入模块: from tracim.lib.user import UserApi [as 别名]
# 或者: from tracim.lib.user.UserApi import create_user [as 别名]
    def test_mark_read(self):
        uapi = UserApi(None)
        groups = [GroupApi(None).get_one(Group.TIM_USER),
                  GroupApi(None).get_one(Group.TIM_MANAGER),
                  GroupApi(None).get_one(Group.TIM_ADMIN)]
        user_a = uapi.create_user(email='[email protected]',
                                 groups=groups, save_now=True)
        user_b = uapi.create_user(email='[email protected]',
                                 groups=groups, save_now=True)

        wapi = WorkspaceApi(user_a)
        workspace = wapi.create_workspace(
            'test workspace',
            save_now=True)

        role_api = RoleApi(user_a)
        role_api.create_one(user_b, workspace, UserRoleInWorkspace.READER, False)
        cont_api_a = ContentApi(user_a)
        cont_api_b = ContentApi(user_b)

        page_1 = cont_api_a.create(ContentType.Page, workspace, None,
                                   'this is a page', do_save=True)

        for rev in page_1.revisions:
            eq_(user_b not in rev.read_by.keys(), True)

        cont_api_b.mark_read(page_1)

        for rev in page_1.revisions:
            eq_(user_b in rev.read_by.keys(), True)
开发者ID:lebouquetin,项目名称:tracim,代码行数:32,代码来源:test_content_api.py

示例2: test_get_all_with_parent_id

# 需要导入模块: from tracim.lib.user import UserApi [as 别名]
# 或者: from tracim.lib.user.UserApi import create_user [as 别名]
    def test_get_all_with_parent_id(self):
        uapi = UserApi(None)
        groups = [GroupApi(None).get_one(Group.TIM_USER),
                  GroupApi(None).get_one(Group.TIM_MANAGER),
                  GroupApi(None).get_one(Group.TIM_ADMIN)]

        user = uapi.create_user(email='[email protected]',
                                groups=groups, save_now=True)
        workspace = WorkspaceApi(user).create_workspace('test workspace',
                                                        save_now=True)

        api = ContentApi(user)
        item = api.create(ContentType.Folder, workspace, None, 'parent', True)
        item2 = api.create(ContentType.File, workspace, item, 'file1', True)
        item3 = api.create(ContentType.File, workspace, None, 'file2', True)
        parent_id = item.content_id
        child_id = item2.content_id
        uid = user.user_id
        wid = workspace.workspace_id
        transaction.commit()

        # Refresh instances after commit
        user = uapi.get_one(uid)
        workspace = WorkspaceApi(user).get_one(wid)
        api = ContentApi(user)

        items = api.get_all(None, ContentType.Any, workspace)
        eq_(3, len(items))

        items2 = api.get_all(parent_id, ContentType.File, workspace)
        eq_(1, len(items2))
        eq_(child_id, items2[0].content_id)
开发者ID:Nonolost,项目名称:tracim,代码行数:34,代码来源:test_content_api.py

示例3: test_unit__get_all_manageable

# 需要导入模块: from tracim.lib.user import UserApi [as 别名]
# 或者: from tracim.lib.user.UserApi import create_user [as 别名]
 def test_unit__get_all_manageable(self):
     admin = DBSession.query(User) \
         .filter(User.email == '[email protected]').one()
     uapi = UserApi(admin)
     # Checks a case without workspaces.
     wapi = WorkspaceApi(current_user=admin)
     eq_([], wapi.get_all_manageable())
     # Checks an admin gets all workspaces.
     w4 = wapi.create_workspace(label='w4')
     w3 = wapi.create_workspace(label='w3')
     w2 = wapi.create_workspace(label='w2')
     w1 = wapi.create_workspace(label='w1')
     eq_([w1, w2, w3, w4], wapi.get_all_manageable())
     # Checks a regular user gets none workspace.
     gapi = GroupApi(None)
     u = uapi.create_user('[email protected]', [gapi.get_one(Group.TIM_USER)], True)
     wapi = WorkspaceApi(current_user=u)
     rapi = RoleApi(current_user=u)
     rapi.create_one(u, w4, UserRoleInWorkspace.READER, False)
     rapi.create_one(u, w3, UserRoleInWorkspace.CONTRIBUTOR, False)
     rapi.create_one(u, w2, UserRoleInWorkspace.CONTENT_MANAGER, False)
     rapi.create_one(u, w1, UserRoleInWorkspace.WORKSPACE_MANAGER, False)
     eq_([], wapi.get_all_manageable())
     # Checks a manager gets only its own workspaces.
     u.groups.append(gapi.get_one(Group.TIM_MANAGER))
     rapi.delete_one(u.user_id, w2.workspace_id)
     rapi.create_one(u, w2, UserRoleInWorkspace.WORKSPACE_MANAGER, False)
     eq_([w1, w2], wapi.get_all_manageable())
开发者ID:lebouquetin,项目名称:tracim,代码行数:30,代码来源:test_workspace.py

示例4: test_get_all_with_filter

# 需要导入模块: from tracim.lib.user import UserApi [as 别名]
# 或者: from tracim.lib.user.UserApi import create_user [as 别名]
    def test_get_all_with_filter(self):
        uapi = UserApi(None)
        groups = [GroupApi(None).get_one(Group.TIM_USER),
                  GroupApi(None).get_one(Group.TIM_MANAGER),
                  GroupApi(None).get_one(Group.TIM_ADMIN)]

        user = uapi.create_user(email='[email protected]',
                                groups=groups, save_now=True)
        workspace = WorkspaceApi(user).create_workspace('test workspace',
                                                        save_now=True)

        api = ContentApi(user)
        item = api.create(ContentType.Folder, workspace, None,
                          'thefolder', True)
        item2 = api.create(ContentType.File, workspace, None, 'thefile', True)
        uid = user.user_id
        wid = workspace.workspace_id
        transaction.commit()

        # Refresh instances after commit
        user = uapi.get_one(uid)
        workspace = WorkspaceApi(user).get_one(wid)
        api = ContentApi(user)

        items = api.get_all(None, ContentType.Any, workspace)
        eq_(2, len(items))

        items2 = api.get_all(None, ContentType.File, workspace)
        eq_(1, len(items2))
        eq_('thefile', items2[0].label)

        items3 = api.get_all(None, ContentType.Folder, workspace)
        eq_(1, len(items3))
        eq_('thefolder', items3[0].label)
开发者ID:buxx,项目名称:tracim,代码行数:36,代码来源:test_content_api.py

示例5: test_search_in_description

# 需要导入模块: from tracim.lib.user import UserApi [as 别名]
# 或者: from tracim.lib.user.UserApi import create_user [as 别名]
    def test_search_in_description(self):
        # HACK - D.A. - 2015-03-09
        # This test is based on a bug which does NOT return results found
        # at root of a workspace (eg a folder)

        uapi = UserApi(None)
        groups = [GroupApi(None).get_one(Group.TIM_USER),
                  GroupApi(None).get_one(Group.TIM_MANAGER),
                  GroupApi(None).get_one(Group.TIM_ADMIN)]

        user = uapi.create_user(email='[email protected]',
                                groups=groups, save_now=True)

        workspace = WorkspaceApi(user).create_workspace('test workspace',
                                                        save_now=True)

        api = ContentApi(user)
        a = api.create(ContentType.Folder, workspace, None,
                       'this is randomized folder', True)
        p = api.create(ContentType.Page, workspace, a,
                       'this is dummy label content', True)

        with new_revision(p):
            p.description = 'This is some amazing test'

        api.save(p)
        original_id = p.content_id

        res = api.search(['dummy'])
        eq_(1, len(res.all()))
        item = res.all()[0]
        eq_(original_id, item.content_id)
开发者ID:buxx,项目名称:tracim,代码行数:34,代码来源:test_content_api.py

示例6: test_get_one_by_email

# 需要导入模块: from tracim.lib.user import UserApi [as 别名]
# 或者: from tracim.lib.user.UserApi import create_user [as 别名]
    def test_get_one_by_email(self):
        api = UserApi(None)
        u = api.create_user()
        api.update(u, 'bibi', '[email protected]', True)
        uid = u.user_id
        transaction.commit()

        eq_(uid, api.get_one_by_email('[email protected]').user_id)
开发者ID:DarkDare,项目名称:tracim,代码行数:10,代码来源:test_user_api.py

示例7: test_user_with_email_exists

# 需要导入模块: from tracim.lib.user import UserApi [as 别名]
# 或者: from tracim.lib.user.UserApi import create_user [as 别名]
    def test_user_with_email_exists(self):
        api = UserApi(None)
        u = api.create_user()
        api.update(u, 'bibi', '[email protected]', True)
        transaction.commit()

        eq_(True, api.user_with_email_exists('[email protected]'))
        eq_(False, api.user_with_email_exists('unknown'))
开发者ID:DarkDare,项目名称:tracim,代码行数:10,代码来源:test_user_api.py

示例8: test_create_and_update_user

# 需要导入模块: from tracim.lib.user import UserApi [as 别名]
# 或者: from tracim.lib.user.UserApi import create_user [as 别名]
    def test_create_and_update_user(self):
        api = UserApi(None)
        u = api.create_user()
        api.update(u, 'bob', '[email protected]', True)

        nu = api.get_one_by_email('[email protected]')
        ok_(nu!=None)
        eq_('[email protected]', nu.email)
        eq_('bob', nu.display_name)
开发者ID:DarkDare,项目名称:tracim,代码行数:11,代码来源:test_user_api.py

示例9: post

# 需要导入模块: from tracim.lib.user import UserApi [as 别名]
# 或者: from tracim.lib.user.UserApi import create_user [as 别名]
    def post(
            self,
            name: str,
            email: str,
            password: str,
            is_tracim_manager: str='off',
            is_tracim_admin: str='off',
            send_email: str='off',
    ):
        is_tracim_manager = h.on_off_to_boolean(is_tracim_manager)
        is_tracim_admin = h.on_off_to_boolean(is_tracim_admin)
        send_email = h.on_off_to_boolean(send_email)
        current_user = tmpl_context.current_user

        if current_user.profile.id < Group.TIM_ADMIN:
            # A manager can't give large rights
            is_tracim_manager = False
            is_tracim_admin = False


        api = UserApi(current_user)

        if api.user_with_email_exists(email):
            tg.flash(_('A user with email address "{}" already exists.').format(email), CST.STATUS_ERROR)
            tg.redirect(self.url())

        user = api.create_user()
        user.email = email
        user.display_name = name
        if password:
            user.password = password
        elif send_email:
            # Setup a random password to send email at user
            password = str(uuid.uuid4())
            user.password = password

        user.webdav_left_digest_response_hash = '%s:/:%s' % (email, password)

        api.save(user)

        # Now add the user to related groups
        group_api = GroupApi(current_user)
        user.groups.append(group_api.get_one(Group.TIM_USER))
        if is_tracim_manager:
            user.groups.append(group_api.get_one(Group.TIM_MANAGER))
            if is_tracim_admin:
                user.groups.append(group_api.get_one(Group.TIM_ADMIN))

        api.save(user)

        if send_email:
            email_manager = get_email_manager()
            email_manager.notify_created_account(user, password=password)

        tg.flash(_('User {} created.').format(user.get_display_name()), CST.STATUS_OK)
        tg.redirect(self.url())
开发者ID:Nonolost,项目名称:tracim,代码行数:58,代码来源:user.py

示例10: test_get_notifiable_roles

# 需要导入模块: from tracim.lib.user import UserApi [as 别名]
# 或者: from tracim.lib.user.UserApi import create_user [as 别名]
 def test_get_notifiable_roles(self):
     admin = DBSession.query(User) \
         .filter(User.email == '[email protected]').one()
     wapi = WorkspaceApi(admin)
     w = wapi.create_workspace(label='workspace w', save_now=True)
     uapi = UserApi(admin)
     u = uapi.create_user(email='[email protected]', save_now=True)
     eq_([], wapi.get_notifiable_roles(workspace=w))
     rapi = RoleApi(u)
     r = rapi.create_one(u, w, UserRoleInWorkspace.READER, with_notif=True)
     eq_([r, ], wapi.get_notifiable_roles(workspace=w))
     u.is_active = False
     eq_([], wapi.get_notifiable_roles(workspace=w))
开发者ID:lebouquetin,项目名称:tracim,代码行数:15,代码来源:test_workspace.py

示例11: test_archive

# 需要导入模块: from tracim.lib.user import UserApi [as 别名]
# 或者: from tracim.lib.user.UserApi import create_user [as 别名]
    def test_archive(self):
        uapi = UserApi(None)
        groups = [GroupApi(None).get_one(Group.TIM_USER),
                  GroupApi(None).get_one(Group.TIM_MANAGER),
                  GroupApi(None).get_one(Group.TIM_ADMIN)]

        user = uapi.create_user(email='[email protected]',
                                groups=groups, save_now=True)
        workspace = WorkspaceApi(user).create_workspace('test workspace',
                                                        save_now=True)

        api = ContentApi(user)
        item = api.create(ContentType.Folder, workspace, None,
                          'not_archived', True)
        item2 = api.create(ContentType.Folder, workspace, None,
                           'to_archive', True)
        uid = user.user_id
        wid = workspace.workspace_id
        transaction.commit()

        # Refresh instances after commit
        user = uapi.get_one(uid)
        workspace = WorkspaceApi(user).get_one(wid)
        api = ContentApi(user)

        items = api.get_all(None, ContentType.Any, workspace)
        eq_(2, len(items))

        items = api.get_all(None, ContentType.Any, workspace)
        with new_revision(items[0]):
            api.archive(items[0])
        transaction.commit()

        # Refresh instances after commit
        user = uapi.get_one(uid)
        workspace = WorkspaceApi(user).get_one(wid)
        api = ContentApi(user)

        items = api.get_all(None, ContentType.Any, workspace)
        eq_(1, len(items))
        transaction.commit()

        # Refresh instances after commit
        user = uapi.get_one(uid)
        workspace = WorkspaceApi(user).get_one(wid)
        api = ContentApi(user)

        # Test that the item is still available if "show deleted" is activated
        api = ContentApi(None, show_archived=True)
        items = api.get_all(None, ContentType.Any, workspace)
        eq_(2, len(items))
开发者ID:buxx,项目名称:tracim,代码行数:53,代码来源:test_content_api.py

示例12: test_set_status_unknown_status

# 需要导入模块: from tracim.lib.user import UserApi [as 别名]
# 或者: from tracim.lib.user.UserApi import create_user [as 别名]
    def test_set_status_unknown_status(self):
        uapi = UserApi(None)
        groups = [GroupApi(None).get_one(Group.TIM_USER),
                  GroupApi(None).get_one(Group.TIM_MANAGER),
                  GroupApi(None).get_one(Group.TIM_ADMIN)]

        user = uapi.create_user(email='[email protected]',
                                groups=groups, save_now=True)

        workspace = WorkspaceApi(user).create_workspace('test workspace',
                                                        save_now=True)
        api = ContentApi(user)
        c = api.create(ContentType.Folder, workspace, None, 'parent', True)
        api.set_status(c, 'unknown-status')
开发者ID:DarkDare,项目名称:tracim,代码行数:16,代码来源:test_content_api.py

示例13: test_search_in_label_or_description

# 需要导入模块: from tracim.lib.user import UserApi [as 别名]
# 或者: from tracim.lib.user.UserApi import create_user [as 别名]
    def test_search_in_label_or_description(self):
        # HACK - D.A. - 2015-03-09
        # This test is based on a bug which does NOT return results found
        # at root of a workspace (eg a folder)

        uapi = UserApi(None)
        groups = [GroupApi(None).get_one(Group.TIM_USER),
                  GroupApi(None).get_one(Group.TIM_MANAGER),
                  GroupApi(None).get_one(Group.TIM_ADMIN)]

        user = uapi.create_user(email='[email protected]',
                                groups=groups, save_now=True)

        workspace = WorkspaceApi(user).create_workspace('test workspace',
                                                        save_now=True)


        api = ContentApi(user)

        a = api.create(ContentType.Folder, workspace, None,
                       'this is randomized folder', True)
        p1 = api.create(ContentType.Page, workspace, a,
                        'this is dummy label content', True)
        p2 = api.create(ContentType.Page, workspace, a, 'Hey ! Jon !', True)

        with new_revision(p1):
            p1.description = 'This is some amazing test'

        with new_revision(p2):
            p2.description = 'What\'s up ?'

        api.save(p1)
        api.save(p2)

        id1 = p1.content_id
        id2 = p2.content_id

        eq_(1, DBSession.query(Workspace).filter(Workspace.label == 'test workspace').count())
        eq_(1, DBSession.query(ContentRevisionRO).filter(ContentRevisionRO.label == 'this is randomized folder').count())
        eq_(2, DBSession.query(ContentRevisionRO).filter(ContentRevisionRO.label == 'this is dummy label content').count())
        eq_(1, DBSession.query(ContentRevisionRO).filter(ContentRevisionRO.description == 'This is some amazing test').count())
        eq_(2, DBSession.query(ContentRevisionRO).filter(ContentRevisionRO.label == 'Hey ! Jon !').count())
        eq_(1, DBSession.query(ContentRevisionRO).filter(ContentRevisionRO.description == 'What\'s up ?').count())

        res = api.search(['dummy', 'jon'])
        eq_(2, len(res.all()))

        eq_(True, id1 in [o.content_id for o in res.all()])
        eq_(True, id2 in [o.content_id for o in res.all()])
开发者ID:buxx,项目名称:tracim,代码行数:51,代码来源:test_content_api.py

示例14: test_set_status_ok

# 需要导入模块: from tracim.lib.user import UserApi [as 别名]
# 或者: from tracim.lib.user.UserApi import create_user [as 别名]
    def test_set_status_ok(self):
        uapi = UserApi(None)
        groups = [GroupApi(None).get_one(Group.TIM_USER),
                  GroupApi(None).get_one(Group.TIM_MANAGER),
                  GroupApi(None).get_one(Group.TIM_ADMIN)]

        user = uapi.create_user(email='[email protected]',
                                groups=groups, save_now=True)

        workspace = WorkspaceApi(user).create_workspace('test workspace',
                                                        save_now=True)
        api = ContentApi(user)
        c = api.create(ContentType.Folder, workspace, None, 'parent', True)
        for new_status in ['open', 'closed-validated', 'closed-unvalidated',
                           'closed-deprecated']:
            api.set_status(c, new_status)
            eq_(new_status, c.status)
            eq_(ActionDescription.STATUS_UPDATE, c.revision_type)
开发者ID:DarkDare,项目名称:tracim,代码行数:20,代码来源:test_content_api.py

示例15: test_create_comment_ok

# 需要导入模块: from tracim.lib.user import UserApi [as 别名]
# 或者: from tracim.lib.user.UserApi import create_user [as 别名]
    def test_create_comment_ok(self):
        uapi = UserApi(None)
        groups = [GroupApi(None).get_one(Group.TIM_USER),
                  GroupApi(None).get_one(Group.TIM_MANAGER),
                  GroupApi(None).get_one(Group.TIM_ADMIN)]

        user = uapi.create_user(email='[email protected]',
                                groups=groups, save_now=True)

        workspace = WorkspaceApi(user).create_workspace('test workspace',
                                                        save_now=True)

        api = ContentApi(user)
        p = api.create(ContentType.Page, workspace, None, 'this_is_a_page')
        c = api.create_comment(workspace, p, 'this is the comment', True)

        eq_(Content, c.__class__)
        eq_(p.content_id, c.parent_id)
        eq_(user, c.owner)
        eq_(workspace, c.workspace)
        eq_(ContentType.Comment, c.type)
        eq_('this is the comment', c.description)
        eq_('', c.label)
        eq_(ActionDescription.COMMENT, c.revision_type)
开发者ID:buxx,项目名称:tracim,代码行数:26,代码来源:test_content_api.py


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