def get(self): listing_id = int(self.path_tail()) listing = Listing.get_by_id(listing_id) if not listing: self.error(404) return self.write_json(listing.encode_builtin(bids=True))
def post(self): try: post = self.body_json() listing_id = int(post["id"]) listing = Listing.get_by_id(listing_id) if not listing: self.error(404) return current_user = users.get_current_user() if current_user and (listing.owner == user_steam_id(current_user.nickname())): db_result = listing.cancel("Cancelled by user.") else: import logging logging.warn( "wtf %s %s %s", user_steam_id(current_user.nickname()), listing.owner, current_user.nickname() == listing.owner, ) self.error(401) return result = {"msg": "okay", "result": db_result} except (Exception,), exc: self.error(500) exc = exc.message if hasattr(exc, "message") else str(exc) result = {"msg": "error", "description": exc}
def post(self): try: post = self.body_json() listing_id = int(post['id']) listing = Listing.get_by_id(listing_id) if not listing: self.error(404) return bid = post['bid'] current_user = users.get_current_user() if current_user and (listing.owner == user_steam_id(current_user.nickname())): db_result = listing.winner(bid) else: self.error(401) return result = {'msg':'okay', 'result':db_result} except (Exception, ), exc: self.error(500) exc = exc.message if hasattr(exc, 'message') else str(exc) result = {'msg':'error', 'description':exc}