From 6af1d3c7cb4dfcdee03159dab622155977d2f9fb Mon Sep 17 00:00:00 2001 From: pi3c Date: Sun, 15 Oct 2023 23:22:15 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BF=D0=B0=D0=B3=D0=B8=D0=BD=D0=B0=D1=86=D0=B8=D1=8E?= =?UTF-8?q?=20=D0=BD=D0=B0=20=D0=B3=D0=BB=D0=B0=D0=B2=D0=BD=D0=BE=D0=B9,?= =?UTF-8?q?=20=D1=86=D0=B5=D0=BD=D1=82=D1=80=D0=B8=D1=80=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D1=84=D1=83=D1=82=D0=B5=D1=80=D0=B0,=20?= =?UTF-8?q?=D1=81=D1=81=D1=8B=D0=BB=D0=BA=D0=B8=20=D1=81=D0=BE=20=D0=B2?= =?UTF-8?q?=D0=B7=D0=B0=D0=B8=D0=BC=D0=BE=D0=B4=D0=B5=D0=B9=D1=81=D1=82?= =?UTF-8?q?=D0=B2=D0=B8=D0=B5=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproger/admin/admin.py | 1 - pyproger/blog/urls.py | 8 ++++---- pyproger/dbase/database.py | 8 +++----- pyproger/templates/admin/edit.html | 3 ++- pyproger/templates/blog/base.html | 26 +++++++++++++------------- pyproger/templates/blog/postview.html | 2 +- 6 files changed, 23 insertions(+), 25 deletions(-) diff --git a/pyproger/admin/admin.py b/pyproger/admin/admin.py index b061c16..12c2485 100644 --- a/pyproger/admin/admin.py +++ b/pyproger/admin/admin.py @@ -1,5 +1,4 @@ from flask_admin import Admin -from flask_ckeditor import CKEditor admin = Admin( name="Админ панель", diff --git a/pyproger/blog/urls.py b/pyproger/blog/urls.py index b7b8482..a01ffee 100644 --- a/pyproger/blog/urls.py +++ b/pyproger/blog/urls.py @@ -29,10 +29,10 @@ def index(page=1): session["back_url"] = request.url per_page = current_app.config.get("POSTS_ON_PAGE") - posts, total_pages = get_paginated_posts(page, per_page) - list_pages = [ - x for x in range(1, total_pages + 1) if x >= page - 2 and x <= page + 2 - ] + posts, total = get_paginated_posts(page, per_page) + total_pages = total // per_page + [0, 1][total % per_page != 0] + + list_pages = [x for x in range(1, total_pages + 1)] return render_template( "blog/index.html", title=f'{current_app.config.get("BRAND")} - разговоры про питон', diff --git a/pyproger/dbase/database.py b/pyproger/dbase/database.py index 201b2d7..1e2d109 100644 --- a/pyproger/dbase/database.py +++ b/pyproger/dbase/database.py @@ -38,12 +38,10 @@ def get_all_posts_by_tag(tag, page, per_page): .order_by(Post.create_datetime.desc()) .paginate(page=page, per_page=per_page, error_out=True) ) - total_pages = ( - posts_query.total // per_page + [0, 1][posts_query.total % per_page != 0] - ) if posts_query.total == 0: - return None, None - return posts_query, total_pages + return None, False + print(posts_query.total) + return posts_query, posts_query.total def get_page(slug): diff --git a/pyproger/templates/admin/edit.html b/pyproger/templates/admin/edit.html index c740297..4ae4cb5 100644 --- a/pyproger/templates/admin/edit.html +++ b/pyproger/templates/admin/edit.html @@ -8,5 +8,6 @@ {% block tail %} {{ super() }} {{ ckeditor.load() }} - {{ ckeditor.config(name='text')}} + {{ ckeditor.config(name='title', serve_local=True, pkg_type='basic')}} + {{ ckeditor.config(name='description', serve_local=True, pkg_type='basic')}} {% endblock %} diff --git a/pyproger/templates/blog/base.html b/pyproger/templates/blog/base.html index 365178f..a29614a 100644 --- a/pyproger/templates/blog/base.html +++ b/pyproger/templates/blog/base.html @@ -36,17 +36,17 @@