From 4c1186f2be76c6a99b1708857ed3107f47a16da5 Mon Sep 17 00:00:00 2001 From: Ethan Date: Wed, 27 Apr 2022 17:35:46 -0400 Subject: [PATCH 1/3] added pages for 'a\dditional' route --- quotefault/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quotefault/__init__.py b/quotefault/__init__.py index c2b05d9..d049d68 100644 --- a/quotefault/__init__.py +++ b/quotefault/__init__.py @@ -242,7 +242,7 @@ def additional_quotes(): # Get all the quotes quotes = get_quote_query(speaker = request.args.get('speaker'), - submitter = request.args.get('submitter')).all() + submitter = request.args.get('submitter')).paginate(int(request.args.get("page", default="1")), 20).items for quote in quotes: quote[0].quote_time=quote[0].quote_time.astimezone(pytz.timezone('America/New_York')) @@ -252,7 +252,7 @@ def additional_quotes(): return render_template( 'bootstrap/additional_quotes.html', - quotes=quotes[20:], + quotes=quotes, metadata=metadata, user_votes=user_votes ) From 3f8119f3888bc7b76ac7112cdcf5b5011f4ce4d7 Mon Sep 17 00:00:00 2001 From: Ethan Date: Wed, 27 Apr 2022 20:06:40 -0400 Subject: [PATCH 2/3] finished pages :) --- quotefault/static/js/load_more.js | 14 +++++++++----- quotefault/templates/bootstrap/storage.html | 17 ++++++++--------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/quotefault/static/js/load_more.js b/quotefault/static/js/load_more.js index 5ac7c9c..2a6f059 100644 --- a/quotefault/static/js/load_more.js +++ b/quotefault/static/js/load_more.js @@ -34,24 +34,28 @@ function buttonAjax(buttonElem, options, failOnly) { } } +var currentPage = 1; + $(function () { - $("#get_more").one("click", function (e) { + $("#get_more").click(function (e) { //Prepare the url with the proper query strings let urlParams = new URLSearchParams(window.location.search); let speaker = urlParams.get('speaker'); let submitter = urlParams.get('submitter'); - let urlStr = `/additional`; + let page = urlParams.get('page'); + let urlStr = `/additional?j`; if(speaker){ - urlStr+=`?speaker=${speaker}`; + urlStr+=`&speaker=${speaker}`; } if(submitter){ - urlStr+=`?submitter=${submitter}`; + urlStr+=`&submitter=${submitter}`; } + urlStr += "&page=" + (currentPage++); buttonAjax($(this), { url: urlStr, method: 'GET', success: function (data, textStatus, jqXHR) { - $("#moreQuotes").html(data) + $("#moreQuotes").append(data) .collapse("show"); }, error: function (error) { diff --git a/quotefault/templates/bootstrap/storage.html b/quotefault/templates/bootstrap/storage.html index 16eba26..b56dcb7 100644 --- a/quotefault/templates/bootstrap/storage.html +++ b/quotefault/templates/bootstrap/storage.html @@ -11,17 +11,17 @@ {% with messages = get_flashed_messages(with_categories=true) %} {% if messages %} {% for category, message in messages %} - - {% endfor %} - {% endif %} + + {% endfor %} + {% endif %} {% endwith %} {{ display( quotes ) }} - -
- {% endblock %} @@ -30,4 +30,3 @@ {% endblock %} - From 204bb3fe48e7eafe9d579f509dd2970e9cf9f1a5 Mon Sep 17 00:00:00 2001 From: Ethan Date: Wed, 27 Apr 2022 20:09:15 -0400 Subject: [PATCH 3/3] fix whitespace issues --- quotefault/templates/bootstrap/storage.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/quotefault/templates/bootstrap/storage.html b/quotefault/templates/bootstrap/storage.html index b56dcb7..862a048 100644 --- a/quotefault/templates/bootstrap/storage.html +++ b/quotefault/templates/bootstrap/storage.html @@ -11,11 +11,11 @@ {% with messages = get_flashed_messages(with_categories=true) %} {% if messages %} {% for category, message in messages %} - - {% endfor %} - {% endif %} + + {% endfor %} + {% endif %} {% endwith %} {{ display( quotes ) }}