Пример #1
0
    def save_to_firebase(self):
        validation = self.validate()
        if validation:
            titulo = self.lineEdit_titulo.text()
            isbn = self.lineEdit_ISBN.text()
            numerodepaginas = self.lineEdit_numerodepaginas.text()
            ano = self.lineEdit_ano.text()
            genero = self.lineEdit_Genero.text()
            descricao = self.lineEdit_descricao.text()
            autor = self.lineEdit_autor.text()

            book = Book(isbn, titulo, numerodepaginas, genero, descricao, ano,
                        autor)

            db.child('books').push(book.to_dict())

            msg = QtWidgets.QMessageBox()
            msg.setIcon(QtWidgets.QMessageBox.NoIcon)
            msg.setText("Sucesso")
            msg.setInformativeText("Cadastrado com sucesso!")
            msg.setWindowTitle("Sucesso")
            msg.exec_()

            self.lineEdit_titulo.setText('')
            self.lineEdit_ISBN.setText('')
            self.lineEdit_numerodepaginas.setText('')
            self.lineEdit_ano.setText('')
            self.lineEdit_Genero.setText('')
            self.lineEdit_descricao.setText('')
            self.lineEdit_autor.setText('')

            if self.mainWindow:
                if loggedUser != None and loggedUser.level == LevelOfAccess.ADMIN:
                    self.mainWindow.stackedWidget.setCurrentIndex(4)
                else:
                    self.mainWindow.stackedWidget.setCurrentIndex(0)
        else:
            print("Validation Error")
Пример #2
0
line = '192.168.125-00'

import re
line = re.sub('[.-]', '', line)

print(line)

exit()

booksRef = db.child('books')

from data import Book, User, LevelOfAccess

b = Book('1234567890123', 'Teste', "Editora", 'Genero', "Descrição do livro.",
         '2019', ['Fulano'])

print('sending ', b, ' to firebase...')
booksRef.push(b.to_dict())

u = User("*****@*****.**", "Fulano", "123467543091",
         LevelOfAccess.COMMON_USER)
db.child('users').child(u.email).set(u.to_dict())

docs = booksRef.get()

print("Data:")
print(docs.val())
'''
for doc in docs.val():
    print('Retrieved document ', doc.id, ' from Firebase: ', Book.from_dict(doc.to_dict()))
'''