From 8b2e43b41dc032a052bd37e9ca23581e3d8fac01 Mon Sep 17 00:00:00 2001 From: Matthew Welch Date: Sat, 28 Mar 2020 12:37:11 -0700 Subject: [PATCH] bug fixes and navigation improvement fixed bugs with postgresql group by statement replacing it with the over statement added buttons to go to the next and previous episodes in the episode viewer improved pagination so that it will only show a few previous and next pages instead of all of them and added a next and previous page button --- comics/comics.py | 8 ++--- .../templates/comics/PublisherSeriesList.html | 4 +-- comics/templates/comics/comicGallery.html | 4 +-- comics/templates/comics/seriesList.html | 2 +- scripts/database.py | 6 ++-- templates/pagination.html | 34 +++++++++++++++++-- tv/templates/tv/episodeViewer.html | 22 ++++++++++-- tv/templates/tv/tvShowList.html | 13 ++++--- 8 files changed, 74 insertions(+), 19 deletions(-) diff --git a/comics/comics.py b/comics/comics.py index 206c7de..7af1b6c 100644 --- a/comics/comics.py +++ b/comics/comics.py @@ -112,7 +112,7 @@ def comic_viewer(publisher, series, series_year, issue): series_parsed = parse.quote(series) page_number = int(request.args.get("pageNumber")) meta = database.db_get_comic(publisher, series, series_year, issue) - page_count = int(meta.pageCount) + page_count = int(meta.pagecount) prev_page = page_number - 1 next_page = page_number + 1 @@ -122,7 +122,7 @@ def comic_viewer(publisher, series, series_year, issue): prev_page = page_count - 1 prev_url = "/comics/{}?series={}&seriesYear={}&issue={}&pageNumber={}".format(publisher_parsed, series_parsed, series_year, issue, prev_page) next_url = "/comics/{}?series={}&seriesYear={}&issue={}&pageNumber={}".format(publisher_parsed, series_parsed, series_year, issue, next_page) - title = "Comics: "+meta.series+": #"+meta.issueText+" "+(meta.title or "") + title = "Comics: "+meta.series+": #"+meta.issuetext+" "+(meta.title or "") return render_template("comics/comicView.html", title=title, on_mobile=on_mobile, prev_url=prev_url, next_url=next_url, comic=meta, page_number=page_number) except Exception as e: current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e)) @@ -135,8 +135,8 @@ def comic_gallery(publisher, series, series_year, issue): max_items = request.args.get("max_items", 30, type=int) meta = database.db_get_comic(publisher, series, series_year, issue) start = (max_items*(page-1)) - end = meta.pageCount if meta.pageCount < max_items*page else max_items*page - return render_template("comics/comicGallery.html", title="Comics", comic=meta, start=start, end=end, page=page, max_items=max_items, item_count=meta.pageCount) + end = meta.pagecount if meta.pagecount < max_items*page else max_items*page + return render_template("comics/comicGallery.html", title="Comics", comic=meta, start=start, end=end, page=page, max_items=max_items, item_count=meta.pagecount) except Exception as e: current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e)) return str(type(e)) + " " + str(e) diff --git a/comics/templates/comics/PublisherSeriesList.html b/comics/templates/comics/PublisherSeriesList.html index f86605e..5e1881e 100644 --- a/comics/templates/comics/PublisherSeriesList.html +++ b/comics/templates/comics/PublisherSeriesList.html @@ -1,10 +1,10 @@ {% for i in range(start, end) %}
- +
- {{ publisher_series[i].series }} {{ publisher_series[i].seriesYear }} + {{ publisher_series[i].series }} {{ publisher_series[i].seriesyear }}
diff --git a/comics/templates/comics/comicGallery.html b/comics/templates/comics/comicGallery.html index 86f6249..f5f5a12 100644 --- a/comics/templates/comics/comicGallery.html +++ b/comics/templates/comics/comicGallery.html @@ -8,9 +8,9 @@
{% for page_number in range(start, end) %} {% endfor %} diff --git a/comics/templates/comics/seriesList.html b/comics/templates/comics/seriesList.html index d232287..1028ee2 100644 --- a/comics/templates/comics/seriesList.html +++ b/comics/templates/comics/seriesList.html @@ -1,6 +1,6 @@ {% for i in range(start, end) %}
- +
diff --git a/scripts/database.py b/scripts/database.py index e016075..45852d8 100644 --- a/scripts/database.py +++ b/scripts/database.py @@ -443,7 +443,7 @@ def db_get_all_comics(): def db_get_series_by_publisher(publisher): session = Session() - result = session.query(Comic).filter(Comic.publisher == publisher).group_by(Comic.publisher, Comic.series, Comic.seriesyear).order_by(Comic.series, Comic.seriesyear).all() + result = [i[0] for i in session.query(Comic, over(func.rank(), partition_by=[Comic.publisher, Comic.series, Comic.seriesyear], order_by=[Comic.series, Comic.seriesyear])).filter(Comic.publisher == publisher).all()] series = result return series @@ -580,7 +580,9 @@ def db_get_movie_by_imdb_id(imdb_id, extended=False, directors_cut=False): def get_all_tv_shows(): session = Session() result = session.query(TvShow).order_by(TvShow.title, TvShow.year).all() - return result + email = current_user.email + shows = [(i, session.execute("SELECT rpiwebapp.is_tv_show_finished('{}', '{}')".format(i.imdb_id, email)).first()[0]) for i in result] + return shows def get_tv_show_episodes_by_imdb_id(imdb_id): diff --git a/templates/pagination.html b/templates/pagination.html index 2fb6c4e..9c702f6 100644 --- a/templates/pagination.html +++ b/templates/pagination.html @@ -5,12 +5,42 @@ {% for key in request.args.keys() %} {% if key != "page" %}{% endif %} {% endfor %} -