Ejemplo n.º 1
0
def submit_upload_form(title, author, genre, isbn, price, uploader, summary, cover_img, file_location):
    """
    Saves file to the database folder, preferably under the blobs subdirectory.
    :param title: str
    :param author: str
    :param genre: str
    :param isbn: str
    :param price: int
    :param uploader: str
    :param summary: str
    :param cover_img: str
    :param file_location: str
    :return:
    """

    # Upload file to subdirectory
    serialize_ebook(EBook(title=title,
                          author=author,
                          genre=genre,
                          isbn=isbn,
                          price=price,
                          uploader=load_serialized_user(uploader),
                          summary=summary,
                          cover_img=cover_img,
                          book_text=convert_pdf_to_txt(file_location)
                          ), isbn, file_location)
Ejemplo n.º 2
0
def submit_upload_form(title, author, genre, isbn, price, uploader, summary,
                       cover_img, file_location):
    """
    Saves file to the database folder, preferably under the blobs subdirectory.
    :param title: str
    :param author: str
    :param genre: str
    :param isbn: str
    :param price: int
    :param uploader: str
    :param summary: str
    :param cover_img: str
    :param file_location: str
    :return:
    """

    # Upload file to subdirectory
    serialize_ebook(
        EBook(title=title,
              author=author,
              genre=genre,
              isbn=isbn,
              price=price,
              uploader=load_serialized_user(uploader),
              summary=summary,
              cover_img=cover_img,
              book_text=convert_pdf_to_txt(file_location)), isbn,
        file_location)
Ejemplo n.º 3
0
def add_report_to_book(book_instance, report_name):
    book_instance.add_report(load_serialized_report(report_name))
    serialize_ebook(book_instance, book_instance.isbn, os.path.join(EBOOKS_DIR_PATH, book_instance.isbn + ".pickle"))
Ejemplo n.º 4
0
for user in os.listdir(USER_DIR_PATH):
    if user.endswith('.pickle'):
        user_list.append(load_serialized_user(user[:-7]))

for pdf in os.listdir(PDF_DIR_PATH):
    if count == len(GENRE_LIST):
        break

    if pdf.endswith('.pdf'):
        e_book = EBook(title=(pdf[:-4]),
                       author="Author#" + str(count),
                       genre=GENRE_LIST[count],
                       price=price,
                       uploader=user_list[user_count],
                       summary=lorem,
                       cover_img=os.path.abspath(os.path.join(COVER_DIR_PATH, 'temp-cover' + str(count) + '.jpg')),
                       isbn=str(init_ISBN),
                       approved=True,
                       reward_amount=10,
                       book_text=convert_pdf_to_txt(PDF_DIR_PATH + os.sep + pdf),
                       rating=0)
        e_book.buy_count = random.randrange(0, 30)
        serialize_ebook(e_book, str(init_ISBN), os.path.join(PDF_DIR_PATH, pdf))
        user_count += 1
        if user_count == len(user_list):
            user_count = 0
        init_ISBN += 1
        count += 1
        price += 10
Ejemplo n.º 5
0
for pdf in os.listdir(PDF_DIR_PATH):
    if count == len(GENRE_LIST):
        break

    if pdf.endswith('.pdf'):
        e_book = EBook(title=(pdf[:-4]),
                       author="Author#" + str(count),
                       genre=GENRE_LIST[count],
                       price=price,
                       uploader=user_list[user_count],
                       summary=lorem,
                       cover_img=os.path.abspath(
                           os.path.join(COVER_DIR_PATH,
                                        'temp-cover' + str(count) + '.jpg')),
                       isbn=str(init_ISBN),
                       approved=True,
                       reward_amount=10,
                       book_text=convert_pdf_to_txt(PDF_DIR_PATH + os.sep +
                                                    pdf),
                       rating=0)
        e_book.buy_count = random.randrange(0, 30)
        serialize_ebook(e_book, str(init_ISBN),
                        os.path.join(PDF_DIR_PATH, pdf))
        user_count += 1
        if user_count == len(user_list):
            user_count = 0
        init_ISBN += 1
        count += 1
        price += 10
Ejemplo n.º 6
0
def add_report_to_book(book_instance, report_name):
    book_instance.add_report(load_serialized_report(report_name))
    serialize_ebook(
        book_instance, book_instance.isbn,
        os.path.join(EBOOKS_DIR_PATH, book_instance.isbn + ".pickle"))