def search_results(): search_country = [] search_city = [] search_sight = [] search_key = request.form['search'] key = search_key.lower() countries = country_repository.select_all() cities = city_repository.select_all() sights = sight_repository.select_all() for country in countries: if country.name.lower() == key: search_country.append(country) for city in cities: if city.name.lower() == key: search_city.append(city) elif city.country.name.lower() == key: search_city.append(city) for sight in sights: if sight.name.lower() == key: search_sight.append(sight) elif sight.city.name.lower() == key: search_sight.append(sight) elif sight.city.country.name.lower() == key: search_sight.append(sight) return render_template("search.html", countries=countries, cities=cities, sights=sights, search_sight=search_sight, search_city=search_city, search_country=search_country)
def locations_edit(): location = location_repository.select(request.form['location_id']) countries = country_repository.select_all() return render_template("locations/edit.html", location=location, countries=countries, title="Edit/Delete location")
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 profile(): countries = country_repository.select_all() country_percentage = country_repository.country_percentage() countries_visited = country_repository.countries_visited() return render_template("profile.html", all_countries=countries, country_percentage=country_percentage, countries_visited=countries_visited)
def new_entry(): countries = country_repository.select_all() destinations = destination_repository.select_all() return render_template('search.html', title="Home", countries=countries, destinations=destinations)
def search(): continents = continent_repository.select_all() countries = country_repository.select_all() cities = city_repository.select_all() sights = sight_repository.select_all return render_template("search.html", continents=continents, countries=countries, cities=cities, sights=sights)
def new_trip(): cities = city_repository.select_all() countries = country_repository.select_all() sights = sight_repository.select_all() trips = visit_repository.select_all() return render_template("trips/new.html", cities=cities, countries=countries, sights=sights, trips=trips)
def bucketlist(): bucketlist_cities = [ city for city in city_repository.select_all() if city.visited is False ] countries = country_repository.select_all() bucketlist_countries = [] for country in countries: if country.visited is False: bucketlist_countries.append(country) # import pdb; pdb.set_trace() return render_template("/bucketlist.html", all_cities=bucketlist_cities, all_countries=bucketlist_countries)
def new_city(id): sel_country = country_repository.select(id) countries = country_repository.select_all() return render_template("cities/new.html", sel_country=sel_country, countries=countries)
def countries_view(): countries = country_repository.select_all() return render_template("countries/view.html", countries=countries, title="List of countries")
def add_destination(): countries = country_repository.select_all() print(countries) return render_template("destinations/new.html", countries=countries)
def locations_new(): countries = country_repository.select_all() return render_template("locations/add.html", countries=countries, title="Add a location")
def list_countries(): all_countries = country_repository.select_all() return render_template('/countries/index.html', all_countries=all_countries)
def bucketlist_home(): bucketlist = bucketlist_repository.select_all() countries = country_repository.select_all() return render_template("/bucketlist/index.html", countries= countries, bucketlist=bucketlist)
def countries(): countries = country_repository.select_all() return render_template("countries/index.html", all_countries=countries)
def cities(): cities = city_repository.select_all() countries = country_repository.select_all() return render_template("cities/index.html", cities=cities, countries=countries)
def destinations(): bucketlists = bucketlist_repository.select_all() countries = country_repository.select_all() destinations = destination_repository.select_all() return render_template("bucketlist/index.html", countries=countries, destinations=destinations, bucketlists=bucketlists)
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 new_city(): cities = city_repository.select_all() countries = country_repository.select_all() return render_template("cities/new.html", cities = cities, countries = countries)
import pdb from models.country import Country from models.destination import Destination import repositories.country_repository as country_repository import repositories.destination_repository as destination_repository country_repository.delete_all() destination_repository.delete_all() country_repository.select_all() destination_repository.select_all() country1 = Country('Brazil', '212 million', True) country_repository.save(country1) country2 = Country('Australia', '25 million', False) country_repository.save(country2) destination_1 = Destination('Foz do Iguacu', country1) destination_repository.save(destination_1) destination_2 = Destination('Sydney', country2) destination_repository.save(destination_2) pdb.set_trace()
def new_place(): countries =country_repository.select_all() place_types =place_type_repository.select_all() return render_template("places/new.html", countries=countries, place_types = place_types)
def new_country(): countries = country_repository.select_all() return render_template("countries/new.html", all_countries=countries)
def edit_place(id): countries =country_repository.select_all() place_types =place_type_repository.select_all() place = place_repository.select(id) return render_template('places/edit.html', place_types=place_types, countries=countries, place=place)