Пример #1
0
def approve_book(isbn, username):
    """
    Approve a book and reward points
    :param isbn: str
    :param username: str
    :return:
    """
    book = load_serialized_ebook(isbn)
    book.approved = True
    add_user_credits(username, book.award_amount)
    update_serialized_ebook(book)
Пример #2
0
def approve_book(isbn, username):
    """
    Approve a book and reward points
    :param isbn: str
    :param username: str
    :return:
    """
    book = load_serialized_ebook(isbn)
    book.approved = True
    add_user_credits(username, book.award_amount)
    update_serialized_ebook(book)
Пример #3
0
def submit_review_rate_form(book_instance, reviewer, rating, review):
    review_name = book_instance.isbn + "-" + str(datetime.datetime.now()).replace(":", "-")
    serialize_review(Review(reviewer=reviewer.username,
                            review=review), review_name)
    book_instance.add_review(load_serialized_review(review_name))
    reviewer.reviewed_books.append(book_instance)
    update_serialized_user(reviewer)

    book_instance.rating = (book_instance.rating * book_instance.count_seconds +
                            reviewer.rented_books[book_instance.isbn].total_seconds * rating) / \
                           book_instance.total_seconds
    book_instance.count_seconds = book_instance.total_seconds

    update_serialized_ebook(book_instance)
Пример #4
0
def submit_review_rate_form(book_instance, reviewer, rating, review):
    review_name = book_instance.isbn + "-" + str(
        datetime.datetime.now()).replace(":", "-")
    serialize_review(Review(reviewer=reviewer.username, review=review),
                     review_name)
    book_instance.add_review(load_serialized_review(review_name))
    reviewer.reviewed_books.append(book_instance)
    update_serialized_user(reviewer)

    book_instance.rating = (book_instance.rating * book_instance.count_seconds +
                            reviewer.rented_books[book_instance.isbn].total_seconds * rating) / \
                           book_instance.total_seconds
    book_instance.count_seconds = book_instance.total_seconds

    update_serialized_ebook(book_instance)