diff --git a/main/models.py b/main/models.py index 0da3dbd684b5599b644cd5d2a89f7c8444f73a30..6d511de27fe365068f2e124a27583a1c7c183ea9 100644 --- a/main/models.py +++ b/main/models.py @@ -218,7 +218,7 @@ class MainHomePage( ).content data = { "html": html_content.decode("utf-8"), - "last_page": tweet_page.paginator.num_pages, + "has_next": tweet_page.has_next(), } return JsonResponse(data=data, safe=False) @@ -388,7 +388,7 @@ class MainArticlesPage( ).content data = { "html": html_content.decode("utf-8"), - "last_page": article_page.paginator.num_pages, + "has_next": article_page.has_next(), } return JsonResponse(data=data, safe=False) diff --git a/main/templates/main/blocks/twitter_block.html b/main/templates/main/blocks/twitter_block.html index acd9f668abca5d609e750d80eecf32cb99243ffe..c6e609aacc09cd99db9b3e568b707bba52c72db0 100644 --- a/main/templates/main/blocks/twitter_block.html +++ b/main/templates/main/blocks/twitter_block.html @@ -42,7 +42,7 @@ const data = await response.json() tweetsList.innerHTML += data.html; - if (btn.getAttribute('data-page') === data.last_page) { btn.hide() } + if (!data.has_next) { btn.style.display = 'none'; } const dataPage = parseInt(btn.getAttribute('data-page')) + 1 btn.setAttribute('data-page', dataPage) diff --git a/main/templates/main/main_articles_page.html b/main/templates/main/main_articles_page.html index ba40e551f09b409dbbf07974d47b75bb9238c758..c61a8a35ce2b3c7711c74d5bfecbf2aa1f778766 100644 --- a/main/templates/main/main_articles_page.html +++ b/main/templates/main/main_articles_page.html @@ -120,8 +120,7 @@ }) const data = await response.json() searchArticleResultWrapper.innerHTML += data.html; - if (btn.getAttribute('data-page') === data.last_page) - btn.hide(); + if (!data.has_next) { btn.style.display = 'none'; } btn.setAttribute('data-page', parseInt(btn.getAttribute('data-page')) + 1) } </script>