Ejemplo n.º 1
0
 def defaultRequest():
     oGetData = GetData()
     oUnisportData = oGetData.GetUnisportData()
     
     oSortData = SortData()
     oSortedData = oSortData.sortByPrice(oUnisportData, True)
     #convert the list back to json
     return json.dumps(oSortedData)
Ejemplo n.º 2
0
 def productUpdateIdRequest(iProductId,sKey,sValue):
     oGetData = GetData()
     oUnisportData = oGetData.GetUnisportData()
         
     if not (iProductId.isdigit()):
         return "Product value should only contain numbers"
         
     oManipulateData = ManipulateData()
     oSortedData = oManipulateData.updateProductById(oUnisportData, int(iProductId), sKey, sValue)
 
     #convert the list back to json
     return json.dumps(oSortedData)   
Ejemplo n.º 3
0
 def productIdRequest(iProductId):
     oGetData = GetData()
     oUnisportData = oGetData.GetUnisportData()
         
     if not (iProductId.isdigit()):
         return "Product value should only contain numbers"
         
     oSortData = SortData()
     oSortedData = oSortData.getSpecificDictById(oUnisportData, int(iProductId))
 
     #convert the list back to json
     return json.dumps(oSortedData)
Ejemplo n.º 4
0
 def productsKidsRequest():
     oGetData = GetData()
     oUnisportData = oGetData.GetUnisportData()
     
     oSortData   = SortData()
     oSortedData = oSortData.getDictsByStringInKeyValue(oUnisportData, "name", "Børn")
     #paginate the result to only show 10 pr page,         #paginate the result to only show 10 pr page
     iPageVar=1
     #paginate the result to only show 10 pr page
     oPage= oSortData.paginateList(oSortedData, iPageVar, 10)
     #convert the list back to json
     return json.dumps(oPage)
Ejemplo n.º 5
0
    def productCreateRequest():
        oGetData = GetData()
        oUnisportData = oGetData.GetUnisportData()

        if not request.json:
            return "json data not valid"           
        
        oNewProduct = json.loads(request.json)    
        oManipulateData = ManipulateData()
        oSortedData = oManipulateData.createProduct(oUnisportData, oNewProduct)
    
        #convert the list back to json
        return json.dumps(oSortedData)    
Ejemplo n.º 6
0
 def productsRequest():
     oGetData = GetData()
     oUnisportData = oGetData.GetUnisportData()
     
     oSortData = SortData()
     oSortedData = oSortData.sortByPrice(oUnisportData, False)
     
     iPageVar = str(request.args.get('page'))
     #test if the page value only contains numbers
     if not (iPageVar.isdigit()):
         iPageVar="1"
     #paginate the result to only show 10 pr page
     oPage= oSortData.paginateList(oSortedData, iPageVar, 10)
     
     #oPage = paginate.Page(oSortedData,page=iPageVar,items_per_page=10)
     #convert the list back to json
     return json.dumps(oPage)