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 %}
{{message|safe}} {{ ClearStatus() }} diff --git a/templates/books.html b/templates/books.html index 94b24ed..efe11fc 100644 --- a/templates/books.html +++ b/templates/books.html @@ -1,24 +1,38 @@ {% extends "base.html" %} {% block main_content %} +{% if page_title is not defined %} + {% set page_title="All Books" %} +{%endif %} + {% if not InDBox %} -

All Books

+

{{page_title}}

{% set tab_id = 'book_table' %} {% else %} {% set tab_id = 'addsel_table' %} {% endif %} - - - {% if not InDBox %} - - {% else %} - - {% endif %} - - - {% for book in books %} - + + + {% if not InDBox %} + {% for h in ['Publisher','Condition','Owned','Covertype'] %} + {% if h not in hide_cols %} + + {% endif %} + {% endfor %} + {% for h in ['Rating'] %} + {% if h in show_cols %} + + {% endif %} + {% endfor %} + {% else %} + + {% endif %} + + + + {% for book in books %} + {% if book.sub_book_num is defined %} {% else %} @@ -29,30 +43,42 @@ {{ auth['surname'] }}, {{auth['firstnames']}} {% endfor %} - {% if not InDBox %} - - {% set cond = GetConditionById(book.condition) %} - {% if cond == "N/A" %} - - {% else %} - {% endif %} - - {% endif %} - - {% endif %} - - {% if InDBox %} - - {% endif %} - - {% endfor %} + {% if 'Condition' not in hide_cols %} + {% set cond = GetConditionById(book.condition) %} + {% if cond == "N/A" %} + + {% else %} + + {% endif %} + {% endif %} + {% if 'Owned' not in hide_cols %} + + {% endif %} + {% endif %} + {% if 'Covertype' not in hide_cols %} + + {% endif %} + {% if InDBox %} + + {% endif %} + {% if 'Rating' in show_cols %} + + {% endif %} + + + {% endfor %} -
TitleAuthor(s)PublisherConditionOwned Covertype
CovertypeAdd?
TitleAuthor(s){{h}}{{h}}CovertypeAdd?
    {{book.title}}{{ GetPublisherById(book.publisher)}}N/A - {% if cond == "Good" %} - - {% elif cond == "Average" %} - - {% elif cond == "Needs Replacing" %} - + {% if not InDBox %} + {% if 'Publisher' not in hide_cols %} + {{ GetPublisherById(book.publisher)}}{{ GetOwnedById(book.owned)}}{{ GetCovertypeById(book.covertype) }}
N/A + {% if cond == "Good" %} + + {% elif cond == "Average" %} + + {% elif cond == "Needs Replacing" %} + + {% endif %} + {{ GetOwnedById(book.owned)}}{{ GetCovertypeById(book.covertype) }}{{ GetRatingById(book.rating) }}
+ {% endblock main_content %}