コード例 #1
0
def select_all():
    bucketlists = []

    sql = "SELECT * FROM bucketlists"
    results = run_sql(sql)

    for row in results:
        destination_id = destination_repository.select(row["destination_id"])
        bucketlist = Bucketlist(destination_id, row["id"])
        bucketlists.append(bucketlist)
    return bucketlists
コード例 #2
0
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
コード例 #3
0
def select(id):
    bucketlist = None
    sql = "SELECT * FROM bucketlists WHERE id = %s"
    values = [id]
    result = run_sql(sql, values)[0]

    if result is not None:
        destination_id = destination_repository.select(
            result['destination_id'])
        bucketlist_id = result["id"]
        bucketlist = Bucketlist(destination_id, bucketlist_id)
    return bucketlist
コード例 #4
0
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
コード例 #5
0
def create_destination():
    destination_id = request.form['destination']
    destination_object = destination_repository.select(destination_id)
    destination_name = destination_object.name
    country_id = request.form['country']
    country = country_repository.select(country_id)
    visited = request.form['visited']

    destination1 = Destination(destination_name, country, visited)
    destination_repository.save(destination1)
    new_destination = Bucketlist(destination1)

    bucketlist_repository.save(new_destination)

    return redirect("/bucketlist")
コード例 #6
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")
コード例 #7
0
country1 = Country("Germany", "Europe")
country_repository.save(country1)

country2 = Country("South Korea", "Asia")
country_repository.save(country2)

country3 = Country("New Zealand", "Oceania")
country_repository.save(country3)

# country_repository.delete(1)
# country_repository.select_all()
# country_repository.select(1)

# country_repository.update(country1)
city1 = City("Busan", country2)
city_repository.save(city1)

city2 = City("Cologne", country1)
city_repository.save(city2)

city3 = City("Christchurch", country3)
city_repository.save(city3)

# city_repository.update(city1)

# city_repository.delete(0)
# city_repository.select_all()
bucketlist1 = Bucketlist(country2, city1, False)
bucketlist_repository.save(bucketlist1)
pdb.set_trace()
コード例 #8
0
# Germany
destination7 = Destination("Berlin", country5)
destination_repository.save(destination7)
destination8 = Destination("Hamburg", country5)
destination_repository.save(destination8)
destination12 = Destination("Leipzig", country5)
destination_repository.save(destination12)

# New Zealand
destination9 = Destination("Christchurch", country6)
destination_repository.save(destination9)
destination14 = Destination("Auckland", country6)
destination_repository.save(destination14)
destination15 = Destination("Hamilton", country6)
destination_repository.save(destination15)

# testing update city
# destination10 = Destination("Mexico Ctiy", country6)
# destination_repository.save(destination10)
# print(destination_repository.select(destination10.id))
# destination10.name = "Mexico City"
# destination_repository.update(destination10)

bucketlist1 = Bucketlist(destination2)
bucketlist_repository.save(bucketlist1)

bucketlist2 = Bucketlist(destination7)
bucketlist_repository.save(bucketlist2)

pdb.set_trace()