Ejemplo n.º 1
0
    def changepassword(self):

        sec_ans = self.parent.sec_a_lineedit.text()
        user = dbHelper().get_user_by_uid(dbHelper().get_user_by_username(
            self.username)[0])
        print(user)
        password = self.parent._new_password_lineedit.text()
        if sec_ans == "" or password == "":
            self.parent.empty_error()
            return
        if user is not None:
            if user[3] == sec_ans:
                dbHelper().update_password(user[0], password)
        self.parent._password_changed_()
Ejemplo n.º 2
0
 def __init__(self, parent,username) -> None:
     super().__init__(parent=parent)
     self._parent = parent
     self.username = username
     self.rowid = dbHelper().get_user_by_username(self.username)
     self.init()
     self.addComponnent()
     self.setData()
     self.setDataToComponnents()
Ejemplo n.º 3
0
    def save(self):
        _book_name = self.parent._book_name_lineedit.text()
        _book_author_name = self.parent._book_author_lineedit.text()
        _book_pages = self.parent._book_pages_lineedit.text()
        _book_edition = self.parent._book_edition_lineedit.text()
        _book_isbn = self.parent._book_isbn_lineedit.text()
        _book_publisher = self.parent._book_publisher_lineedit.text()
        _book_language = self.parent._book_language_lineedit.text()
        _book_translator = self.parent._book_translate_lineedit.text()
        _book_uploader = self.parent._parent.username

        _book_release_date = self.parent._book_firstpublishdate_lineedit.text()
        _book_editionpublishdate = self.parent._book_editionpublishdate_lineedit.text(
        )
        _book_desc = self.parent._book_desc_textedit.toPlainText()
        _book_image = None
        if _book_isbn == "" or _book_name == "" or _book_pages == "" or _book_author_name == "":
            #TODO add error label
            return
        if self.parent._book_image_label.pixmap() is not None:
            if self.parent.fileaddress is not None:
                with open(self.parent.fileaddress, 'rb') as file:
                    _book_image = file.read()
            else:
                _book_image = self.parent._book_image_label.pixmap()

        if self.parent.mode == 1:
            from datetime import datetime
            _book_uploaddate = datetime.now()
            dbHelper().add_book(_book_name, _book_author_name, _book_pages,
                                _book_isbn, _book_edition, _book_publisher,
                                _book_language, _book_translator,
                                _book_uploader, _book_uploaddate,
                                _book_release_date, _book_editionpublishdate,
                                _book_desc, _book_image)
            self.parent.close()
        else:
            #edit book info
            dbHelper().editbook(_book_name, _book_author_name, _book_pages,
                                _book_edition, _book_isbn, _book_publisher,
                                _book_language, _book_translator,
                                _book_release_date, _book_editionpublishdate,
                                _book_desc, _book_image, self.parent._uid)
            self.parent.close()
Ejemplo n.º 4
0
    def search(self, text):

        self.clear()
        books = dbHelper().search(text)
        for i in books:
            book = bookPreviewWidget(i[0], self._book_list_widget)
            book.setMinimumSize(300, 100)
            book.setMaximumSize(300, 200)
            self.items.append(book)
            self._book_list_widget.addWidget(book)
Ejemplo n.º 5
0
 def __init__(self, parent,uniqueId=None) -> None:
     # self._event = bookPreviewEvent(self)
     self._parent = parent
     self.mode =1
     super().__init__()
     self._uid = uniqueId
     self._dbHelper:dbHelper = dbHelper()
     self.init()
     self.init_data()
     self._event = event(self)
     self.setAttribute(QtCore.Qt.WA_StyledBackground, True)
     self.setStyleSheet(parser(CSS_LOGIN))
Ejemplo n.º 6
0
 def login(self):
     username = self.parent._username_lineedit.text()
     passwors = self.parent._password_lineedit_.text()
     if username=="" or passwors =="":
         self.parent.empty_error()
         return
     user = dbHelper().get_user(username= username,password= passwors)
     if user is not None:
         if user[4]==1:
             self.parent._parent.open(user[0])
         return
     self.parent.wrongpassword()
