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 ) 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..862a048 100644 --- a/quotefault/templates/bootstrap/storage.html +++ b/quotefault/templates/bootstrap/storage.html @@ -18,10 +18,10 @@ {% endif %} {% endwith %} {{ display( quotes ) }} - -
- {% endblock %} @@ -30,4 +30,3 @@ {% endblock %} -