def deleteRestaurant(restaurant_id): # Get user info for the user menu user = userData.getCurrentUserInfo() # Fetches the restaurant to delete restaurant = db.getRestaurant(restaurant_id) # Checks whether the user has access to this content if not allowAccess(restaurant.user_id, user["id"]): # Inform the user output = "You are not authorized to delete the %s restaurant. Please create your own restaurant in order to delete!" % restaurant.name flash(output, "alert-danger") # Redirects to the new area return redirect(url_for('showRestaurants')) if request.method == 'POST': if validateStateToke(request.form['csrf']): # Deleting from database db.deleteRestaurant(restaurant) # Inform the user output = "Restaurant %s was deleted!" % restaurant.name flash(output, "alert-success") # Redirects to the new area return redirect(url_for('showRestaurants')) else: # Render template return render_template('deleteRestaurant.html', restaurant=restaurant, token=antiForgeryGenToke(), username=user['name'], user_picture=user['picture'])
def showMenuXML(restaurant_id): restaurant = db.getRestaurant( restaurant_id ) items = db.getAllRestaurantMenuItems( restaurant ) xml = Element('restaurant') xml.set('id', str(restaurant.id)) xml.set('name', restaurant.name) for item in items: xml.append(item.serialize_xml) return xmlResponse(xml)
def showMenuXML(restaurant_id): restaurant = db.getRestaurant(restaurant_id) items = db.getAllRestaurantMenuItems(restaurant) xml = Element('restaurant') xml.set('id', str(restaurant.id)) xml.set('name', restaurant.name) for item in items: xml.append(item.serialize_xml) return xmlResponse(xml)
def NewMenuItem(restaurant_id): # Get user info for the user menu user = userData.getCurrentUserInfo() # Fetches the context restaurant restaurant = db.getRestaurant( restaurant_id ) # Checks whether the user has access to this content if not allowAccess( restaurant.user_id, user["id"] ): # Inform the user output = "You are not authorized to add menu items to %s restaurant. Please create your own restaurant in order to add items." % restaurant.name flash(output, "alert-danger") # Redirects to the new area return redirect( url_for('showmenu', restaurant_id = restaurant_id) ) # Fetches all courses type courses = db.getAllCourses() if request.method == 'POST': if validateStateToke( request.form['csrf'] ): # Save the new menu item db.newRestaurantMenuItem( name = request.form['name'], restaurant_id = restaurant_id, description = request.form['description'], price = '${:,.2f}'.format(float(request.form['price'])), user_id = user["id"], course_name = request.form['course'] ) # Inform the user flash("New menu item created!", "alert-success") # Redirects to the new area return redirect( url_for('showmenu', restaurant_id = restaurant_id) ) else: # Render template return render_template( 'newMenuItem.html', restaurant = restaurant, courses = courses, token = antiForgeryGenToke(), username = user['name'], user_picture = user['picture'] )
def NewMenuItem(restaurant_id): # Get user info for the user menu user = userData.getCurrentUserInfo() # Fetches the context restaurant restaurant = db.getRestaurant(restaurant_id) # Checks whether the user has access to this content if not allowAccess(restaurant.user_id, user["id"]): # Inform the user output = "You are not authorized to add menu items to %s restaurant. Please create your own restaurant in order to add items." % restaurant.name flash(output, "alert-danger") # Redirects to the new area return redirect(url_for('showmenu', restaurant_id=restaurant_id)) # Fetches all courses type courses = db.getAllCourses() if request.method == 'POST': if validateStateToke(request.form['csrf']): # Save the new menu item db.newRestaurantMenuItem(name=request.form['name'], restaurant_id=restaurant_id, description=request.form['description'], price='${:,.2f}'.format( float(request.form['price'])), user_id=user["id"], course_name=request.form['course']) # Inform the user flash("New menu item created!", "alert-success") # Redirects to the new area return redirect(url_for('showmenu', restaurant_id=restaurant_id)) else: # Render template return render_template('newMenuItem.html', restaurant=restaurant, courses=courses, token=antiForgeryGenToke(), username=user['name'], user_picture=user['picture'])
def editRestaurant(restaurant_id): # Get user info for the user menu user = userData.getCurrentUserInfo() # Fetches the restaurant to edit restaurant = db.getRestaurant( restaurant_id ) # Checks whether the user has access to this content if not allowAccess( restaurant.user_id, user["id"] ): # Inform the user output = "You are not authorized to edit the %s restaurant. Please create your own restaurant in order to edit!" % restaurant.name flash(output, "alert-danger") # Redirects to the new area return redirect( url_for('showRestaurants') ) if request.method == 'POST': if validateStateToke( request.form['csrf'] ): # Save the edited restaurant name = request.form['name'] file_path = filesHandler.uploadImage( request.files['file'] ) print "----------->" db.updateRestaurant( restaurant = restaurant, name = name, picture = file_path ) # Inform the user output = "Restaurant %s was edited!" % name flash( output, "alert-success" ) # Redirects to the new area return redirect( url_for('showRestaurants') ) else: # Render template return render_template( 'editRestaurant.html', restaurant = restaurant, token = antiForgeryGenToke(), username = user['name'], user_picture = user['picture'] )
def editRestaurant(restaurant_id): # Get user info for the user menu user = userData.getCurrentUserInfo() # Fetches the restaurant to edit restaurant = db.getRestaurant(restaurant_id) # Checks whether the user has access to this content if not allowAccess(restaurant.user_id, user["id"]): # Inform the user output = "You are not authorized to edit the %s restaurant. Please create your own restaurant in order to edit!" % restaurant.name flash(output, "alert-danger") # Redirects to the new area return redirect(url_for('showRestaurants')) if request.method == 'POST': if validateStateToke(request.form['csrf']): # Save the edited restaurant name = request.form['name'] file_path = filesHandler.uploadImage(request.files['file']) print "----------->" db.updateRestaurant(restaurant=restaurant, name=name, picture=file_path) # Inform the user output = "Restaurant %s was edited!" % name flash(output, "alert-success") # Redirects to the new area return redirect(url_for('showRestaurants')) else: # Render template return render_template('editRestaurant.html', restaurant=restaurant, token=antiForgeryGenToke(), username=user['name'], user_picture=user['picture'])
def showmenu(restaurant_id): # Get user info for the user menu user = userData.getCurrentUserInfo() # Fetches the context restaurant restaurant = db.getRestaurant(restaurant_id) # Fetches all items from the context restaurant items = db.getAllRestaurantMenuItems(restaurant) # Fetches all courses type, and respective menu items courses = db.getAllRestItemsByCourses(restaurant) # Render template return render_template('menu.html', filesPath=filesHandler.getFilesFolder(), restaurant=restaurant, items=list(items), courses=courses, user_id=user['id'], username=user['name'], user_picture=user['picture'])
def showmenu(restaurant_id): # Get user info for the user menu user = userData.getCurrentUserInfo() # Fetches the context restaurant restaurant = db.getRestaurant( restaurant_id ) # Fetches all items from the context restaurant items = db.getAllRestaurantMenuItems( restaurant ) # Fetches all courses type, and respective menu items courses = db.getAllRestItemsByCourses( restaurant ) # Render template return render_template( 'menu.html', filesPath = filesHandler.getFilesFolder(), restaurant = restaurant, items = list(items), courses = courses, user_id = user['id'], username = user['name'], user_picture = user['picture'] )
def deleteRestaurant(restaurant_id): # Get user info for the user menu user = userData.getCurrentUserInfo() # Fetches the restaurant to delete restaurant = db.getRestaurant( restaurant_id ) # Checks whether the user has access to this content if not allowAccess( restaurant.user_id, user["id"] ): # Inform the user output = "You are not authorized to delete the %s restaurant. Please create your own restaurant in order to delete!" % restaurant.name flash( output, "alert-danger" ) # Redirects to the new area return redirect( url_for('showRestaurants') ) if request.method == 'POST': if validateStateToke( request.form['csrf'] ): # Deleting from database db.deleteRestaurant( restaurant ) # Inform the user output = "Restaurant %s was deleted!" % restaurant.name flash(output, "alert-success") # Redirects to the new area return redirect( url_for('showRestaurants') ) else: # Render template return render_template( 'deleteRestaurant.html', restaurant = restaurant, token = antiForgeryGenToke(), username = user['name'], user_picture = user['picture'] )
def showMenuJSON(restaurant_id): restaurant = db.getRestaurant( restaurant_id ) items = db.getAllRestaurantMenuItems( restaurant ) return jsonify( MenuItems=[i.serialize_json for i in items] )
def showRestaurantJSON(restaurant_id): restaurant = db.getRestaurant( restaurant_id ) return jsonify( restaurant.serialize_json )
def showMenuJSON(restaurant_id): restaurant = db.getRestaurant(restaurant_id) items = db.getAllRestaurantMenuItems(restaurant) return jsonify(MenuItems=[i.serialize_json for i in items])
def showRestaurantJSON(restaurant_id): restaurant = db.getRestaurant(restaurant_id) return jsonify(restaurant.serialize_json)
def showRestaurantXML(restaurant_id): restaurant = db.getRestaurant( restaurant_id ) return xmlResponse( restaurant.serialize_xml )
def showRestaurantXML(restaurant_id): restaurant = db.getRestaurant(restaurant_id) return xmlResponse(restaurant.serialize_xml)