本文整理汇总了Python中models.account.Account.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Account.get_by_id方法的具体用法?Python Account.get_by_id怎么用?Python Account.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.account.Account
的用法示例。
在下文中一共展示了Account.get_by_id方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models.account import Account [as 别名]
# 或者: from models.account.Account import get_by_id [as 别名]
def post(self, user_id):
self._require_admin()
user = Account.get_by_id(user_id)
user.display_name = self.request.get("display_name")
user.put()
self.redirect("/admin/user/" + user_id)
示例2: get
# 需要导入模块: from models.account import Account [as 别名]
# 或者: from models.account.Account import get_by_id [as 别名]
def get(self, user_id):
self._require_admin()
user = Account.get_by_id(user_id)
self.template_values.update({
"user": user
})
path = os.path.join(os.path.dirname(__file__), '../../templates/admin/user_edit.html')
self.response.out.write(template.render(path, self.template_values))
示例3: post
# 需要导入模块: from models.account import Account [as 别名]
# 或者: from models.account.Account import get_by_id [as 别名]
def post(self, user_id):
self._require_admin()
user = Account.get_by_id(user_id)
user.display_name = self.request.get("display_name")
user.permissions = []
for enum in AccountPermissions.permissions:
permcheck = self.request.get("perm-" + str(enum))
if permcheck :
user.permissions.append(enum)
user.put()
self.redirect("/admin/user/" + user_id)
示例4: post
# 需要导入模块: from models.account import Account [as 别名]
# 或者: from models.account.Account import get_by_id [as 别名]
def post(self):
self._require_registration()
# Check to make sure that they aren't trying to edit another user
real_account_id = self.user_bundle.account.key.id()
check_account_id = self.request.get('account_id')
if check_account_id == real_account_id:
user = Account.get_by_id(self.user_bundle.account.key.id())
user.display_name = self.request.get('display_name')
user.put()
self.redirect('/account?status=account_edit_success')
else:
self.redirect('/account?status=account_edit_failure')
示例5: post
# 需要导入模块: from models.account import Account [as 别名]
# 或者: from models.account.Account import get_by_id [as 别名]
def post(self):
self._require_login('/account/edit')
self._require_registration('/account/register')
# Check to make sure that they aren't trying to edit another user
real_account_id = self.user_bundle.account.key.id()
check_account_id = self.request.get('account_id')
if check_account_id == real_account_id:
user = Account.get_by_id(self.user_bundle.account.key.id())
user.display_name = self.request.get('display_name')
user.put()
self.redirect('/account')
else:
self.redirect('/')
示例6: get
# 需要导入模块: from models.account import Account [as 别名]
# 或者: from models.account.Account import get_by_id [as 别名]
def get(self):
self._require_admin()
if tba_config.CONFIG["env"] != "prod":
account = Account.get_by_id(self.user_bundle.account.key.id())
account.display_name = "Test User"
account.registered = True
account.permissions = AccountPermissions.permissions.keys()
account.put()
self.redirect("/admin/user/" + account.key.id())
else:
logging.error("{} tried to set up a test user in prod! No can do.".format(
self.user_bundle.user.email()))
self.redirect("/admin/")
示例7: post
# 需要导入模块: from models.account import Account [as 别名]
# 或者: from models.account.Account import get_by_id [as 别名]
def post(self):
self._require_login('/account/register')
if self.user_bundle.account.registered:
self.redirect('/account')
return None
# Check to make sure that they aren't trying to edit another user
real_account_id = self.user_bundle.account.key.id()
check_account_id = self.request.get('account_id')
if check_account_id == real_account_id:
account = Account.get_by_id(self.user_bundle.account.key.id())
account.display_name = self.request.get('display_name')
account.registered = True
account.put()
self.redirect('/account')
else:
self.redirect('/')
示例8: user_email_to_id
# 需要导入模块: from models.account import Account [as 别名]
# 或者: from models.account.Account import get_by_id [as 别名]
def user_email_to_id(cls, user_email):
'''
Returns the user id for a given email address (or None if invalid)
workaround for this bug: https://code.google.com/p/googleappengine/issues/detail?id=8848
solution from: http://stackoverflow.com/questions/816372/how-can-i-determine-a-user-id-based-on-an-email-address-in-app-engine
'''
u = users.User(user_email)
key = MobileUser(user=u).put()
obj = key.get()
user_id = obj.user.user_id()
key.delete()
if Account.get_by_id(user_id) is None:
# Create an account for this user
Account(id=user_id, email = user_email, nickname = user_email.split('@')[0], registered = False).put()
return user_id
示例9: post
# 需要导入模块: from models.account import Account [as 别名]
# 或者: from models.account.Account import get_by_id [as 别名]
def post(self):
self._require_login()
if self.user_bundle.account.registered:
self.redirect("/account", abort=True)
# Check to make sure that they aren't trying to edit another user
real_account_id = self.user_bundle.account.key.id()
check_account_id = self.request.get("account_id")
if check_account_id == real_account_id:
account = Account.get_by_id(self.user_bundle.account.key.id())
account.display_name = self.request.get("display_name")
account.registered = True
account.put()
redirect = self.request.get("redirect")
if redirect:
self.redirect(redirect, abort=True)
else:
self.redirect("/account", abort=True)
else:
self.redirect("/")