def del_hostel(self): db = dbd.init_firebase() dorm_number = self.Number_line.text() choosen_num = self.Hostel_list.currentRow() c = 0 if choosen_num == 0: dorm_mas = db.child("dormitories").order_by_key().equal_to( "dormitory" + str(dorm_number)).get().each() room = dbd.list_of_room_num(dorm_number) for rooms in room: if 'members' in dorm_mas[0].val()['rooms'][str(rooms)]: c = 1 break if c == 1: from error_del_hostel import Ui_Error self.window = QtWidgets.QMainWindow() self.ui = Ui_Error() self.ui.setupUi(self.window) self.window.show() self.Number_line.clear() self.Hostel_list.clear() else: db.child("dormitories").child("dormitory" + str(dorm_number)).remove() self.Number_line.clear() self.Hostel_list.clear()
def fill_data(self): db = dbd.init_firebase() data_fac = db.child("facilities").child("buffer").get() for data in data_fac.each(): self.discount_line.setText(str(data.val())) self.Name_line.setText(data.key())
def add_to_buffer(self): db = dbd.init_firebase() fac_mas = dbd.list_of_facilities() item = self.NameBox.currentIndex() name = fac_mas[0][item][0] cost = fac_mas[0][item][1] db.child("facilities").child("buffer").set({name: cost})
def edit_hostel(self): db = dbd.init_firebase() dorm_number = self.Number_line.text() choosen_num = self.Hostel_list.currentRow() if choosen_num == 0: dorm_mas = db.child("dormitories").order_by_key().equal_to( "dormitory" + str(dorm_number)).get().each() if dorm_mas != []: dorm = dorm_mas[0].val() buffer_mas = {"number": dorm["number"], "Адрес": dorm["Адрес"]} db.child("dormitories").child("buffer1").set(buffer_mas)
def edit(self): number = self.Number_line.text() new_address = self.Addres_line.text() db = dbd.init_firebase() db.child("dormitories").child("dormitory" + str(number)).update( {"Адрес": new_address}) from success_action import Ui_Error self.window = QtWidgets.QMainWindow() self.ui = Ui_Error() self.ui.setupUi(self.window) self.window.show()
def fill_list(self): self.Hostel_list.clear() dorm_number = self.Number_line.text() db = dbd.init_firebase() dorm_mas = db.child("dormitories").order_by_key().equal_to( "dormitory" + str(dorm_number)).get().each() if dorm_mas == []: self.Number_line.clear() else: dorm = dorm_mas[0].val() self.Hostel_list.addItem( f"Название: {dorm['name']}\nАдрес: {dorm['Адрес']}")
def red(self): db = dbd.init_firebase() room = db.child("dormitories").child("buffer_room").get() room_number = room.val()["number"] dorm_number = room.val()["dorm"] status = self.RoomTipeBox.currentText() capacity = int(self.RoomPlacesBox.currentText()) db.child("dormitories").child("dormitory"+str(dorm_number)).child("rooms").child(room_number).update({"capacity":capacity,"status":status}) from success_action import Ui_Error self.window = QtWidgets.QMainWindow() self.ui = Ui_Error() self.ui.setupUi(self.window) self.window.show()
def fill_data(self): db = dbd.init_firebase() room = db.child("dormitories").child("buffer_room").get() room_number = room.val()["number"] dorm_number = room.val()["dorm"] status = room.val()["status"] capacity = room.val()["capacity"] occupied = room.val()["occupied"] for i in range(int(occupied),4): self.RoomPlacesBox.addItem(f"{i}") self.room_number_line.setText(str(room_number)) self.RoomTipeBox.setCurrentText(status) self.RoomPlacesBox.setCurrentText(str(capacity))
def get_and_update(self): cost = self.discount_line.text() name = self.Name_line.text() dbd.edit_facility(name, cost) #Получаем старое имя db = dbd.init_firebase() data_fac = db.child("facilities").child("buffer").get() for data in data_fac.each(): old_name = data.key() dbd.update_facility_data(old_name, name, cost) from success_action import Ui_Error self.window = QtWidgets.QMainWindow() self.ui = Ui_Error() self.ui.setupUi(self.window) self.window.show()
def red_room(self): db = dbd.init_firebase() room_number = self.RoomNumber.currentText() dorm_number = self.HostelNumber.currentText() if self.Room_list.currentRow() != -1: room_data = dbd.search_room(dorm_number, room_number) room_mas = { "dorm": dorm_number, "number": int(room_number), "capacity": room_data["capacity"], "status": room_data["status"], "occupied": room_data["occupied"] } db.child("dormitories").child("buffer_room").set(room_mas) from red_room_2 import Ui_red_room_2 self.window = QtWidgets.QMainWindow() self.ui = Ui_red_room_2() self.ui.setupUi(self.window) self.window.show()
def del_buffer(self): db = dbd.init_firebase() db.child("dormitories").child("buffer_room").remove()
def del_buffer(self): db = dbd.init_firebase() db.child("facilities").child("buffer").remove()
def fill_line(self): db = dbd.init_firebase() buffer = db.child("dormitories").child("buffer1").get().val() self.Number_line.setText(str(buffer["number"])) self.Addres_line.setText(buffer["Адрес"])