Exemple #1
0
def comment(id):
    sight = sight_repository.select(id)
    sight_id = sight.id
    name = sight.name
    city = sight.city
    visited = sight.visited
    comment = request.form['comment']
    commented_sight = Sight(name, city, visited, comment, id)
    sight_repository.update(commented_sight)
    return redirect(f"/sights/{sight_id}")
Exemple #2
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_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
Exemple #4
0
def visit(id):
    sight = sight_repository.select(id)
    sight_id = sight.id
    name = sight.name
    city = sight.city
    comment = sight.comment
    visited = True
    visit_sight = Sight(name, city, visited, comment, id)
    sight_repository.update(visit_sight)
    visit_sight.city.visited = True
    city_repository.update(visit_sight.city)
    visit_sight.city.country.visited = True
    country_repository.update(visit_sight.city.country)
    return redirect(f"/sights/{sight_id}")
def show_sight(id):
    sight = sight_repository.select(id)
    sight_cities = sight_repository.cities(sight)
    return render_template("sights/show.html",
                           sight=sight,
                           cities=sight_cities)
Exemple #6
0
def edit_sight(id):
    sight = sight_repository.select(id)
    return render_template("sights/edit.html", sight=sight)
Exemple #7
0
def show_sight(id):
    sight = sight_repository.select(id)
    return render_template("sights/show.html", sight=sight)
Exemple #8
0
def delete_sight(id):
    sight = sight_repository.select(id)
    city_id = sight.city.id
    sight_repository.delete(id)
    return redirect(f"/cities/{city_id}")