def add(id_op): """Given an operator, this method allows him to add a restaurant Args: id_op (int): univocal identifier for the customer Returns: Redirects the view to the operator's page """ form = RestaurantForm() if request.method == 'POST': if form.validate_on_submit(): print("ADD POST OKAY 60-77") name = form.data['name'] address = form.data['address'] city = form.data['city'] phone = form.data['phone'] menu_type = form.data['menu_type'] location = geolocator.geocode(address + " " + city) lat = 0 lon = 0 if location is not None: lat = location.latitude lon = location.longitude restaurant = Restaurant(name, address, city, lat, lon, phone, menu_type) restaurant.owner_id = id_op RestaurantManager.create_restaurant(restaurant) return redirect(url_for('auth.operator', id=id_op)) return render_template('create_restaurant.html', form=form)
def test_create_delete(self): restaurant, _ = TestRestaurant.generate_random_restaurant() customer, _ = TestCustomer.generate_random_customer() from gooutsafe.dao.customer_manager import CustomerManager from gooutsafe.dao.restaurant_manager import RestaurantManager # Adding restaurant RestaurantManager.create_restaurant(restaurant=restaurant) # Adding user CustomerManager.create_customer(customer=customer) self.like_manager.LikeManager.create_like(customer.id, restaurant.id) self.like_manager.LikeManager.delete_like(customer.id, restaurant.id) self.assertEqual( False, self.like_manager.LikeManager.like_exists( restaurant_id=restaurant.id, user_id=customer.id))