def getTVModelRII(self): data = self.getAllData() for i in range(len(data)): data2 = 0 idGroup = data[i]['idClientGroup'] if idGroup == 2: data2 = Client().getFromID(data[i]['idRii']) data2['nameClientGroup'] = 'Преподаватель' elif idGroup == 3: data2 = CathGroup().getFromID(id=data[i]['idRii']) if data2: data2['shortfio'] = data2['name'] data2['nameClientGroup'] = 'Студент' if data2: if 'id' in data2.keys(): del data2['id'] data[i] = {**data[i], **data2} else: data[i]['shortfio'] = "-" data[i]['nameClientGroup'] = 'Администратор' fieldsTable = ['id', 'idTelegram', 'shortfio', 'nameClientGroup'] fieldsView = [ 'id', 'idTelegram', 'ФИО/группа клиента', 'Группа клиентов' ] model = DBM.CreateTableViewModelFromData(data=data, fieldTab=fieldsTable, fieldsView=fieldsView) return model
def save(self): ind = self.kathCB.currentIndex() if ind == -1: ind = 0 idCath = self.cathData[ind]['id'] if self.ID: Client().updateTeacher(idClient=self.ID, fio=self.fioLE.text(), shortfio=self.leShort.text(), obrazovanie=self.obrazovanieLE.text(), stepen=self.stepenLE.text(), zvanie=self.zvanieLE.text(), kvalifikacia=self.kvalifikaciaLE.text(), dolzhnost=self.dolzhnostLE.text(), idCath=idCath) else: Client().insertTeacher(fio=self.fioLE.text(), shortfio=self.leShort.text(), obrazovanie=self.obrazovanieLE.text(), stepen=self.stepenLE.text(), zvanie=self.zvanieLE.text(), kvalifikacia=self.kvalifikaciaLE.text(), dolzhnost=self.dolzhnostLE.text(), idCath=idCath) if self.Parent: self.Parent.RefreshTable() self.close()
def initTeachers(self): self.setVisibleOtherCB(True) idCath = self._getCathID() self.labClient.setText('ФИО') self.teacherList = Client().getTeachersListFromIDCath(idCath=idCath) self.cbClient.clear() self.cbClient.addItems([row['shortfio'] for row in self.teacherList])
def reserveDevice(self, nameDevice, numAud, idClient): data = self.getList() device = 0 for row in data: if row['name'].upper() == nameDevice.upper(): device = row break if device: if device['numAud'] != '0': cl = Client().getFromID(id=device['idClient']) return { 'error': 1, 'text': 'Устройство уже занято: %s ауд. - %s' % (device['numAud'], cl['shortfio']) } else: self.updateRecord(id=device['id'], numAud=numAud, idClient=idClient) return { 'error': 0, 'text': "За вами зарезервировано " "устройство %s в аудитории %s " % (device['name'], numAud) } else: return {'error': 1, 'text': 'Неправильное имя устройства'}
def initTeacher(self): self.lab1.setText('ФИО преподавателя : ') self.TeacherData = Client().getFromID(self.idClient) self.labFio.setText(self.TeacherData['fio']) self.labCath.setText(self.TeacherData['nameCath']) self.giveTVModel()
def initTeachers(self, idCath=0): if not idCath: self.initCath() idCath=1 self.teachersList = Client().getTeachersListFromIDCath(idCath=idCath) self.cbOther.clear() self.cbOther.addItems([row['shortfio'] for row in self.teachersList])
def refreshTeachers(self): idC = self.cbCath.currentIndex() if idC == -1: idC = 0 self.teachList = Client().getTeachersListFromIDCath( idCath=self.cathList[idC]['id']) self.cbTeacherOrGroup.clear() self.cbTeacherOrGroup.addItems( [row['shortfio'] for row in self.teachList])
def initTeachers(self): self.selGroup = 2 self.lab3.setText('ФИО : ') self.cbGroup.clear() self.teachList = Client().getTeachersListFromIDCath( idCath=self.getSelectedIDCath()) self.cbGroup.addItems([row['shortfio'] for row in self.teachList])
def save(self): fio = self.leFio.text() short = self.leShort.text() ind = self.cbGroup.currentIndex() idInfo = self.groupList[ind]['id'] if self.ID: Client().updateStudent(idClient=self.ID, shortfio=self.leShort.text(), fio=fio, idInfo=idInfo) else: Client().insertStudent(fio=fio, shortfio=self.leShort.text(), idInfo=idInfo) if self.Parent: self.Parent.RefreshTable() self.close()
def initEdit(self): rec = Client().getFromID(self.ID) self.leFio.setText(rec['fio']) self.leShort.setText(rec['shortfio']) for i in range(len(self.groupList)): if rec['idInfo'] == self.groupList[i]['id']: ind = i self.cbGroup.setCurrentIndex(ind) self.setWindowTitle('Редактирование информации о студенте')
def loadTeacherData(self): data = Client().getFromID(self.ID) self.fioLE.setText(data['fio']) self.leShort.setText(data['shortfio']) self.dolzhnostLE.setText(data['dolzhnost']) self.obrazovanieLE.setText(data['obrazovanie']) self.stepenLE.setText(data['stepen']) self.zvanieLE.setText(data['zvanie']) self.kvalifikaciaLE.setText(data['kvalifikacia']) for i in range(len(self.cathData)): if data['idCath'] == self.cathData[i]['id']: self.kathCB.setCurrentIndex(i) self.setWindowTitle('Редактирование преподавателя')
def DeleteRecord(self): id = self.GetSelectedRecordID() if id: table = self.GetTableName() if (table == 'Преподаватели'): Client().deleteTeacher(id) elif table == "Аудитории": Auditory().deleteRecord(id) elif table == "Клиенты Telegram": ClientsTab().deleteClient(idTelegram=id) self.RefreshTable()
def initEdit(self): rec = Cathedra().getRecord(self.ID) self.leName.setText(rec['name']) self.teacherList = Client().getTeachersListFromIDCath(rec['id']) self.cbZav.clear() self.cbZav.addItems([rec['shortfio'] for rec in self.teacherList]) ind = -1 for i in range(len(self.teacherList)): if rec['idZav'] == self.teacherList[i]['id']: ind = i break if ind != -1: self.cbZav.setCurrentIndex(ind)
def GetTableModel(self, table): if table == 'Студенты': self.setVisibleCB(True) if self.selectedTable != self.AdisTable['Group']: self.cbGroupInit() idGroup = self.getAdditionalParIndex() model = Client().getTVStudentsModel(idGroup) elif table == 'Преподаватели': self.setVisibleCB(True) if self.selectedTable != self.AdisTable['Cathedra']: self.cbCathedraInit() idCathedra = self.getAdditionalParIndex() model = Client().getTVTeachersModel(idCathedra) elif table == 'Кафедры': self.setVisibleCB(False) model = Cathedra().getTVCathedraModel(zav=False) elif table == 'Группы студентов': self.setVisibleCB(True) if self.selectedTable != self.AdisTable['Cathedra']: self.cbCathedraInit() idCathedra = self.getAdditionalParIndex() model = CathGroup().getTVCathGroup(idCathedra) elif table == 'Аудитории': self.setVisibleCB(False) model = Auditory().getTVModel() elif table == 'Клиенты Telegram': self.setVisibleCB(False) model = ClientsTab().getTVModelRII() elif table == "Проекторы": model = Projectors().getTVModel() self.tableView.setModel(model) self.tableView.resizeRowsToContents() self.tableView.resizeColumnsToContents() self.tableView.horizontalHeader().setStyleSheet( "::section{Background-color:rgb(100,200,100);border-radius:14px;}")
def getListInfo(self): data = self.getList() for row in data: if row['numAud'] == "0": row['numAud'] = "На кафедре" if row['idClient']: client = Client().getFromID(row['idClient']) if client: row['fioClient'] = client['shortfio'] else: row['fioClient'] = "-" else: row['fioClient'] = "-" return data
def getRecordFromIDTelegram(self, idTelegram): sql = "SELECT id, idRii, idTelegram, idClientGroup " \ "FROM botdb.clientstab " \ "WHERE idTelegram = '%s';" % idTelegram data = DBM.GetData(sql=sql, nameDB='botdb') #data = data[0] if len(data) == 0 or "Error" in data[0].keys(): return 0 else: data = data[0] idClient = data['idRii'] idGroup = data['idClientGroup'] data2 = 0 if idGroup == 2: data2 = Client().getFromID(id=idClient) elif idGroup == 3: data2 = CathGroup().getFromID(id=idClient) if data2: return {**data, **data2} else: return data
def refreshTeachers(self): cbi = self.cbCath.currentIndex() idCath = self.cathList[cbi]['id'] self.teachersList = Client().getTeachersListFromIDCath(idCath=idCath) self.cbTeacher.clear() self.cbTeacher.addItems([rec['shortfio'] for rec in self.teachersList])
def _getFromRIIDB(self, idRii): record = Client().getFromID(id=idRii) return record