本文整理匯總了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)