Exemple #1
0
    def add_user(self):
        dic = dict()
        dic["name"] = self.name_edit.text()
        dic["surname"] = self.surname_edit.text()
        dic["address"] = self.address_edit.text()
        dic["phone"] = int(self.phone_edit.text())
        dic["email"] = self.mail_edit.text()
        dic["group"] = Group.get(
            Group.name == self.group_combo_box.currentText())

        User.add(dic)
        self.app.el.fire(EventManager.Events.user_added, {})
        self.close()
Exemple #2
0
    def edit_user(self):
        dic = dict()
        dic["name"] = self.name_edit.text()
        dic["surname"] = self.surname_edit.text()
        dic["address"] = self.address_edit.text()
        dic["phone"] = int(self.phone_edit.text())
        dic["email"] = self.mail_edit.text()
        dic["group"] = self.user.group

        User.edit(self.user.card_id, dic)
        self.app.el.fire(EventManager.Events.user_changed,
                         {"id": self.user.card_id})
        self.close()
Exemple #3
0
 def check_out(self):
     id, okPressed = QInputDialog.getInt(self, "User", "User card ID")
     if not okPressed:
         return
     usr = None
     try:
         usr = User.get_by_id(id)
     except:
         msg = QMessageBox()
         msg.setText("Invalid user card")
         msg.exec_()
         return
     (err, res) = self.bs.check_out(self.doc, usr)
     if err > 0:
         msg = QMessageBox()
         msgs = {
             7: "User is already in the queue",
             6: "User already has copy of this document",
             4: "User is deleted",
             3: "Document is not active",
             2: "Document is referenced",
             1: "User has been added to the queue"
         }
         msg.setText(msgs[err])
         msg.exec_()
         if err == 1:
             self.app.el.fire(EventManager.Events.queue_changed,
                              {"id": self.doc.DocumentID})
         return
     self.app.el.fire(EventManager.Events.copy_state_changed,
                      {"id": res.copy.CopyID})
Exemple #4
0
 def make_or(self):
     id, okPressed = QInputDialog.getInt(self, "User", "User card ID")
     if not okPressed:
         return
     usr = None
     try:
         usr = User.get_by_id(id)
     except:
         msg = QMessageBox()
         msg.setText("Invalid user card")
         msg.exec_()
         return
     (code, res) = self.bs.outstanding_request(self.doc, usr)
     msg = QMessageBox()
     msgs = {
         1: "Copy of a document has been checked out",
         2: "There is a free copy",
         0: "Requested"
     }
     msg.setText(msgs[code])
     msg.exec_()
     if code < 2:
         for i in range(0, len(self.cl)):
             self._row_update(i)
         self.app.el.fire(EventManager.Events.queue_changed,
                          {"id", self.doc.DocmentID})
Exemple #5
0
    def get_result(self):
        self.list = User.get_list(15, self.page_num)

        for i in range(0, len(self.list)):
            self.result_table.setItem(
                i, 0, QTableWidgetItem(str(self.list[i].card_id)))
            self.result_table.setItem(i, 1,
                                      QTableWidgetItem(self.list[i].name))
            self.result_table.setItem(i, 2,
                                      QTableWidgetItem(self.list[i].surname))
            self.result_table.setItem(i, 3,
                                      QTableWidgetItem(self.list[i].address))
            self.result_table.setItem(
                i, 4, QTableWidgetItem(str(self.list[i].phone)))
            self.result_table.setItem(i, 5,
                                      QTableWidgetItem(str(self.list[i].fine)))
            self.result_table.setItem(
                i, 6, QTableWidgetItem(self.list[i].group.name))
        for i in range(len(self.list), 15):
            self.result_table.setItem(i, 0, QTableWidgetItem(""))
            self.result_table.setItem(i, 1, QTableWidgetItem(""))
            self.result_table.setItem(i, 2, QTableWidgetItem(""))
            self.result_table.setItem(i, 3, QTableWidgetItem(""))
            self.result_table.setItem(i, 4, QTableWidgetItem(""))
            self.result_table.setItem(i, 5, QTableWidgetItem(""))
            self.result_table.setItem(i, 6, QTableWidgetItem(""))
Exemple #6
0
    def get_result(self):
        self.list = User.get_list(10, self.page_num)

        for i in range(0, len(self.list)):
            self.result_table.setItem(i, 0, QTableWidgetItem(str(self.list[i].card_id)))
        for i in range(len(self.list), 10):
            self.result_table.setItem(i, 0, QTableWidgetItem(self.list[i].name + " " + self.list[i].surname))
Exemple #7
0
 def reopen(self, id):
     if id != self.user.card_id:
         return
     self.close()
     self.app.open_window(UserInfo,
                          {"user": User.get_by_id(self.user.card_id)})
Exemple #8
0
 def delete_user(self):
     User.remove(self.user.card_id)
     self.close()
     self.app.el.fire(EventManager.Events.user_deleted,
                      {"id": self.user.card_id})