def __init__(self, parent=None): super().__init__(parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.clicked = None if read_from_database(): self.cars = read_from_database() else: self.cars = [] if self.cars: self.cars_dict = cars_as_dict(self.cars) self.ui.pages.setCurrentIndex(0) self.ui.ShowCarList.clicked.connect(lambda: self._setup_car_list(self.cars, 1)) self.ui.overdueCars.clicked.connect(lambda: self._setup_car_list(self.cars, 'overdue')) self.ui.backButton.clicked.connect(lambda: self.go_back()) self.ui.backButton_2.clicked.connect(lambda: self. go_back()) self.ui.backButton_3.clicked.connect(lambda: self. go_back()) self.ui.modifyDatabase.clicked.connect(lambda: self._setup_car_list(self.cars, 'modify')) self.ui.searchButton.clicked.connect(lambda: self.search_cars(self.cars)) self.ui.typeDatabase.textEdited.connect(lambda: self.set_variables()) self.ui.reservedCars.clicked.connect(lambda: self._setup_car_list(self.cars, 'reserved')) self.ui.carList.itemClicked.connect(self.get_item) self.ui.reserve_button.setText("Reserve") self.ui.RemoveReservation.clicked.connect(lambda: self._remove_reservation_rent(self.clicked, 'reservation')) self.ui.RemoveRent.clicked.connect(lambda: self._remove_reservation_rent(self.clicked, 'rent')) self.ui.reserve_button.clicked.connect(lambda: self._reserve_rent(self.clicked, 'reservation')) self.ui.rent_button.clicked.connect(lambda: self._reserve_rent(self.clicked, 'rent')) self.ui.removeDatabase.clicked.connect(lambda: self.remove_from_database(self.clicked)) self.ui.addDatabase.clicked.connect(lambda: self.edit_add_to_database(self.clicked, "add")) self.ui.editDatabase.clicked.connect(lambda: self.edit_add_to_database(self.clicked, "edit")) self.ui.availableRent.clicked.connect(lambda: self._setup_car_list(self.cars, 'availableRent'))
def serve_json(): index = request.args.get('id') if request.args.get('reportdb'): db_name = request.args.get('reportdb') else: db_name = request.args.get('app') response = db.read_from_database(db_name, index) #response = open('static/data.json').read() return response
def serve_json(): index = request.args.get('id') if request.args.get('reportdb'): db_name = request.args.get('reportdb') else: db_name = request.args.get('app') response = db.read_from_database(db_name, index) #response = open('static/data.json').read() return response
def check_reservations(self): """ reloads items in the list to check if some of them expired, removes expired reservations """ cars = [] for car in self.cars: if car.reservation: if car.reservation.check_expiration() == "EXPIRED": car.reservation = None cars.append(car) self.cars_dict = write_to_database(cars) self.cars = read_from_database() return self.cars
def serve_json(id, reportdb=None, app=None): index = id db_name = reportdb or app response = db.read_from_database(db_name, index) # response = open('static/data.json').read() return json.loads(response)
def test_read_from_database(): items = read_from_database() assert len(items) >= 0