本文整理汇总了Python中autonomie.models.user.User.get方法的典型用法代码示例。如果您正苦于以下问题:Python User.get方法的具体用法?Python User.get怎么用?Python User.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autonomie.models.user.User
的用法示例。
在下文中一共展示了User.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_company_index
# 需要导入模块: from autonomie.models.user import User [as 别名]
# 或者: from autonomie.models.user.User import get [as 别名]
def test_company_index(self):
avatar = User.get(3)
self.config.add_route('company', '/company/{cid}')
self.config.add_static_view('static', 'autonomie:static')
request = self.get_csrf_request()
request._user = avatar
request.user = avatar
request.context = avatar.companies[0]
response = company_index(request)
self.assertEqual(avatar.companies[0].name, response['company'].name )
示例2: submit_success
# 需要导入模块: from autonomie.models.user import User [as 别名]
# 或者: from autonomie.models.user.User import get [as 别名]
def submit_success(self, appstruct):
"""
Edit the database entry and return redirect
"""
user_id = appstruct.get('user_id')
company = Company()
company = merge_session_with_post(company, appstruct)
if user_id is not None:
user_account = User.get(user_id)
if user_account is not None:
company.employees.append(user_account)
self.dbsession.add(company)
self.dbsession.flush()
message = u"L'entreprise '{0}' a bien été ajoutée".format(company.name)
self.session.flash(message)
return HTTPFound(self.request.route_path("company", id=company.id))
示例3: company_remove_employee_view
# 需要导入模块: from autonomie.models.user import User [as 别名]
# 或者: from autonomie.models.user.User import get [as 别名]
def company_remove_employee_view(context, request):
"""
Enlève un employé de l'entreprise courante
"""
uid = request.params.get("uid")
if not uid:
request.session.flash("Missing uid parameter", "error")
user = User.get(uid)
if not user:
request.session.flash("User not found", "error")
if user in context.employees:
context.employees = [employee for employee in context.employees if employee != user]
request.session.flash(
u"L'utilisateur {0} ne fait plus partie de l'entreprise {1}".format(format_account(user), context.name)
)
url = request.referer
if url is None:
url = request.route_path("company", id=context.id)
return HTTPFound(url)
示例4: test_get_company
# 需要导入模块: from autonomie.models.user import User [as 别名]
# 或者: from autonomie.models.user.User import get [as 别名]
def test_get_company(self):
user1 = User.get(3)
cid = 1
company = user1.get_company(cid)
self.assertEqual(company.name, u'Laveur de K-ro')
self.assertRaises(KeyError, user1.get_company, 3000)