def loginOnClicked(self): username = self.username.text() password = self.password.text() self.username.clear() self.password.clear() self.username.setFocus() if username == '': notification.showNotif('Username tidak boleh kosong') return if password == '': notification.showNotif('Password tidak boleh kosong') return loginResult = self.PedatrenApi.login(username, password) if loginResult != True: textBody = json.loads(loginResult.text) notification.showNotif(textBody['message']) else: checkAksesPerizinan = self.PedatrenApi.getListPerizinan() if checkAksesPerizinan.status_code < 200 or checkAksesPerizinan.status_code >= 300: textBody = json.loads(checkAksesPerizinan.text) notification.showNotif(textBody['message']) else: self.switch_window.emit() self.close()
def __konfirmasiPenjagaPosOnclicked(self): if self.__itemIzin['id_status_perizinan'] == 3: response = self.PedatrenApi.setStatusKeluarDariPondok( self.__itemIzin['id_perizinan']) elif self.__itemIzin['id_status_perizinan'] == 4 or self.__itemIzin[ 'id_status_perizinan'] == 5: response = self.PedatrenApi.setStatusKembaliKePondok( self.__itemIzin['id_perizinan']) else: notification.showNotif( 'Status perizinan tidak valid. \nYang bisa input disini yg berstatus, perizinan sudah diacc atau yang kembali ke pondok' ) return if self.__responseApiHandler(response): self.refreshOnClicked() self.__childDialog.close()
def inputQrCodeOnPressed(self): textqrcode = self.input_qr_code.text().strip() self.input_qr_code.clear() if not textqrcode or textqrcode == '': notification.showNotif('Input QR Code tidak boleh kosong', True) return try: decoded64 = base64.b64decode(textqrcode) resJson = json.loads(decoded64) id_perizinan = resJson['id_perizinan_santri'] except: notification.showNotif( 'Input QR Code bukan jenis QR Code Perizinan atau bukan dari Pedatren', True) return if self.menu_AutoConfirm.isChecked() == True: self.__isAutoConfirmOK = self.__autoConfim(id_perizinan) if self.__isAutoConfirmOK == False: return self.showIdPerizinan(id_perizinan)
def __autoConfim(self, id_perizinan): response = self.PedatrenApi.getItemPerizinan(id_perizinan) if self.__responseApiHandler(response, True): itemPerizinan = json.loads(response.text) if itemPerizinan['id_status_perizinan'] == 3: resKeluar = self.PedatrenApi.setStatusKeluarDariPondok( id_perizinan) self.__responseApiHandler(resKeluar, True) elif itemPerizinan['id_status_perizinan'] == 4 or itemPerizinan[ 'id_status_perizinan'] == 5: resKembali = self.PedatrenApi.setStatusKembaliKePondok( id_perizinan) self.__responseApiHandler(resKembali, True) else: notification.showNotif( 'Status perizinan tidak valid. \nYang bisa diproses adalah perizinan yg berstatus sudah disetujui (di-acc) atau yang kembali ke pondok', True) return False self.refreshOnClicked() return True
def __responseApiHandler(self, response, autoCloseNotif=False): if response is None: notification.showNotif( 'Ops, error tidak diketahui, response API is None') self.close() sys.exit(1) return False elif 'exception' in response: notification.showNotif(response['exception'], autoCloseNotif) return False elif response.status_code == 401: self.close() self.switch_window.emit() return False elif response.status_code < 200 or response.status_code >= 300: errMsg = response.json() notification.showNotif(errMsg['message'], autoCloseNotif) return False return True
def showUserProfile(self): if not self.__userProfile: notification.showNotif( 'Kegagalan system mendapatkan info user Anda. Silahkan coba login ulang lagi.' ) return self.__userProfileDialog = fprofileuser.Ui_ProfileUser(self) self.__userProfileDialog.tabWidget.setCurrentIndex(0) # Biodata fotodiri = self.PedatrenApi.getImage( self.__userProfile['fotodiri']['medium']) if fotodiri.status_code >= 200 and fotodiri.status_code < 300: qimg = QtGui.QImage.fromData(fotodiri.content) pixmap = QtGui.QPixmap.fromImage(qimg) self.__userProfileDialog.label_fotodiri.setPixmap( pixmap.scaled(190, 190, QtCore.Qt.KeepAspectRatio)) self.__userProfileDialog.label_nokk.setText(self.__userProfile['nokk']) self.__userProfileDialog.label_nik.setText(self.__userProfile['nik']) self.__userProfileDialog.label_niup.setText( self.__userProfile['warga_pesantren']['niup']) self.__userProfileDialog.label_nama_lengkap.setText( self.__userProfile['nama_lengkap']) self.__userProfileDialog.label_gender.setText( 'Laki-laki' if self.__userProfile['jenis_kelamin'] == 'L' else 'Perempuan') self.__userProfileDialog.label_ttl.setText( self.__userProfile['tempat_lahir'] + ', ' + self.__userProfile['tanggal_lahir']) self.__userProfileDialog.label_umur.setText( str(self.__userProfile['umur']) + ' Tahun') self.__userProfileDialog.label_anak_ke.setText( str(self.__userProfile['anak_ke']) + ' <strong>dari</strong> ' + str(self.__userProfile['jum_saudara']) + ' bersaudara') self.__userProfileDialog.label_kecamatan.setText( self.__userProfile['kecamatan']) self.__userProfileDialog.label_kabupaten.setText( self.__userProfile['kabupaten']) self.__userProfileDialog.label_provinsi.setText( self.__userProfile['provinsi']) self.__userProfileDialog.label_negara.setText( self.__userProfile['negara']) # Status Santri if 'santri' not in self.__userProfile: self.__userProfileDialog.tabWidget.removeTab(2) else: last_index_santri = len(self.__userProfile['santri']) - 1 self.__userProfileDialog.label_nis.setText( self.__userProfile['santri'][last_index_santri]['nis']) nis_sampai = ' <strong>sampai</strong> ' + self.__userProfile[ 'santri'][last_index_santri][ 'tanggal_akhir'] if self.__userProfile['santri'][ last_index_santri]['tanggal_akhir'] else '' self.__userProfileDialog.label_santri_sejak.setText( self.__userProfile['santri'][last_index_santri] ['tanggal_mulai'] + nis_sampai) if 'domisili_santri' in self.__userProfile: headers = [ 'Kamar', 'Wilayah', 'Tanggal Ditempati', 'Tanggal Pindah' ] self.__userProfileDialog.tableDomisiliSantri.setColumnCount( len(headers)) self.__userProfileDialog.tableDomisiliSantri.setHorizontalHeaderLabels( headers) font = QtGui.QFont() font.setBold(True) self.__userProfileDialog.tableDomisiliSantri.horizontalHeader( ).setFont(font) self.__userProfileDialog.tableDomisiliSantri.horizontalHeader( ).setSectionResizeMode(0, QtWidgets.QHeaderView.ResizeToContents) self.__userProfileDialog.tableDomisiliSantri.horizontalHeader( ).setSectionResizeMode(1, QtWidgets.QHeaderView.Stretch) self.__userProfileDialog.tableDomisiliSantri.horizontalHeader( ).setSectionResizeMode(2, QtWidgets.QHeaderView.ResizeToContents) self.__userProfileDialog.tableDomisiliSantri.horizontalHeader( ).setSectionResizeMode(3, QtWidgets.QHeaderView.ResizeToContents) self.__userProfileDialog.tableDomisiliSantri.setRowCount( len(self.__userProfile['domisili_santri'])) no = 0 for row in self.__userProfile['domisili_santri']: self.__userProfileDialog.tableDomisiliSantri.setItem( no, 0, QtWidgets.QTableWidgetItem(row['kamar'])) self.__userProfileDialog.tableDomisiliSantri.setItem( no, 1, QtWidgets.QTableWidgetItem(row['wilayah'])) self.__userProfileDialog.tableDomisiliSantri.setItem( no, 2, QtWidgets.QTableWidgetItem(row['tanggal_mulai'])) self.__userProfileDialog.tableDomisiliSantri.setItem( no, 3, QtWidgets.QTableWidgetItem(row['tanggal_akhir'])) no += 1 # Keluarga if 'keluarga' not in self.__userProfile: self.__userProfileDialog.tabWidget.removeTab(1) else: headers = [ 'NIK', 'Nama Lengkap', 'Status Keluarga', 'Sebagai Wali' ] self.__userProfileDialog.tableKeluarga.setColumnCount(len(headers)) self.__userProfileDialog.tableKeluarga.setHorizontalHeaderLabels( headers) font = QtGui.QFont() font.setBold(True) self.__userProfileDialog.tableKeluarga.horizontalHeader().setFont( font) self.__userProfileDialog.tableKeluarga.horizontalHeader( ).setSectionResizeMode(0, QtWidgets.QHeaderView.ResizeToContents) self.__userProfileDialog.tableKeluarga.horizontalHeader( ).setSectionResizeMode(1, QtWidgets.QHeaderView.Stretch) self.__userProfileDialog.tableKeluarga.horizontalHeader( ).setSectionResizeMode(2, QtWidgets.QHeaderView.ResizeToContents) self.__userProfileDialog.tableKeluarga.horizontalHeader( ).setSectionResizeMode(3, QtWidgets.QHeaderView.ResizeToContents) self.__userProfileDialog.tableKeluarga.setRowCount( len(self.__userProfile['keluarga'])) no = 0 for row in self.__userProfile['keluarga']: self.__userProfileDialog.tableKeluarga.setItem( no, 0, QtWidgets.QTableWidgetItem(row['nik'])) self.__userProfileDialog.tableKeluarga.setItem( no, 1, QtWidgets.QTableWidgetItem(row['nama_lengkap'])) self.__userProfileDialog.tableKeluarga.setItem( no, 2, QtWidgets.QTableWidgetItem(row['status_relasi'])) sbgWali = QtWidgets.QTableWidgetItem(row['sebagai_wali']) sbgWali.setTextAlignment(QtCore.Qt.AlignVCenter | QtCore.Qt.AlignHCenter) self.__userProfileDialog.tableKeluarga.setItem(no, 3, sbgWali) no += 1 self.__userProfileDialog.exec_()