Ejemplo n.º 7
0
    def signup(self):

        username = self.parent._username_lineedit.text()
        passwors = self.parent._password_lineedit_.text()
        sec_q = self.parent.sec_q.text()
        sec_a = self.parent.sec_p.text()
        if username == "" or passwors == "" or sec_a == "" or sec_q == "":
            self.parent.empty_error()
            return
        user = dbHelper().add_user(username, passwors, sec_q, sec_a)
        if user is None:
            self.parent._username_exist()
            return
        self.parent.wait()
    def __init__(self, uniqueId:str ,parent ):
        """
        :param uniqueId: book unique id
        :param parent: parent widget obj
        """
        self._event = bookPreviewEvent(self)
        self._parent = parent

        super().__init__( event_=self._event)
        
        self._uid = uniqueId
        self._dbHelper:dbHelper = dbHelper()
        self.init()
        self.init_data()
        self.setAutoFillBackground(True)
        self.setAttribute(QtCore.Qt.WA_StyledBackground, True)
        self.setAccessibleNames()
        self.setStyleSheet(parser(CSS_BOOKPREVIEW))
Ejemplo n.º 9
0
 def addItems(self):
     users = dbHelper().get_users()
     itemflags = QtCore.Qt.ItemFlags(QtCore.Qt.ItemIsSelectable
                                     | QtCore.Qt.ItemIsEnabled)
     for i in users:
         row_number: int = self.__tablewidget_admins_.rowCount()
         self.__tablewidget_admins_.setRowCount(row_number + 1)
         username = i[0]
         row_item1: cQTableWidgetItem = cQTableWidgetItem(
             userid=username, type_=1, event_=self.event_)
         row_item1.setFlags(itemflags)
         row_item2: cQTableWidgetItem = cQTableWidgetItem(
             userid=username, type_=0, event_=self.event_)
         row_item2.setFlags(itemflags)
         self.__tablewidget_admins_.setItem(row_number, 0, row_item1)
         self.__tablewidget_admins_.setItem(row_number, 1, row_item2)
         self.__tablewidget_admins_.setVerticalHeaderItem(
             row_number, QTableWidgetItem(str(row_number)))
Ejemplo n.º 10
0
 def update(self):
     self._search_lineedit.setHidden(False)
     self._add_book_button.setHidden(False)
     self._books_label.setAccessibleName("sidebar_clicked")
     self._admin_label.setAccessibleName("transparent")
     self._mybooks_label.setAccessibleName("transparent")
     self._setting_label.setAccessibleName("transparent")
     self.setStyleSheets()
     self._setting_widget.setHidden(True)
     self._admins_widget.setHidden(True)
     self._book_list_widget.setHidden(False)
     self.clear()
     books = dbHelper().get_books()
     for i in books:
         book = bookPreviewWidget(i[0], self)
         book.setMinimumSize(300, 100)
         book.setMaximumSize(300, 200)
         self.items.append(book)
         self._book_list_widget.addWidget(book)
Ejemplo n.º 11
0
    def update(self):
        if self.username_lineedit.text() =="" or self.s_q_.text() == "" or self.s_a_.text() == "":

            if self.username_lineedit.text() =="":
                self.username_lineedit.setPlaceholderText("[this field is empty]")

            if self.s_q_.text() == "" :
                self.s_q_.setPlaceholderText("[this field is empty]")

            if self.s_a_.text() == "":
                self.s_a_.setPlaceholderText("[this field is empty]")

            return

        if dbHelper().update_user(self.c_username,self.username_lineedit.text(),self.password_lineedit.text(),self.s_q_.text(),self.s_a_.text()) == -1:
            self.username_lineedit.setText("")
            self.username_lineedit.setPlaceholderText("This User Name Exist")
            self.username_lineedit.setAccessibleName("error")
            return
        self.setData()
Ejemplo n.º 12
0
 def setdata(self):
     if (dbHelper().get_user_by_username(self.username) != None):
         user_seq = dbHelper().get_user_by_uid(
             dbHelper().get_user_by_username(self.username)[0])[2]
         self.__sec_q_label.setText(user_seq)
Ejemplo n.º 13
0
 def setData(self):
     user = dbHelper().get_user_by_uid( self.rowid)
     self.c_username ,self.c_password , self.c_sec_q , self.c_sec_a ,_=user
 def deactive(self):
     self.activated = False
     if self.type_ == 0:
         self.setText("DEACTIVATED")
     dbHelper().deactive_user(dbHelper().get_user_by_username(self.username))
 def active(self):
     self.activated = True
     if self.type_ == 0:
         self.setText("ACTIVATED")
     dbHelper().active_user(dbHelper().get_user_by_username(self.username))
 def init(self):
     self.username,_,_,_,self.activated = dbHelper().get_user_by_uid( dbHelper().get_user_by_username(self.username))