def defaultRequest(): oGetData = GetData() oUnisportData = oGetData.GetUnisportData() oSortData = SortData() oSortedData = oSortData.sortByPrice(oUnisportData, True) #convert the list back to json return json.dumps(oSortedData)
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)
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)
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)
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)
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)