def select_all(): cuisines = [] sql = "SELECT * FROM cuisines" results = run_sql(sql) for result in results: cuisine = Cuisine(result['cuisine'], result['id']) cuisines.append(cuisine) return cuisines
def create_cuisine(): user = User.get_by_id(get_jwt_identity()) if user.is_admin: name = request.json.get("name") if name == "": return error cuisine = Cuisine(name=name) if cuisine.save(): return jsonify({ "successful": True, "message": name + " cuisine is created successfully" }) else: return jsonify( {"errors": "Non-admin user detected. Request cannot be done."})
'password_confirmation': 'pass' }) cath, errors = user_schema.load({ 'username': '******', 'email': 'cath@email', 'password': '******', 'password_confirmation': 'pass' }) david, errors = user_schema.load({ 'username': '******', 'email': 'david@email', 'password': '******', 'password_confirmation': 'pass' }) french = Cuisine(name='French') thai = Cuisine(name='Thai') indonesian = Cuisine(name='Indonesian') chinese = Cuisine(name='Chinese') turkish = Cuisine(name='Turkish') italian = Cuisine(name='Italian') fusion = Cuisine(name='Fusion') moroccan = Cuisine(name='Moroccan') quick = Tag(name='Quick') student = Tag(name='Student') budget = Tag(name='Budget') family = Tag(name='Family') seasonal = Tag(name='Seasonal') summer = Tag(name='Summer') winter = Tag(name='Winter')
order_dish_repository.delete_all() customer_repository.delete_all() cuisine_repository.delete_all() restaurant_repository.delete_all() order_repository.delete_all() dish_repository.delete_all() customer1 = Customer("Jenken", "1 Street Name", "Card", "07123456789", "Delivery") customer_repository.save(customer1) customer1 = Customer("Jenken2", "2 Street Name", "Card", "07123456789", "Delivery") customer_repository.save(customer1) chinese = Cuisine("Chinese") cuisine_repository.save(chinese) japanese = Cuisine("Japanese") cuisine_repository.save(japanese) fast_food = Cuisine("Fast Food") cuisine_repository.save(fast_food) mcdonalds = Restaurant("McDonalds", "137 Princes St", "01312263872", True, fast_food) restaurant_repository.save(mcdonalds) kfc = Restaurant("KFC", "36 Nicolson St", "01316629524", True, fast_food) restaurant_repository.save(kfc) cheeseburger = Dish("Cheeseburger", 0.99, "A burger with cheese", mcdonalds) dish_repository.save(cheeseburger) doublecheeseburger = Dish("Double Cheeseburger", 1.99,
def select(id): sql = "SELECT * FROM cuisines WHERE id = %s" values = [id] result = run_sql(sql, values)[0] cuisine = Cuisine(result['cuisine'], result['id']) return cuisine
def update_cuisines(id): cuisine = request.form["cuisine"] update_cuisine = Cuisine(cuisine, id) cuisine_repository.update(update_cuisine) return redirect("/cuisines")
def create_cuisines(): cuisine = request.form['cuisine'] new_cuisine = Cuisine(cuisine) cuisine_repository.save(new_cuisine) return redirect("/cuisines")
session3.add(record) data3 = Load_Data_3("csv/1time.csv") for i in data3: record = Time(**{'id': i[0], 'minutes': i[1]}) session3.add(record) data4 = Load_Data_1("csv/1categories.csv") for i in data4: record = Categories(**{'id': i[0], 'category_name': i[1]}) session3.add(record) data5 = Load_Data_1("csv/1cuisine.csv") for i in data5: record = Cuisine(**{'id': i[0], 'cuisine_name': i[1]}) session3.add(record) data6 = Load_Data_1("csv/1menu.csv") for i in data6: record = Menu(**{'id': i[0], 'menu_name': i[1]}) session3.add(record) data7 = Load_Data_3("csv/1recipe_has_ingredients.csv") for i in data7: record = Recipe_has_ingredients(**{ 'recipe_id': i[0], 'ingredients_id': i[1] }) session3.add(record)