def add(restaurant, category_name): if isinstance(restaurant, str) or isinstance(restaurant, unicode): restaurant = ndb.Key(Restaurant, restaurant) check_get_restaurant(restaurant) category = Category(restaurant_key = restaurant, name = category_name) return category.put().get()
def get_all_by_restaurant_uid(restaurant_uid): restaurant_key = ndb.Key(Restaurant, restaurant_uid) check_get_restaurant(restaurant_key) return Dish.query(Dish.restaurant_key == restaurant_key).fetch()
def get_all_by_restaurant_key(restaurant_key): check_get_restaurant(restaurant_key) return Category.query(Category.restaurant_key == restaurant_key).fetch()
def delete(uid): restaurant_key = ndb.Key(Restaurant, uid) check_get_restaurant(restaurant_key) restaurant_key.delete()