Exemple #1
0
    def create_and_store_purchase_option(self, temp_book, isbn, price):
        errors = []
        # Check if book has correct ISBN
        # Check DB for duplicate isbn entry.
        # If so just make purchase option

        book = Book.get(isbn=isbn)
        if not book:
            book = Book()
            book.author = temp_book.author
            if temp_book.subtitle is None:
                book.title = temp_book.title
            else:
                book.title = temp_book.title+': ' + temp_book.subtitle
            book.isbn = isbn
            book.save()

        # add purchaseChoice to DB
        p = PurchaseChoice()
        p.book_id = book.id
        p.price = price
        p.type = 'Hardcover'
        p.isRental = False
        p.link = ''  # TODO change to valid link
        p.local_seller_id = current_user.id
        p.isLocalSeller = True
        p.save()
        return errors