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, )
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, )
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, }
def to_dict(self): ''' Returns public data as a dict ''' box = Box.by_id(self.box_id) return { 'name': self.name, 'uuid': self.uuid, 'token': self.token, 'description': self.description, 'value': self.value, 'box': box.uuid, }
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."])
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."])
def box(self): return Box.by_id(self.box_id)