Esempio n. 1
0
 def update_on_server_handler(self):
     user = self.update_username.text()
     password = self.update_pass.text()
     r = api.udpate_user2(self.curr_username, self.curr_pass, user, password)
     
     if api.check_status('PUT', r):
         QMessageBox.about(self.update_form, 'Update', 'User updated successfuly.')
         self.setEnabled(True)
         self.fill_table()
         self.update_form.destroy()
Esempio n. 2
0
    def register_handler(self):
        username = self.username.text()
        password = self.password.text()

        r = api.add_user(username, password)
        print(r, r.content)

        if api.check_status('POST', r):
            print('registerd successfuly.')
            QMessageBox.about(self, 'Add User', 'User added successfuly.')
        else:   # some problem occured in user adding
            self.error_message.setText(str(r))
Esempio n. 3
0
    def fill_table(self):
        row = 0

        r = api.get_users()
        if api.check_status('GET', r):
            users = r.json()
            self.table_widget.setRowCount(len(users))
            for user in users:
                self.table_widget.setItem(row, 0, QTableWidgetItem(f'{user.get("username")}'))
                self.table_widget.setItem(row, 1, QTableWidgetItem(f'{user.get("password")}'))
                row += 1
        else:
            self.error_message.setText(f'{r.status_code} Error')
            self.layout.addWidget(self.error_message)
Esempio n. 4
0
 def add_user(self):
     username = self.new_user_ui.username.text()
     password = self.new_user_ui.password.text()
     pass_conf = self.new_user_ui.password_confirm.text()
     if password == pass_conf:
         r = api.add_user(username, password)
         if api.check_status('POST', r):
             self.error_message.setStyleSheet('color: #00ff00')
             self.error_message.setText(f'{r.status_code} User Successfuly Added.')
             self.new_user_ui.username.setText('')
             self.new_user_ui.password.setText('')
             self.new_user_ui.password_confirm.setText('')
         else:
             self.error_message.setText(str(r))
     else:
         self.error_message.setText('Wrong password!')
Esempio n. 5
0
 def load_users(self, table_widget):
     header = table_widget.horizontalHeader()       
     header.setSectionResizeMode(1, QHeaderView.ResizeToContents)
     row = 0
     r = api.get_users()
     if api.check_status('GET', r):
         users = r.json()
         table_widget.setRowCount(len(users))
         
         for user in users:
             btn = QPushButton('Edit')
             table_widget.setItem(row, 0, QTableWidgetItem(f'{user.get("username")}'))
             table_widget.setItem(row, 1, QTableWidgetItem(f'{user.get("password")}'))
             table_widget.setCellWidget(row, 2, btn)
             row += 1
     else:
         # self.error_message.setText(f'{r.status_code} Error')
         # self.layout.addWidget(self.error_message)
         print(r.status_code)
Esempio n. 6
0
 def status(self):
   return api.check_status(self.id)
Esempio n. 7
0
 def status(self):
     return api.check_status(self.id, db_name=self.db_name)
Esempio n. 8
0
 def status(self):
   return api.check_status(self.id)
Esempio n. 9
0
 def status(self):
   return api.check_status(self.id, db_name=self.db_name)