Exemplo n.º 1
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')
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}")
Exemplo n.º 4
0
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}")
Exemplo n.º 5
0
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
Exemplo n.º 8
0
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}")
Exemplo n.º 9
0
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
Exemplo n.º 10
0
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
Exemplo n.º 13
0
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}")
Exemplo n.º 14
0
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
Exemplo n.º 16
0
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
Exemplo n.º 17
0
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
Exemplo n.º 18
0
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")
Exemplo n.º 19
0
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)    
Exemplo n.º 20
0
def mark_city(id, id2):
    city = cities_repository.select(id2)
    city.mark_visited()
    cities_repository.update(city)
    return redirect("/countries/"+id)
Exemplo n.º 21
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)
Exemplo n.º 22
0
def delete_city(id):
    city = city_repository.select(id)
    country_id = city.country.id
    city_repository.delete(id)
    return redirect(f"/countries/{country_id}")
Exemplo n.º 23
0
def show_city(id):
    sights = sight_repository.sights(id)
    city = city_repository.select(id)
    return render_template("cities/show.html", sights=sights, city=city)
Exemplo n.º 24
0
def show_city(id):
    city = city_repository.select(id)
    return render_template('countries/index.html', city = city)
Exemplo n.º 25
0
def edit_city(id):
    city = city_repository.select(id)
    return render_template("cities/edit.html", city=city)
Exemplo n.º 26
0
def show_city(id):
    city = city_repository.select(id)
    return render_template("/cities/show.html", city=city)
Exemplo n.º 27
0
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)
Exemplo n.º 28
0
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)
Exemplo n.º 29
0
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)