def offset_rating(rating,num =5): user = Food.name_authenticate(rating) rest = Food.all_restaurants_offset_two(user.City,rating,int(num) +5) if rest: return jsonify ({"restaurant": rest}) return jsonify({"No restaurant here,":rest})
def setUp(self): """ Will be called before every test """ # Create table db.create_all() # Create test log_date sample_log_date = Log_date(entry_date='2020-02-04') # Create test Food sample_food = Food(name="Pizza", protein=10, carb=15, fat=10, calories=190) # Create test food_date sample_food_date = Food_date(food_id=1, log_date_id=1) # save users to database db.session.add(sample_log_date) db.session.add(sample_food) db.session.commit() db.session.add(sample_food_date) db.session.commit()
def filter_price_four(city,price_range, num = 5): user = Food.price_authenticate(city) rest = user.price_filter_four(user.City,price_range, int(num) + 5) print(rest) if rest: return jsonify ({"restaurant": rest}) return jsonify({"No restaurant here,":rest})
def food(): food = Food( id=1, name="egg", serving_size="piece", kcal_per_serving=78, protein_grams=6.3, fibre_grams=1, ) return food
def addReview(api_key,name,city): example = User.api_authenticate(api_key) example_two = Food.food_authenticate(name,city) if example: data=request.get_json() new_review =Review(0,name,data['Rating'],example.email,city,example.First_name,example.Last_name,example.image_path) new_review.save() if new_review: return jsonify({"token":example.Api_key}) return jsonify({"token":""})
def suggest(city,rating,price_range): user = Food.price_authenticate(city) restaurants = Food.vacation_five(user.City,rating,price_range) if restaurants: return jsonify ({"restaurant": restaurants}) return jsonify({"No restaurant here,":restaurants})
def filter_price_italian(city,cuisine, num =5): user = Food.price_authenticate(city) rests = user.price_filter_asian(user.City,cuisine, int(num) + 5) if rests: return jsonify ({"restaurant": rests}) return jsonify({"No restaurant here,":"No Asian Restaurants in this city"})
def filter_price_vegeterian(city,cuisine,num=5): user = Food.price_authenticate(city) rests = user.price_filter_veg(user.City,cuisine,int(num) + 5) if rests: return jsonify ({"restaurant": rests}) return jsonify({"No restaurant here,":rests})
def price_one_offset(city,price_range,num = 5): user = Food.price_authenticate(city) food = user.price_one_offset(user.City, price_range, int(num) +5) if food: return jsonify ({"restaurant": food}) return jsonify({"No restaurant here,":food})
def offset(city,num=5): restaurants = Food.all_restaurants_offset(city,int(num) + 5) if restaurants: return jsonify ({"restaurant": restaurants}) # return jsonify({"pk":results[0],"name":results[1], "city":results[2], "cuisine_style":results[3],"ranking":results[4],"rating":results[5],"price_range":results[6],"number_of_reviews":results[7],"reviews":results[8]}) return jsonify({"No restaurant here,":city})
def lookup_ranking(city): restaurants = Food.all_restaurants_city(city) if restaurants: return jsonify ({"restaurants": restaurants}) return jsonify({"No restaurant here,":"city"})
def lookup_rating(rating): user = Food.name_authenticate(rating) restaurants = Food.rating_city(user.City,rating) if restaurants: return jsonify ({"rest":restaurants}) return jsonify({"No restaurant here,":restaurants})
from app import db, Category, Food, Basket db.drop_all() db.create_all() categories = [] categories.append(Category(name='Зелень')) categories.append(Category(name='Овощи')) categories.append(Category(name='Фрукты')) foods = [] foods.append( Food( name='Зелёный лук', cost=250, category_id=1, img_url= 'http://test.degreen.kz/media/filer_public/9a/11/9a11f0b2-0c4e-463f-80f0-4d1f26c77c30/zelenyi_luk.jpg', description= 'В составе зелёного лука имеются витамины С, Е, К, необходимые для усиления иммунитета, ускорения роста волос и улучшения состояния кожных покровов, а также некоторые минеральные вещества, среди которых: кальций, магний, цинк, железо, сера, фтор, фосфор.' )) foods.append( Food( name='Петрушка', cost=170, category_id=1, img_url= 'http://test.degreen.kz/media/filer_public/c0/a1/c0a115ca-df4f-4809-894a-f91ef029c229/petrushka.jpg', description= 'Петрушка обладает пряным запахом и сладковатым, терпким вкусом. В ней содержится эфирное масло, аскорбиновая кислота, каротин, тиамин, минеральные соли железа, фосфора, калия, кальция, магния, белки, пектиновые вещества и многое другое.' )) foods.append(