def create_truck_finished(self): error = self.createTruckReply.error() if error == QtNetwork.QNetworkReply.NoError: truck = Truck.fromJSON(self.createTruckReply.readAll().data()) self.createTruckFinished.emit(truck) else: errors = self._parse_errors(self.createTruckReply.readAll().data()) self.createTruckFailed.emit(errors)
def createTruck(self): license_plate = self.ui.licensePlateLineEdit.text() carrierIndex = self.ui.carriersComboBox.currentIndex() if carrierIndex != -1: license_plate = self.ui.licensePlateLineEdit.text() carrier = self.ui.carriersComboBox.model().getCarrier(carrierIndex) self.truck = Truck(carrier.id, license_plate) self.accept()
def addTruck(self): if self.ui.newButton.isChecked(): errors = [] license_plate = self.ui.licensePlateLineEdit.text() carrier_id = self.carrier.id if self.carrier else None frequent = self.ui.saveAsFrequentBox.isChecked() truck = Truck(carrier_id, license_plate, frequent) self.api.create_truck(truck) else: errors = [] truckFilteredIndex = self.ui.trucksTableView.currentIndex() if truckFilteredIndex.row() == -1: errors.append("Debe seleccionar un camión") if not errors: self.new = False truckIndex = self.filterTrucksProxyModel.mapToSource( truckFilteredIndex) self.truck = self.trucksTableModel.getTruck(truckIndex.row()) self.accept() else: ErrorMessageBox(errors).exec_()
def get_trucks_finished(self): trucks = Truck.fromJSON(self.getTrucksReply.readAll().data()) self.getTrucksFinished.emit(trucks)