def deleteShopList(): """ It deletes the shopping list by name """ name = request.args.get("lname") date_created = request.args.get("date") all_names = '' if 'User' in session: if name is not None: ShoppingList.deleteShoppingList(name, session['User'], date_created) else: ShoppingList.deleteShoppingListByDate(session['User'], date_created) all_names = ShoppingList.getShoppingListNames(session['User']) return redirect ('/getShoppingLists') else: flash = [] flash = "You need to login" return render_template("/error.html",url="homepage.html")
def getShoppingList(name=None): """ It searches a shopping list by name or finds the latest saved""" shop_list = '' all_names = '' i_list = {} date_created = '' if 'User' in session: if name: shop_list = ShoppingList.getShoppingListByName(name, session['User']) else: shop_list = ShoppingList.getLatestShoppingList(session['User']) if shop_list: name = shop_list[0].list_name if len(shop_list) > 0: date_created = shop_list[0].date_created all_names = ShoppingList.getShoppingListNames(session['User']) i_list = helpFunctions.makeShoppingList(shop_list) return render_template("view_shopping_list.html", list=i_list, names=all_names, date_created=date_created, name=name ) else: flash = [] flash = "You need to login" return render_template("/error.html", url="/getShoppingLists")