當前位置: 首頁>>代碼示例>>Python>>正文


Python Box.by_id方法代碼示例

本文整理匯總了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,
     )
開發者ID:CRYPTOlab,項目名稱:RootTheBox,代碼行數:11,代碼來源:MissionsHandler.py

示例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,
     }
開發者ID:CRYPTOlab,項目名稱:RootTheBox,代碼行數:13,代碼來源:Flag.py

示例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."])
開發者ID:lavalamp-,項目名稱:RootTheBox,代碼行數:16,代碼來源:MissionsHandler.py

示例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."])
開發者ID:CRYPTOlab,項目名稱:RootTheBox,代碼行數:19,代碼來源:MissionsHandler.py

示例5: box

# 需要導入模塊: from models import Box [as 別名]
# 或者: from models.Box import by_id [as 別名]
 def box(self):
     return Box.by_id(self.box_id)
開發者ID:CRYPTOlab,項目名稱:RootTheBox,代碼行數:4,代碼來源:Flag.py


注:本文中的models.Box.by_id方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。