def create_city(): name = request.form["name"] country_id = request.form["country_id"] visited = request.form["visited"] country = country_repository.select(country_id) new_city = City(name, country, visited) city_repository.save(new_city) return redirect("/cities")
def create_city(): city_name = request.form['city_name'] # visited = request.form['visited'] country_id = request.form['country_id'] country = country_repository.select(country_id) city = City(city_name, country) city_repository.save(city) return redirect('/countries')
def create_city(): new_city = request.form['name'] country_id = request.form['country_id'] visited = request.form['visited'] country = country_repository.select(country_id) city = City(new_city, country, visited) city_repository.save(city) return redirect('/list-destinations')
def create_city(): name = request.form["name"] city_type = request.form["city_type"] visited = request.form["visited"] country = country_repository.select(request.form["country_id"]) city = City(name, city_type, country, id, visited) city_repository.save(city) return redirect('/cities')
def create_city(): name = request.form['name'] country_id = request.form['country_id'] country = country_repository.select(country_id) visited = False comment = request.form['comment'] new_city = City(name, country, visited, comment) city_repository.save(new_city) return redirect(f"/countries/{country_id}")
def add_city_to_country(): city_name = request.form['city_name'] country_id = request.form['country'] country = country_repository.select(country_id) city = City(city_name, country) city_repository.save(city) return redirect('/countries')
def add_city(): name = request.form['name'] country_id = request.form["country"] visited = request.form["visited"] country = country_repository.select(country_id) city = City(name, country, visited) city_repository.save(city) return redirect("/cities")
def create_city(): #data from form city_name = request.form['city_name'] date_of_travel = request.form['date_of_travel'] visited = request.form['visited'] == 'true' #select the country using the repository country = country_repository.select(request.form['country_id']) #create a new cityc city = City(city_name, country, date_of_travel, visited) #save the city back to the database with the save method city_repository.save(city) if city.visited: return redirect("/cities") else: return redirect("/cities/future")
sight_repository.delete_all() city_repository.delete_all() country_repository.delete_all() visit_repository.delete_all() sight_1 = Sight("Beach") sight_repository.save(sight_1) sight_2 = Sight("Cathedral") sight_repository.save(sight_2) sight_3 = Sight("Art Gallery") sight_repository.save(sight_3) city_1 = Sight("Havana") city_repository.save(city_1) city_2 = City("Barcelona") city_repository.save(city_2) city_3 = City("Florence") city_repository.save(city_3) country_1 = Country("Cuba") country_repository.save(country_1) country_2 = Country("Spain") country_repository.save(country_2) country_3 = Country("Italy") country_repository.save(country_3)
country_repository.delete_all() city_repository.delete_all() attraction_repository.delete_all() france = Country("France", "Europe") country_repository.save(france) italy = Country("Italy", "Europe") country_repository.save(italy) america = Country("America", "North America") country_repository.save(america) peru = Country("Peru", "South America") country_repository.save(peru) paris = City("Paris", france) city_repository.save(paris) rome = City("Rome", italy) city_repository.save(rome) venice = City("Venice", italy) city_repository.save(venice) new_york_city = City("New York City", america) city_repository.save(new_york_city) lima = City("Lima", peru) city_repository.save(lima) eiffel_tower = Attraction("Eiffel Tower", 25.90, paris) attraction_repository.save(eiffel_tower) the_louvre = Attraction("The Louvre", 17, paris) attraction_repository.save(the_louvre) the_colosseum = Attraction("The colosseum", 12, rome) attraction_repository.save(the_colosseum)
import pdb from models.country import Country from models.city import City import repositories.city_repository as city_repository import repositories.country_repository as country_repository city_repository.delete_all() country_repository.delete_all() country1 = Country("China") country_repository.save(country1) country2 = Country("Japan") country_repository.save(country2) country3 = Country("Denmark") country_repository.save(country3) city1 = City("Beijing", country1, False) city_repository.save(city1) city2 = City("Tokyo", country2, True) city_repository.save(city2) city3 = City("Copenhagen", country3, True) city_repository.save(city3) city4 = City("Osaka", country2, True) city_repository.save(city4) pdb.set_trace()
def add_city(id): country = country_repository.select(id) city_name = request.form["cityname"] city = City(city_name, country) cities_repository.save(city) return redirect("/countries/"+id)
def create_city(): city = request.form["city"] new_city = City(city) city_repository.save(new_city) return redirect("/cities")
country_1 = Country("Scotland") country_2 = Country("Germany") country_3 = Country("Japan") country_4 = Country("Italy") country_repository.save(country_1) country_repository.save(country_2) country_repository.save(country_3) country_repository.save(country_4) city_1 = City("Glasgow", country_1) city_2 = City("Berlin", country_2) city_3 = City("Tokyo", country_3) city_4 = City("Edinburgh", country_1) city_5 = City("Pisa", country_4) city_6 = City("Munich", country_2) city_repository.save(city_1) city_repository.save(city_2) city_repository.save(city_3) city_repository.save(city_4) city_repository.save(city_5) city_repository.save(city_6) sight_1 = Sight("Kelvingrove Art Gallery", country_1, city_1) sight_2 = Sight("Brandenburg Gate", country_2, city_2) sight_3 = Sight("Tokyo Tower", country_3, city_3) sight_4 = Sight("Edinburgh Castle", country_1, city_4) sight_5 = Sight("Leaning Tower of Pisa", country_4, city_5) sight_6 = Sight("Reichstag Building", country_2, city_2) sight_7 = Sight("Berlin Wall Memorial", country_2, city_2) sight_repository.save(sight_1) sight_repository.save(sight_2)