コード例 #1
0
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)
コード例 #2
0
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")
コード例 #3
0
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')
コード例 #4
0
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)
コード例 #5
0
def new_entry():
    countries = country_repository.select_all()
    destinations = destination_repository.select_all()

    return render_template('search.html',
                           title="Home",
                           countries=countries,
                           destinations=destinations)
コード例 #6
0
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)
コード例 #7
0
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)
コード例 #8
0
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)
コード例 #9
0
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)
コード例 #10
0
def countries_view():
    countries = country_repository.select_all()
    return render_template("countries/view.html", countries=countries, title="List of countries")
コード例 #11
0
def add_destination():
    countries = country_repository.select_all()
    print(countries)
    return render_template("destinations/new.html", countries=countries)
コード例 #12
0
def locations_new():
    countries = country_repository.select_all()
    return render_template("locations/add.html",
                           countries=countries,
                           title="Add a location")
コード例 #13
0
def list_countries():
    all_countries = country_repository.select_all()
    return render_template('/countries/index.html',
                           all_countries=all_countries)
コード例 #14
0
def bucketlist_home():
    bucketlist = bucketlist_repository.select_all()
    countries = country_repository.select_all()

    return render_template("/bucketlist/index.html", countries= countries, bucketlist=bucketlist)
コード例 #15
0
def countries():
    countries = country_repository.select_all()
    return render_template("countries/index.html", all_countries=countries)
コード例 #16
0
def cities():
    cities = city_repository.select_all()
    countries = country_repository.select_all()
    return render_template("cities/index.html",
                           cities=cities,
                           countries=countries)
コード例 #17
0
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)
コード例 #18
0
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)
コード例 #19
0
def new_city():
    cities = city_repository.select_all()
    countries = country_repository.select_all()
    return render_template("cities/new.html", cities = cities, countries = countries)
コード例 #20
0
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()
コード例 #21
0
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)
コード例 #22
0
def new_country():
    countries = country_repository.select_all()
    return render_template("countries/new.html", all_countries=countries)
コード例 #23
0
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)