Example #1
0
def delete_all_books():
    clear_caches()
    for isbn in all_isbns():
        delete_book_isbn(isbn)
    redis.flushdb()
    flash('All books have been deleted.')
    return redirect(url_for('show_entries'))
Example #2
0
def populate():
    clear_caches()
    # books_on_shelf = {'9780691036564': 0, \
    #                 '9780393924282': 0, \
    #                 '9780393971668': 0, \
    #                 '9780486270654': 0, \
    #                 '9780060726461': 0, \
    #                 '9781844674183': 1, \
    #                 '9780300118063': 1, \
    #                 '9780061792960': 1, \
    #                 '9780802170019': 1, \
    #                 '9780521566827': 1, \
    #                 '9781852421397': 2, \
    #                 '9780140186246': 2, \
    #                 '9781565848160': 2, \
    #                 '9780945774075': 2, \
    #                 '9780231133814': 2, }
    books_on_shelf = {'9780691036564': 0, \
                    '9780393924282': 0, \
                    '9780393971668': 0, \
                    '9780486270654': 0, \
                    '9780060726461': 0, \
                    '9781844674183': 1, \
                    '9780300118063': 1, \
                    '9780061792960': 1, \
                    '9780802170019': 1, \
                    '9780521566827': 1, \
                    '9781852421397': 2, \
                    '9780140186246': 2, \
                    '9781565848160': 2, \
                    '9780945774075': 2, \
                    '9780231133814': 2 }
    # bookmark ids go here
    books_on_shelf_tag_ids = {'9780691036564': 27445, \
                    '9780393924282': "06876", \
                    '9780393971668': 11927, \
                    '9780486270654': 56581, \
                    '9780060726461': 38526, \
                    '9781844674183': 13087, \
                    '9780300118063': 45975, \
                    '9780061792960': 13238, \
                    '9780802170019': 18351, \
                    '9780521566827': 50273, \
                    '9781852421397': 39726, \
                    '9780140186246': 39670, \
                    '9781565848160': 43616, \
                    '9780945774075': 10091, \
                    '9780231133814': 28475, }  
    books_not_on_shelf = ['9780062255655', \
                            '9780062017819', \
                            '9781476727653', \
                            '9780061342394', \
                            '9780316198837', \
                            '9780440180296', \
                            '9780810117433', \
                            '9781593076672']
    redis.flushdb();
    for isbn in books_on_shelf.keys():
        add_book_info_programmatically(isbn)
        add_to_shelf_with_tag(isbn, books_on_shelf[isbn], books_on_shelf_tag_ids[isbn])
    for isbn in books_not_on_shelf:
        add_book_info_programmatically(isbn)
    # special book for testing, must have card
    redis.set("9781852421397:rfid_num", "11927")
    return redirect(url_for('show_entries'))