예제 #1
0
def show_restaurants():
    listWidget.clear()
    content = str(combo_box.currentText())
    session = get_session()

    restaurants = session.query(Restaurant).filter(
        Restaurant.kitchen_type.has(type=content)).all()
    for rest in restaurants:
        reserved_tables = session.query(ReservedTables).filter(
            ReservedTables.restaurant.has(name=rest.name)).one()

        nr_of_all_tables = rest.nr_of_tables
        nr_of_reserved_tables = reserved_tables.total_nr_of_reservations

        listWidget.addItem(
            f'Nazwa: {rest.name}\n' + f'Ocena: {str(rest.rate)}\n' +
            f'Ilość wolnych stolików: {str(nr_of_all_tables - nr_of_reserved_tables)}'
        )
예제 #2
0
def make_order():
    restaurant_name = get_order_restaurant_name()

    if restaurant_name in listWidget.item(listWidget.currentRow()).text():
        session = get_session()
        restaurant = session.query(Restaurant).filter(
            Restaurant.name == restaurant_name).one()
        modify_available_tables(restaurant, restaurant_name, session)

        lat_user, lng_user = get_user_location()
        location = save_user_location(lat_user, lng_user, session)
        save_order(location, restaurant, session)

        distance = calculate_distance(lat_user, lng_user, restaurant)

        QMessageBox.information(
            window, "Informacja o rezerwacji", f'Zarezerwowano\n'
            f'{listWidget.item(listWidget.currentRow()).text()}\n'
            f'Odległośc do restauracji: {str(round(distance, 2))} km')
예제 #3
0
def find_meals():
    get_user_location()

    sender = window.sender()
    content = str(combo_box.currentText())
    if sender.text() == "Show":
        if content == " ":
            combo_box_menu.clear()
            listWidget.clear()

        session = get_session()
        menu = session.query(Meal).filter(
            Meal.kitchen_type.has(type=content)).all()

        for meal in menu:
            combo_box_menu.addItem(meal.meal)

        ukladT.addWidget(label_menu, 6, 0)
        ukladT.addWidget(combo_box_menu, 7, 0)

        combo_box.activated.connect(clear_menu)
        combo_box_menu.activated.connect(show_restaurants)
from controllers.db_connection import get_session

from db_objects.objects import Location, Restaurant

session = get_session()
locations = session.query(Location).order_by(Location.id).all()
print(locations[0].id)

restaurants = session.query(Restaurant).order_by(Restaurant.id).all()
print(restaurants[0].name)

location = Location(latitude=1.0, longitude=2.0)
session.add(location)
session.commit()
print(location.id)