def post(self): item_id = int(self.get_argument("item_id")) value = int(self.get_argument("value")) context = self._build_common_context() DATABASE.items_add_price(item_id, value, context['identity']['user_id']) self.write({})
def post(self): user_id = self.get_current_user() or DATABASE.users_login(*validate_credentials( self.get_argument('username'), self.get_argument('password'), )) if user_id is None or user_id < 0: raise tornado.web.HTTPError(403, reason='Unable to validate access') item_id = DATABASE.items_get_id_by_base_item_id( int(self.get_argument('item_id')), bool(self.get_argument('hq', default=False)), ) if item_id is None: raise tornado.web.HTTPError(404, reason='Unknown item') cached_item = DATABASE.items_get_latest_by_id(item_id) if not cached_item.item_state.price or cached_item.item_state.price.timestamp < (time.time() - (TIME_HOUR * CONFIG['data']['prices']['api_submission_cooldown_hours'])): DATABASE.items_add_price( item_id=item_id, value_average=int(self.get_argument('value_average')), value_average_low=int(self.get_argument('value_average_low')), value_average_high=int(self.get_argument('value_average_high')), quantity=int(self.get_argument('quantity')), user_id=user_id, ) self.set_secure_cookie( CONFIG['cookies']['authentication']['identifier'], str(user_id), expires_days=CONFIG['cookies']['authentication']['longevity_days'] )
def post(self): item_id = self.get_argument("item_id", default=None) if not item_id: self.redirect("/items/search?term={term}".format( term=tornado.escape.url_escape(self.get_argument('term')), )) return item_id = int(item_id) value = self.get_argument("value", default=None) if value: try: value = int(value.strip()) except ValueError: raise tornado.web.HTTPError(422, reason="Invalid value: {value}".format( value=value, )) else: value = None context = self._build_common_context() if value is not None: DATABASE.items_add_price( item_id=item_id, value_average=value, value_average_low=value, value_average_high=value, quantity=None, user_id=context['identity']['user_id'], ) self.redirect("/items/{item_id}".format( item_id=item_id, ))
def post(self): item_id = self.get_argument("item_id", default=None) if not item_id: self.redirect("/items/search?term={term}".format( term=tornado.escape.url_escape(self.get_argument('term')), )) return item_id = int(item_id) value = self.get_argument("value", default=None) if value: try: value = int(value.strip()) except ValueError: raise tornado.web.HTTPError( 422, reason="Invalid value: {value}".format(value=value, )) else: value = None context = self._build_common_context() if value is not None: DATABASE.items_add_price( item_id=item_id, value_average=value, value_average_low=value, value_average_high=value, quantity=None, user_id=context['identity']['user_id'], ) self.redirect("/items/{item_id}".format(item_id=item_id, ))
def post(self): item_id = int(self.get_argument("item_id")) value = int(self.get_argument("value")) context = self._build_common_context() DATABASE.items_add_price( item_id=item_id, value_average=value, value_average_low=value, value_average_high=value, quantity=None, user_id=context['identity']['user_id'], ) self.write({})
def post(self): item_id = int(self.get_argument("item_id")) value = self.get_argument("value", default=None) if value: try: value = int(value.strip()) except ValueError: raise tornado.web.HTTPError(422, reason="Invalid value: {value}".format( value=value, )) else: value = None context = self._build_common_context() if value is not None: DATABASE.items_add_price(item_id, value, context['identity']['user_id']) self.redirect("/items/{item_id}".format( item_id=item_id, ))
def post(self): user_id = self.get_current_user() or DATABASE.users_login( *validate_credentials( self.get_argument('username'), self.get_argument('password'), )) if user_id is None or user_id < 0: raise tornado.web.HTTPError(403, reason='Unable to validate access') item_id = DATABASE.items_get_id_by_base_item_id( int(self.get_argument('item_id')), bool(self.get_argument('hq', default=False)), ) if item_id is None: raise tornado.web.HTTPError(404, reason='Unknown item') cached_item = DATABASE.items_get_latest_by_id(item_id) if not cached_item.item_state.price or cached_item.item_state.price.timestamp < ( time.time() - (TIME_HOUR * CONFIG['data']['prices']['api_submission_cooldown_hours'])): DATABASE.items_add_price( item_id=item_id, value_average=int(self.get_argument('value_average')), value_average_low=int(self.get_argument('value_average_low')), value_average_high=int( self.get_argument('value_average_high')), quantity=int(self.get_argument('quantity')), user_id=user_id, ) self.set_secure_cookie( CONFIG['cookies']['authentication']['identifier'], str(user_id), expires_days=CONFIG['cookies']['authentication']['longevity_days'])