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 @@