def POST(self): post_params = web.input() item_id = post_params['item_id'] bid_result = sqlitedb.getBids(item_id) item = sqlitedb.getItemById(item_id) categories = sqlitedb.getCategory(item_id) current_time = sqlitedb.getTime() if item['Buy_Price'] is not None: buy_price = item['Buy_Price'] else: buy_price = float('inf') winner = None if item['Ends'] > current_time and item['Currently'] < buy_price: open = True else: if item['Number_of_Bids'] > 0: winner = sqlitedb.getBuyer(item_id, item['Currently'])['UserID'] open = False return render_template('item.html', bid_result=bid_result, item=item, categories=categories, open=open, winner=winner)
def GET(self): get_params = web.input() itemID = get_params['itemID'] # get item tuple from item ID item = sqlitedb.getItemById(itemID) # get bids bids = sqlitedb.getBids(itemID) # get categories categories = sqlitedb.getCategories(itemID) # get auction status auction_status = sqlitedb.getAuctionStatus(itemID) # get winner if auction is closed winner = None if auction_status == sqlitedb.AuctionStatus.CLOSED: winner = sqlitedb.getWinner(itemID) return render_template('auction.html', item=item, bids=bids, categories=categories, auction_status=auction_status, winner=winner)
def GET(self): id = web.input()['id'] item = sqlitedb.searchItem(id)[0] bids = sqlitedb.getBids(id) item['Category'] = ', '.join(sqlitedb.getCategory(id)) # check status cur_time = sqlitedb.getTime() if cur_time < item['Started']: item['Status'] = 'Not Started' elif cur_time > item['Ends'] or ( item['Buy_Price'] is not None and float(item['Currently']) >= float(item['Buy_Price'])): item['Status'] = 'Close' else: item['Status'] = 'Open' if len(bids) == 0 or item['Status'] is not 'Close': winner = [] else: winner = max(bids, key=lambda bid: bid['Amount']) return render_template('item.html', item=item, bids=bids, winner=winner)
def GET(self): param = web.input() if (len(param) == 0): return render_template('single_item_view.html') id = param.Id item = sqlitedb.getItemById(id) if (not item): update_message = "No Such Item" return render_template('single_item_view.html', message=update_message) # get stuff from items table (category, item, description, etc) result = sqlitedb.getItemReWrite(id) # get categories of item categories = sqlitedb.getItemCategories(id) # figure out if the auction is closed or open auctionMessage = "Open" winning_bidder = None if not sqlitedb.hasAuctionStartedSQLOnly(id): auctionMessage = "Closed" if sqlitedb.hasAuctionEnded(id): auctionMessage = "Closed" if sqlitedb.getWinningBidder(id) is not None: winning_bidder = sqlitedb.getWinningBidder(id) bids = sqlitedb.getBids(id) if (not bids): allBids = [] if winning_bidder is not None: return render_template('single_item_view.html', results=result, categories=categories.Category, auctionMessage=auctionMessage, winningBidder=winning_bidder) return render_template( 'single_item_view.html', results=result, categories=categories.Category, auctionMessage=auctionMessage, ) else: allBids = bids print bids[0]['UserID'] if winning_bidder is not None: return render_template('single_item_view.html', results=result, categories=categories.Category, auctionMessage=auctionMessage, allBids=bids, winningBidder=winning_bidder) return render_template( 'single_item_view.html', results=result, categories=categories.Category, auctionMessage=auctionMessage, allBids=bids, )
def GET(self, items): print('The item id is = ', int(items)) itemID = int(items) tempItem = sqlitedb.getItemById(itemID) # the item attributes are already present # get the categories for the item tempItem['Categories'] = sqlitedb.getCategory(itemID) # determine the auctions open/close status # check if the item is still open if (string_to_time(tempItem['Started']) <= string_to_time( sqlitedb.getTime())) and (string_to_time( tempItem['Ends']) >= string_to_time( sqlitedb.getTime())) and (tempItem['Buy_Price'] > tempItem['Currently']): tempItem['Status'] = 'Open' # check if the item is closed elif (string_to_time(tempItem['Ends']) < string_to_time( sqlitedb.getTime())) or (tempItem['Buy_Price'] <= tempItem['Currently']): tempItem['Status'] = 'Close' # check if the auction for the item has not started elif string_to_time(tempItem['Started']) > string_to_time( sqlitedb.getTime()): tempItem['Status'] = 'Not Started' # determine winner if the auction is closed, determine bids if auction is open if tempItem['Status'] == 'Close': try: win = sqlitedb.getAuctionWinner(itemID) tempItem['Winner'] = win except: tempItem['Winner'] = "No Winners" bids = sqlitedb.getBids(itemID) bidderList = [] for b in bids: bidderList.append({ 'UserID': b['UserID'], 'Amount': b['Amount'], 'Time': b['Time'] }) # bidderList.append() "Bidder: " + b['UserID'] + " , Price: " + str(b['Amount']) + " --- Time of Bid: " + b['Time'] + ' | ' tempItem['Bids'] = bidderList results = [tempItem] return render_template('show_item.html', search_result=results)
def POST(self, item): post_params = web.input() itemID = post_params['itemID'] # get the item tempItem = sqlitedb.getItemById(itemID) # the item attributes are already present # get the categories for the item tempItem['Categories'] = sqlitedb.getCategory(itemID) # determine the auctions open/close status # check if the item is still open if (string_to_time(tempItem['Started']) <= string_to_time( sqlitedb.getTime())) and (string_to_time( tempItem['Ends']) >= string_to_time( sqlitedb.getTime())) and (tempItem['Buy_Price'] > tempItem['Currently']): tempItem['Status'] = 'Open' # check if the item is closed elif (string_to_time(tempItem['Ends']) < string_to_time( sqlitedb.getTime())) or (tempItem['Buy_Price'] <= tempItem['Currently']): tempItem['Status'] = 'Close' # check if the auction for the item has not started elif string_to_time(tempItem['Started']) > string_to_time( sqlitedb.getTime()): tempItem['Status'] = 'Not Started' # determine winner if the auction is closed, determine bids if auction is open if tempItem['Status'] == 'Close': win = sqlitedb.getAuctionWinner(itemID) tempItem['Winner'] = win bids = sqlitedb.getBids(itemID) bidderList = "" for b in bids: bidderList += "Bidder: " + b['UserID'] + " --- Price: " + str( b['Amount']) + " --- Time of Bid: " + b['Time'] + ' | ' tempItem['Bids'] = bidderList results = [tempItem] return render_template('show_item.html', search_result=results)
def POST(self): #grab parameters from post post_params = web.input() item_id = post_params['itemID'] #check if itemID is valid, if not, let user know if not sqlitedb.checkItemID(item_id): message = "Item was not found" return render_template('single_item_view.html', message=message) #get stuff from items table (category, item, description, etc) result = sqlitedb.getItemReWrite(item_id) #get categories of item categories = sqlitedb.getItemCategories(item_id) #figure out if the auction is closed or open auctionMessage = "Open" winning_bidder = None if not sqlitedb.hasAuctionStartedSQLOnly(item_id): auctionMessage = "Closed" if sqlitedb.hasAuctionEnded(item_id): auctionMessage = "Closed" if sqlitedb.getWinningBidder(item_id) is not None: winning_bidder = sqlitedb.getWinningBidder(item_id) bids = sqlitedb.getBids(item_id) print bids[0]['UserID'] if winning_bidder is not None: return render_template('single_item_view.html', results=result, categories=categories.Category, auctionMessage=auctionMessage, allBids=bids, winningBidder=winning_bidder) return render_template( 'single_item_view.html', results=result, categories=categories.Category, auctionMessage=auctionMessage, allBids=bids, )
def POST(self): post_params = web.input() item_id = post_params['item_id'] bid = sqlitedb.getBids(item_id) item = sqlitedb.getItemById(item_id) category = sqlitedb.getCategory(item_id) time = sqlitedb.getTime() price = item['Buy_Price'] winner = None if item['Ends'] > time and item['Currently'] < price: open = True else: if item['Number_of_Bids'] > 0: winner = sqlitedb.getWinner(item_id, item['Currently'])['UserID'] open = False return render_template('auction_detail.html', bid_result=bid, item=item, categories=category, open=open, winner=winner)