本文整理汇总了Python中models.Box.by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Box.by_id方法的具体用法?Python Box.by_id怎么用?Python Box.by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Box
的用法示例。
在下文中一共展示了Box.by_id方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render_page
# 需要导入模块: from models import Box [as 别名]
# 或者: from models.Box import by_id [as 别名]
def render_page(self, flag, errors=[]):
''' Wrapper to .render() to avoid duplicate code '''
user = self.get_current_user()
box = Box.by_id(flag.box_id)
self.render('missions/box.html',
box=box,
team=user.team,
errors=errors,
)
示例2: to_dict
# 需要导入模块: from models import Box [as 别名]
# 或者: from models.Box import by_id [as 别名]
def to_dict(self):
''' Returns public data as a dict '''
box = Box.by_id(self.box_id)
return {
'name': self.name,
'uuid': self.uuid,
'description': self.description,
'value': self.value,
'box': box.uuid,
'token': self.token,
}
示例3: post
# 需要导入模块: from models import Box [as 别名]
# 或者: from models.Box import by_id [as 别名]
def post(self, *args, **kwargs):
''' Purchase a hint '''
uuid = self.get_argument('uuid', '')
hint = Hint.by_uuid(uuid)
box = Box.by_id(hint.box_id)
if hint is not None:
user = self.get_current_user()
if hint.price <= user.team.money:
self._purchase_hint(hint, user.team)
self.render_page(box)
else:
self.render_page(box, ["You cannot afford to purchase this hint."])
else:
self.render_page(box, ["Hint does not exist."])
示例4: post
# 需要导入模块: from models import Box [as 别名]
# 或者: from models.Box import by_id [as 别名]
def post(self, *args, **kwargs):
''' Purchase a hint '''
uuid = self.get_argument('uuid', '')
hint = Hint.by_uuid(uuid)
box = Box.by_id(hint.box_id)
if hint is not None:
user = self.get_current_user()
if hint.price <= user.team.money:
logging.info("%s (%s) purchased a hint for $%d on %s" % (
user.handle, user.team.name, hint.price, box.name
))
self._purchase_hint(hint, user.team)
self.render_page(box)
else:
self.render_page(box, ["You cannot afford to purchase this hint."])
else:
self.render_page(box, ["Hint does not exist."])
示例5: box
# 需要导入模块: from models import Box [as 别名]
# 或者: from models.Box import by_id [as 别名]
def box(self):
return Box.by_id(self.box_id)