def mallResults(): if request.method == "POST": mallname = request.form['mall'] else: if (mallCtrl.checkInstance() == "empty"): return render_template( 'home.html', result="Session time out, please search again") else: mallname = mallCtrl.checkInstance().getName() retParam = mallCtrl.checkNullMallName(mallname) if (retParam == "error"): return render_template('home.html', result="Mall not found") else: result = mallCtrl.chckValidMallInDB(mallname) if result: mallobj = mallCtrl.createMallObj(result) else: return render_template('home.html', result="Mall not found") mallid = mallCtrl.retrieveMallID(mallobj.getName()) results = shopCtrl.retrieveAllShops(mallid) validResults = shopCtrl.checkShopResults(results) if (validResults == "error"): return render_template('home.html', result="Shop detail not available") else: shopArray = shopCtrl.formatShopsResults(results, mallobj.getName()) mallobj.setShopArray(shopArray) return render_template("mallResults.html", result=json.dumps(shopArray))
def updateShopInfo(): if AdminCtrl.checkAdminInstance() == "empty": return render_template('indexAdmin.html', result="Session timeout, please relogin") if request.method == "POST": unitNumber = request.form['unitNum'] oldsname = request.form['oldsname'] shopname = request.form['sname'] category = request.form['category'] mallname = request.form['mname'] retParam = shopCtrl.checkNullShopName(shopname) if (retParam == "error"): return render_template( "adminUpdatePage.html", result="Shopname or category cannot be empty", name=AdminCtrl.checkAdminInstance().getUsername()) else: mallid = mallCtrl.checkInstance().getId() shopid = shopCtrl.fetchShopID(unitNumber, mallid, oldsname) shopCtrl.updateField(shopid[0], category, shopname) shopArray = mallCtrl.checkInstance().getShopArray() for item in shopArray['values']: if (item['Unit'] == unitNumber and item['ShopName'] == oldsname): item['ShopName'] = shopname item['Category'] = category break mallCtrl.checkInstance().setShopArray(shopArray) shopArrayNew = mallCtrl.checkInstance().getShopArray() return render_template( "adminUpdatePage.html", result=json.dumps(shopArrayNew), name=AdminCtrl.checkAdminInstance().getUsername())
def updateSelectionPage(): if AdminCtrl.checkAdminInstance() == "empty": return render_template('indexAdmin.html', result="Session timeout, please relogin") if request.method == "POST": mallname = request.form['mall'] else: if (mallCtrl.checkInstance() == "empty"): return render_template( 'home.html', result="Session time out, please search again") else: mallname = mallCtrl.checkInstance().getName() retParam = mallCtrl.checkNullMallName(mallname) if (retParam == "error"): return render_template( 'adminSelectionPage.html', result="Mall not found", name=AdminCtrl.checkAdminInstance().getUsername()) else: if (mallCtrl.checkInstance() != "empty"): if (mallname == mallCtrl.checkInstance().getName()): print("executing efficiency code") return render_template( "adminUpdatePage.html", result=json.dumps(mallCtrl.checkInstance().getShopArray()), name=AdminCtrl.checkAdminInstance().getUsername()) mallid = mallCtrl.retrieveMallID(mallname) if not mallid: return render_template( 'adminSelectionPage.html', result="Mall not found", name=AdminCtrl.checkAdminInstance().getUsername()) else: results = shopCtrl.retrieveAllShops(mallid) mallresults = mallCtrl.chckValidMallInDB(mallname) mallobj = mallCtrl.createMallObj(mallresults) validResults = shopCtrl.checkShopResults(results) if (validResults == "error"): return render_template( 'adminSelectionPage.html', result="Shop detail not available", name=AdminCtrl.checkAdminInstance().getUsername()) else: shopArray = shopCtrl.formatShopsResults( results, mallobj.getName()) mallobj.setShopArray(shopArray) return render_template( "adminUpdatePage.html", result=json.dumps(shopArray), name=AdminCtrl.checkAdminInstance().getUsername())
def parkingResults(): if (mallCtrl.checkInstance() == "empty"): return render_template("home.html", result="Session time out, please search again") else: mallCoordinates = parkingCtrl.fetchMallCoordinates( mallCtrl.checkInstance().getName()) malladdress = parkingCtrl.fetchMallAddress( mallCtrl.checkInstance().getName()) mallParkingInfo = parkingCtrl.formatMallParkingResults( mallCtrl.checkInstance().getName()) nearbyParkingInfo = parkingCtrl.formatNearbyparkingResults( mallCoordinates) return render_template("parkingResults.html", result=mallParkingInfo, result2=nearbyParkingInfo)
def updateMallName(): if AdminCtrl.checkAdminInstance() == "empty": return render_template('indexAdmin.html', result="Session timeout, please relogin") if request.method == "POST": newmallname = request.form['newmallname'] oldmallname = request.form['oldmallname'] retParam = mallCtrl.checkNullMallName(oldmallname) if (retParam == "error"): return render_template( "adminUpdatePage.html", result="Input Field empty", name=AdminCtrl.checkAdminInstance().getUsername()) else: mallid = mallCtrl.checkInstance().getId() mallCtrl.updateField(mallid, newmallname) shopArrayNew = mallCtrl.checkInstance().getShopArray() shopArrayNew['mname'] = newmallname return render_template( "adminUpdatePage.html", result=json.dumps(shopArrayNew), name=AdminCtrl.checkAdminInstance().getUsername())