Exemple #1
0
 def POST(self):
     post_params = web.input()
     #if(defined(post_params)):
     restaurantId = post_params['restaurantId']
     name = post_params['name']
     category = post_params['category']
     minPrice = post_params['minPrice']
     maxPrice = post_params['maxPrice']
     city = post_params['city']
     lat = post_params['lat']
     longi = post_params['long']
     distance = post_params['distance']
     minStars = post_params['minStars']
     t = sqlitedb.transaction()
     try:
         search_result = sqlitedb.search(restaurantId, name, category,
                                         minPrice, maxPrice, city, lat,
                                         longi, distance, minStars)
         updateMessage = 'search successful'
     except Exception as e:
         t.rollback()
         updateMessage = str(e)
         #search_result = 'error'
         return render_template('search.html', message=updateMessage)
     else:
         t.commit()
         return render_template('search.html',
                                message=updateMessage,
                                search_result=search_result)
    def POST(self):
        post_params = web.input()
        itemID = post_params['itemID']
        category = post_params['category']
        global description
        description = post_params['description']
        minPrice = post_params['minPrice']
        maxPrice = post_params['maxPrice']
        status = post_params['status']

        print len(description)
        if len(description) > 30:
            msg = "Description is overlong. Please try a short description."
            search_result = []
            return render_template('search.html',
                                   message=msg,
                                   search_result=search_result)
        else:
            search_result = sqlitedb.search(itemID, category, description,
                                            minPrice, maxPrice, status)
            if len(search_result) != 0:
                msg = "Your results are listed below"
            else:
                msg = "No results found"
            return render_template('search.html',
                                   message=msg,
                                   search_result=search_result)
Exemple #3
0
 def POST(self):
     
     #get the form values
     post_params = web.input()
     itemID = post_params['itemID']
     category = post_params['category']
     userID = post_params['userID']
     minPrice = post_params['minPrice']
     maxPrice = post_params['maxPrice']
     status = post_params['status']
     description = post_params['description']
     
     self.results = sqlitedb.search(itemID, category, userID, minPrice, maxPrice, status, description)
                          
     if (self.results != None):
         self.total = len(self.results)
         self.page = 1
         
         if self.total <= 14:
             until = self.total
         else:
             until = 14
         
         return render_template('search.html', message = 'Showing results 0 - ' + str(until) + ' of ' + str(self.total) + ' results found', search_result = self.results, total = self.total, page = self.page)
     else:
         self.total = -1
         self.page = 0
         return render_template('search.html', message = 'Error: search failed', search_results = self.results, total = self.total)
Exemple #4
0
 def POST(self):
     post_params = web.input()
     results = sqlitedb.search(post_params['itemID'], post_params['userID'],
                               post_params['category'],
                               post_params['description'],
                               post_params['minPrice'],
                               post_params['maxPrice'],
                               post_params['status'])
     return render_template('search.html', search_result=results)
Exemple #5
0
 def POST(self):
     post_params = web.input()
     searchKeys = [
         post_params['itemID'], post_params["userID"],
         post_params["minPrice"], post_params["maxPrice"],
         post_params["itemDescription"], post_params["status"]
     ]
     result = sqlitedb.search(searchKeys)
     return render_template('search.html',
                            message="Type in fields to search by",
                            search_result=result)
Exemple #6
0
 def POST(self):
     post_params = web.input()
     itemID = post_params['itemID']
     userID = post_params['userID']
     category = post_params['category']
     itemDesc = post_params['itemDesc']
     minPrice = post_params['minPrice']
     maxPrice = post_params['maxPrice']
     status = post_params['status']
     t = sqlitedb.transaction()
     try:
         Items = sqlitedb.search(itemID, userID, category, itemDesc,
                                 maxPrice, minPrice, status)
         result = {}
         item_list = []
         category_list = []
         Bid_list = []
         winner_list = []
         for itemID in Items:
             item = sqlitedb.getItemById(itemID)
             item_list.append(item)
             category_list.append(sqlitedb.getCategoryByID(itemID))
             currTime = sqlitedb.getTime()
             #check if buy_price is reached
             if item.Buy_Price != None and item.Buy_Price <= item.Currently and item.Number_of_Bids != 0:
                 status = "Closed"
             else:
                 if currTime < item.Started:
                     status = 'NotStarted'
                 elif currTime > item.Ends:
                     status = 'Closed'
                 else:
                     status = 'Open'
             Bid_list.append(sqlitedb.getBidsByID(itemID))
             winner = None
             if status == 'Closed':
                 winner = sqlitedb.getWinnerByID(itemID)
             winner_list.append(winner)
             #print(map(itemgetter('Category'), sqlitedb.getCategoryByID(itemID)))
     except Exception as e:
         t.rollback()
         print(str(e))
         return render_template('search.html', message=str(e))
     else:
         t.commit()
         return render_template('search_result.html',
                                Item=item_list,
                                Categories=category_list,
                                status=status,
                                Bids=Bid_list,
                                Winner=winner_list)
Exemple #7
0
 def POST(self):
     post_params = web.input()
     itemID = post_params['itemID']
     userID = post_params['userID']
     minPrice = post_params['minPrice']
     maxPrice = post_params['maxPrice']
     status = post_params['status']
     category = post_params['category']
     itemDescription = post_params['itemDescription']
     time = sqlitedb.getTime()
     search_result = sqlitedb.search(itemID, userID, minPrice, maxPrice,
                                     status, time, category,
                                     itemDescription)
     # buy price is None
     return render_template('search.html', search_result=search_result)
    def POST(self):
        def addVals(keys,mp,params):
            for key in keys:
                if post_params[key] != "":
                    mp[key] = params[key]

        post_params = web.input()
        keys = ["itemID","userID","minPrice","maxPrice","description","status"]
        values = {}
        addVals(keys,values,post_params)
        results = sqlitedb.search(values)
        #results[0] = No error
        #results[1] = Error message
        #results[2] = Tuples
        if results[0] == True:
            message = "Your results are below!"
        else:
            message = results[1]
        return render_template('search.html', message = message, search_result = results[2])
Exemple #9
0
 def POST(self):
     categories = sqlitedb.getAllCategories()
     post_params = web.input()
     restaurantId = post_params['restaurantId']
     name = post_params['name']
     category = post_params['category']
     minPrice = post_params['minPrice']
     maxPrice = post_params['maxPrice']
     city = post_params['city']
     lat = post_params['lat']
     longi = post_params['long']
     distance = post_params['distance']
     minStars = post_params['minStars']
     numResults = post_params['numResults']
     sortBy = post_params['sortBy']
     #print post_params
     t = sqlitedb.transaction()
     try:
         search_result = sqlitedb.search(restaurantId, name, category,
                                         minPrice, maxPrice, city, lat,
                                         longi, distance, minStars,
                                         numResults, sortBy)
         #search_result = sqlitedb.search(None, None, None, None, None, None, None, None, None, '5')
         #search_result = sqlitedb.getRestaurantById('W9Bh_7mfuUrEAdQBJMVOvA')
         updateMessage = 'search successful'
     except Exception as e:
         t.rollback()
         updateMessage = str(e)
         #search_result = 'error'
         #return json.dumps({'status': 1, 'message': updateMessage})
         return render_template('search.html',
                                message=updateMessage,
                                categories=categories)
     else:
         t.commit()
         #return json.dumps({'status': 0, 'results': list(search_result)})
         return render_template('search.html',
                                message=updateMessage,
                                search_result=search_result,
                                categories=categories)
    def POST(self):
        post_params = web.input()

        results = sqlitedb.search(post_params)

        return render_template('search.html', search_result=results)