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


Python UserApi.update方法代码示例

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


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

示例1: put

# 需要导入模块: from tracim.lib.user import UserApi [as 别名]
# 或者: from tracim.lib.user.UserApi import update [as 别名]
    def put(self, user_id, name, email, timezone, next_url=None):
        user_id = tmpl_context.current_user.user_id
        current_user = tmpl_context.current_user
        user_api = UserApi(current_user)
        assert user_id==current_user.user_id
        if next_url:
            next = tg.url(next_url)
        else:
            next = self.url()

        try:
            email_user = user_api.get_one_by_email(email)
            if email_user != current_user:
                tg.flash(_('Email already in use'), CST.STATUS_ERROR)
                tg.redirect(next)
        except NoResultFound:
            pass

        # Only keep allowed field update
        updated_fields = self._clean_update_fields({
            'name': name,
            'email': email,
            'timezone': timezone,
        })

        api = UserApi(tmpl_context.current_user)
        api.update(current_user, do_save=True, **updated_fields)
        tg.flash(_('profile updated.'))
        tg.redirect(next)
开发者ID:lebouquetin,项目名称:tracim,代码行数:31,代码来源:user.py

示例2: test_get_one_by_email

# 需要导入模块: from tracim.lib.user import UserApi [as 别名]
# 或者: from tracim.lib.user.UserApi import update [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

示例3: test_user_with_email_exists

# 需要导入模块: from tracim.lib.user import UserApi [as 别名]
# 或者: from tracim.lib.user.UserApi import update [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

示例4: test_create_and_update_user

# 需要导入模块: from tracim.lib.user import UserApi [as 别名]
# 或者: from tracim.lib.user.UserApi import update [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

示例5: put

# 需要导入模块: from tracim.lib.user import UserApi [as 别名]
# 或者: from tracim.lib.user.UserApi import update [as 别名]
    def put(self, user_id, name, email, next_url=''):
        api = UserApi(tmpl_context.current_user)

        user = api.get_one(int(user_id))
        api.update(user, name, email, True)

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

示例6: put

# 需要导入模块: from tracim.lib.user import UserApi [as 别名]
# 或者: from tracim.lib.user.UserApi import update [as 别名]
    def put(self, user_id, name, email, next_url=None):
        user_id = tmpl_context.current_user.user_id
        current_user = tmpl_context.current_user
        assert user_id==current_user.user_id

        api = UserApi(tmpl_context.current_user)
        api.update(current_user, name, email, True)
        tg.flash(_('profile updated.'))
        if next_url:
            tg.redirect(tg.url(next_url))
        tg.redirect(self.url())
开发者ID:DarkDare,项目名称:tracim,代码行数:13,代码来源:user.py

示例7: put

# 需要导入模块: from tracim.lib.user import UserApi [as 别名]
# 或者: from tracim.lib.user.UserApi import update [as 别名]
    def put(self, user_id, name, email, next_url=None):
        user_id = tmpl_context.current_user.user_id
        current_user = tmpl_context.current_user
        assert user_id==current_user.user_id

        # Only keep allowed field update
        updated_fields = self._clean_update_fields({
            'name': name,
            'email': email
        })

        api = UserApi(tmpl_context.current_user)
        api.update(current_user, do_save=True, **updated_fields)
        tg.flash(_('profile updated.'))
        if next_url:
            tg.redirect(tg.url(next_url))
        tg.redirect(self.url())
开发者ID:Nonolost,项目名称:tracim,代码行数:19,代码来源:user.py

示例8: test_get_one

# 需要导入模块: from tracim.lib.user import UserApi [as 别名]
# 或者: from tracim.lib.user.UserApi import update [as 别名]
 def test_get_one(self):
     api = UserApi(None)
     u = api.create_user()
     api.update(u, 'titi', '[email protected]', True)
     one = api.get_one(u.user_id)
     eq_(u.user_id, one.user_id)
开发者ID:DarkDare,项目名称:tracim,代码行数:8,代码来源:test_user_api.py


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