def update_city(id): city = city_repository.select(id) country = country_repository.select_all() visited = request.form['visited'] city = City(city.city_name, country, visited, id) city_repository.update(city) return redirect('/countries')
def create_attraction(): name = request.form["name"] cost = request.form["cost"] city_id = request.form["city"] city = city_repository.select(city_id) attraction = Attraction(name, cost, city) attraction_repository.save(attraction) return redirect("/attractions")
def update_attraction(id): name = request.form["name"] cost = request.form["cost"] city_id = request.form["city_id"] city = city_repository.select(city_id) attraction = Attraction(name, cost, city, id) attraction_repository.update(attraction) return redirect(f"/attractions/{id}")
def create_sight(): name = request.form['name'] city_id = request.form['city_id'] city = city_repository.select(city_id) visited = False comment = request.form['comment'] new_sight = Sight(name, city, visited, comment) sight_repository.save(new_sight) return redirect(f"/cities/{city_id}")
def comment(id): city = city_repository.select(id) city_id = city.id name = city.name country = city.country visited = city.visited comment = request.form['comment'] commented_city = City(name, country, visited, comment, id) city_repository.update(commented_city) return redirect(f"/cities/{city_id}")
def select_attraction_by_city(id): attractions = [] sql = "SELECT * FROM attractions WHERE city_id = %s" values = [id] results = run_sql(sql, values) for row in results: city = city_repository.select(row['city_id']) attraction = Attraction(row['name'], row['cost'], city, row['id']) attractions.append(attraction) return attractions
def select(id): attraction = None sql = "SELECT * FROM attractions WHERE id = %s" values = [id] result = run_sql(sql, values)[0] if result is not None: city = city_repository.select(result['city_id']) attraction = Attraction(result['name'], result['cost'], city, result['id']) return attraction
def update_city(id): name = request.form['name'] city = city_repository.select(id) city_id = city.id country_id = city.country.id country = country_repository.select(country_id) visited = city.visited comment = city.comment updated_city = City(name, country, visited, comment, id) city_repository.update(updated_city) return redirect(f"/cities/{city_id}")
def select(id): sight = None sql = "SELECT * FROM sights WHERE id = %s" values = [id] result = run_sql(sql, values)[0] if result is not None: city = city_repository.select(result['city_id']) sight = Sight(result['name'], city, result['visited'], result['comment'], result['id']) return sight
def update_sight(id): name = request.form['name'] sight = sight_repository.select(id) sight_id = sight.id city_id = sight.city.id city = city_repository.select(city_id) visited = sight.visited comment = sight.comment updated_sight = Sight(name, city, visited, comment, id) sight_repository.update(updated_sight) return redirect(f"/sights/{sight_id}")
def select(id): bucketlist = None sql = "SELECT * FROM bucketlist WHERE id = %s" values = [id] result = run_sql(sql, values)[0] if result is not None: country = country_repository.select(result['country_id']) city = city_repository.select(result['city_id']) bucketlist = Bucketlist(country, city, result["visited"], result["id"]) return bucketlist
def select_all(): attractions = [] # I WANT TO ORDER THE ATTRACTIONS BY CITY sql = "SELECT * FROM attractions" # ORDER BY city.id" results = run_sql(sql) for row in results: city = city_repository.select(row['city_id']) attraction = Attraction(row['name'], row['cost'], city, row['id']) attractions.append(attraction) return attractions
def visit(id): city = city_repository.select(id) city_id = city.id name = city.name country = city.country comment = city.comment visited = True visit_city = City(name, country, visited, comment, id) city_repository.update(visit_city) visit_city.country.visited = True country_repository.update(visit_city.country) return redirect(f"/cities/{city_id}")
def select_all(): sights = [] sql = "SELECT * FROM sights" results = run_sql(sql) for row in results: city = city_repository.select(row['city_id']) sight = Sight(row['name'], city, row['visited'], row['comment'], row['id']) sights.append(sight) return sights
def select_all(): bucketlist_items = [] sql = "SELECT * FROM bucketlist" results = run_sql(sql) for row in results: country = country_repository.select(row['country_id']) city = city_repository.select(row['city_id']) bucketlist = Bucketlist(country, city, row['visited'], row['id']) bucketlist_items.append(bucketlist) return bucketlist_items
def select_all(): visits = [] sql = "SELECT * FROM visits" results = run_sql(sql) for row in results: city = city_repository.select(row['city_id']) country = country_repository.select(row['country_id']) sight = sight_repository.select(row["sight_id"]) visit = Visit(city, country, sight, row['to_visit'], row['id']) visits.append(visit) return visits
def sights(id): sights = [] sql = "SELECT * FROM sights WHERE city_id = %s ORDER by name ASC" values = [id] results = run_sql(sql, values) for row in results: city = city_repository.select(row['city_id']) sight = Sight(row['name'], city, row['visited'], row['comment'], row['id']) sights.append(sight) return sights
def add_item(): city_id = request.form["city_id"] visited = False city = city_repository.select(city_id) country_id = request.form["country_id"] country = country_repository.select(country_id) visited = request.form["visited"] bucketlist = Bucketlist(country, city, visited) bucketlist_repository.save(bucketlist) return redirect("/bucketlist")
def show_city(id, id2): city = cities_repository.select(id2) sights = cities_repository.sights(city) return render_template("/cities/show.html", city=city, sights=sights)
def mark_city(id, id2): city = cities_repository.select(id2) city.mark_visited() cities_repository.update(city) return redirect("/countries/"+id)
def edit_city(id): city = city_repository.select(id) countries = country_repository.select_all() return render_template('cities/edit.html', city = city, all_countries = countries)
def delete_city(id): city = city_repository.select(id) country_id = city.country.id city_repository.delete(id) return redirect(f"/countries/{country_id}")
def show_city(id): sights = sight_repository.sights(id) city = city_repository.select(id) return render_template("cities/show.html", sights=sights, city=city)
def show_city(id): city = city_repository.select(id) return render_template('countries/index.html', city = city)
def edit_city(id): city = city_repository.select(id) return render_template("cities/edit.html", city=city)
def show_city(id): city = city_repository.select(id) return render_template("/cities/show.html", city=city)
def show_city_sights(id): city = city_repository.select(id) city_sights = city_repository.sights(city) return render_template("cities/show.html", city=city, sights=city_sights)
def new_sight(id): sel_city = city_repository.select(id) cities = city_repository.select_all() return render_template("sights/new.html", sel_city=sel_city, cities=cities)
def show_city(id): city = city_repository.select(id) attractions = attraction_repository.select_attraction_by_city(id) return render_template("cities/show.html", city = city, attractions = attractions)