def ReturnLoanedBook(self): self.Returned = True self.DateReturned = str(dt.datetime.now()) loanedBookToReturn = { "id_book": self.Id_book, "id_subscriber": self.Id_subscriber, "returned": True, "dateRented": self.DateRented, "dateReturned": self.DateReturned } LoanedBooksRepository.returnBook(self.Id, loanedBookToReturn) return self
def __init__(self): self.AllLoanedBooksList = [] self.AllSubscribersList = [] allLoanedBooks = LoanedBooksRepository.readJson() allSubscribers = SubscribersRepository.readJson() for singleLoanedBook in allLoanedBooks: loanObject = LoanedBook(singleLoanedBook) self.AllLoanedBooksList.append(loanObject) for subscriber in allSubscribers: subscriberObject = Subscriber(subscriber) self.AllSubscribersList.append(subscriberObject)
def __init__(self, loanedBook_id): book = LoanedBooksRepository.getLoanedBook(loanedBook_id) if isinstance(loanedBook_id, str): loanedBook_id = int(loanedBook_id) self.Id = loanedBook_id self.Id_book = book['id_book'] self.Id_subscriber = book['id_subscriber'] self.Returned = book['returned'] self.DateRented = book['dateRented'] self.DateReturned = book['dateReturned']
def AddLoanedBook(id_book, id_subscriber): loanedBookToAdd = { "id_book": id_book, "id_subscriber": id_subscriber, "returned": False, "dateRented": str(dt.datetime.now()), "dateReturned": "" } newLoanedBookId = LoanedBooksRepository.addBookToJsonAndReturnId( loanedBookToAdd) return LoanedBook(newLoanedBookId)
def __init__(self): self.AllBooksList = [] allBooks = BooksRepository.readJson() allLoanedBooks = LoanedBooksRepository.readJson() for singleBook in allBooks: bookObject = Book(singleBook) countLoanedBookOfBook = 0 for loanedBook in allLoanedBooks: loanBookObject = LoanedBook(loanedBook) if loanBookObject.Id_book == bookObject.Id and loanBookObject.Returned == False: countLoanedBookOfBook += 1 if countLoanedBookOfBook != bookObject.BookItems: self.AllBooksList.append(bookObject)
def RecoverBackup(self): listOfDirectoryBackups = next(os.walk("Data/Backup"))[1] dictOfDirectoryBackups = dict( enumerate(listOfDirectoryBackups, start=1)) for directory in dictOfDirectoryBackups: print("{} : {}".format(directory, dictOfDirectoryBackups[directory])) backupToRecoverIndex = int( input( "\nWelk backup wil je herstellen? (geef nummer op van backup): " ).strip()) if backupToRecoverIndex in dictOfDirectoryBackups: BooksRepository.recoverBackup( dictOfDirectoryBackups[backupToRecoverIndex]) LoanedBooksRepository.recoverBackup( dictOfDirectoryBackups[backupToRecoverIndex]) SubscribersRepository.recoverBackup( dictOfDirectoryBackups[backupToRecoverIndex]) print("Backup succesvol hersteld") os.startfile(sys.argv[0]) sys.exit() else: print("Backup bestaat niet! Kies een andere index")
def MakeBackup(self): BooksRepository.createBackup() LoanedBooksRepository.createBackup() SubscribersRepository.createBackup() print("\nBackup gelukt")