diff --git a/README b/README index 25cf926..b8f8772 100644 --- a/README +++ b/README @@ -30,21 +30,23 @@ sudo docker-compose -f /srv/docker/config/docker-compose.yml up bookdb_web ########################################################### TODOS (next 29): -TODO-27: from missing, exclude any series where the only books we have are SOLD TODO-28: make books.html have page_title? and pass in a 'print these cols'... at least for poor ratings, etc. so we can hide dud columns, and show more useful ones +TODO-27: from missing, exclude any series where the only books we have are SOLD TODO-05: should deleting really just ask if want to mark it as SOLD? IN FACT, make delete button disabled until its sold... (and a tooltip to explain) TODO-09: show books to buy view / printable -TODO-17: view list of possible duplicate books by title -TODO-18: consider which of the 'books maybe not valid' reports make sense still - - can you even have an N/A publisher now for example? - - but the genre one is interesting -TODO-19: icons on wish list, etc.? (not sure I really want them, but if so) - - wishlist: search-dollar OR https://www.flaticon.com/free-icon/wishlist_868517 - - save: https://www.flaticon.com/free-icon/sold_463255?term=sold&page=1&position=6&related_item_id=463255 +Validation: + TODO-17: view list of possible duplicate books by title + TODO-18: consider which of the 'books maybe not valid' reports make sense still + - can you even have an N/A publisher now for example? + - but the genre one is interesting + TODO-19: icons on wish list, etc.? (not sure I really want them, but if so) + - wishlist: search-dollar OR https://www.flaticon.com/free-icon/wishlist_868517 + - save: https://www.flaticon.com/free-icon/sold_463255?term=sold&page=1&position=6&related_item_id=463255 -TODO-20: ORM all books load is slow - - should I lazy load all books (ajax the 2nd->last pages in, or not use ORM, and do a quick db.execute()....) -TODO-21: allow a way to add a book as a child of another existing book (opposite of rem_sub_book) +Maybe: + TODO-20: ORM all books load is slow + - should I lazy load all books (ajax the 2nd->last pages in, or not use ORM, and do a quick db.execute()....) + TODO-21: allow a way to add a book as a child of another existing book (opposite of rem_sub_book) TODO-26: gunicorn and/or more modern non-flask??? diff --git a/main.py b/main.py index e48666d..9af93ef 100644 --- a/main.py +++ b/main.py @@ -36,7 +36,7 @@ from genre import Genre, GenreForm, GenreSchema, GetGenres from condition import Condition, ConditionForm, ConditionSchema, GetConditionById from covertype import Covertype, CovertypeForm, CovertypeSchema, GetCovertypeById from owned import Owned, OwnedForm, OwnedSchema, GetOwnedById -from rating import Rating, RatingForm, RatingSchema +from rating import Rating, RatingForm, RatingSchema, GetRatingById from loan import Loan, LoanForm, LoanSchema from series import Series, SeriesForm, SeriesSchema, ListOfSeriesWithMissingBooks @@ -237,6 +237,7 @@ app.jinja_env.globals['GetCovertypeById'] = GetCovertypeById app.jinja_env.globals['GetOwnedById'] = GetOwnedById app.jinja_env.globals['GetConditionById'] = GetConditionById app.jinja_env.globals['GetPublisherById'] = GetPublisherById +app.jinja_env.globals['GetRatingById'] = GetRatingById app.jinja_env.globals['SeriesBookNum'] = SeriesBookNum app.jinja_env.globals['ClearStatus'] = st.ClearMessage app.jinja_env.globals['ListOfSeriesWithMissingBooks'] = ListOfSeriesWithMissingBooks @@ -673,22 +674,22 @@ def missing_books(): @app.route("/wishlist", methods=["GET"]) def wishlist(): books = Book.query.join(Owned).filter(Owned.name=='On Wish List').all() - return render_template("books.html", books=books ) + return render_template("books.html", books=books, page_title="Books On Wish List", show_cols='', hide_cols='Publisher,Condition,Covertype' ) @app.route("/needs_replacing", methods=["GET"]) def needs_replacing(): books = Book.query.join(Condition,Owned).filter(Condition.name=='Needs Replacing',Owned.name=='Currently Owned').all() - return render_template("books.html", books=books ) + return render_template("books.html", books=books, page_title="Books that Need Replacing", show_cols='', hide_cols='' ) @app.route("/sold", methods=["GET"]) def sold_books(): books = Book.query.join(Owned).filter(Owned.name=='Sold').all() - return render_template("books.html", books=books ) + return render_template("books.html", books=books, page_title="Books that were Sold", show_cols='', hide_cols='' ) @app.route("/poor_rating", methods=["GET"]) def poor_rating_books(): books = Book.query.join(Rating,Owned).filter(Rating.id>6,Rating.name!='Undefined',Owned.name=='Currently Owned').all() - return render_template("books.html", books=books ) + return render_template("books.html", books=books, page_title="Books that have a Poor Rating (<5 out of 10)", show_cols='Rating', hide_cols='' ) @app.route("/", methods=["GET"]) diff --git a/templates/base.html b/templates/base.html index c8cbfb1..5e62e29 100644 --- a/templates/base.html +++ b/templates/base.html @@ -103,7 +103,7 @@ - {% if message|length %} + {% if message is defined and message|length %}
| Title | Author(s) | - {% if not InDBox %} -Publisher | Condition | Owned | Covertype | Covertype | Add? | - {% endif %} - - - {% for book in books %} -
|---|---|---|---|---|---|---|---|
| Title | Author(s) | + {% if not InDBox %} + {% for h in ['Publisher','Condition','Owned','Covertype'] %} + {% if h not in hide_cols %} +{{h}} | + {% endif %} + {% endfor %} + {% for h in ['Rating'] %} + {% if h in show_cols %} +{{h}} | + {% endif %} + {% endfor %} + {% else %} +Covertype | Add? | + {% endif %} +||
| {{book.title}} | {% else %} @@ -29,30 +43,42 @@ {{ auth['surname'] }}, {{auth['firstnames']}} {% endfor %} - {% if not InDBox %} -{{ GetPublisherById(book.publisher)}} | - {% set cond = GetConditionById(book.condition) %} - {% if cond == "N/A" %} -N/A | - {% else %} -- {% if cond == "Good" %} - - {% elif cond == "Average" %} - - {% elif cond == "Needs Replacing" %} - + {% if not InDBox %} + {% if 'Publisher' not in hide_cols %} + | {{ GetPublisherById(book.publisher)}} | {% endif %} - - {% endif %} -{{ GetOwnedById(book.owned)}} | - {% endif %} -{{ GetCovertypeById(book.covertype) }} | - {% if InDBox %} -- {% endif %} - | N/A | + {% else %} ++ {% if cond == "Good" %} + + {% elif cond == "Average" %} + + {% elif cond == "Needs Replacing" %} + + {% endif %} + | + {% endif %} + {% endif %} + {% if 'Owned' not in hide_cols %} +{{ GetOwnedById(book.owned)}} | + {% endif %} + {% endif %} + {% if 'Covertype' not in hide_cols %} +{{ GetCovertypeById(book.covertype) }} | + {% endif %} + {% if InDBox %} ++ {% endif %} + {% if 'Rating' in show_cols %} + | {{ GetRatingById(book.rating) }} | + {% endif %} + + + {% endfor %} -