From b4341ed0f8743ee40ea96ae25886de10cbfb8f42 Mon Sep 17 00:00:00 2001 From: Darks Date: Sat, 7 Dec 2019 16:34:39 +0100 Subject: [PATCH] Ajout de la pagination pour les topics de forum --- app/processors/utilities.py | 6 ++++-- app/templates/forum/topic.html | 5 +++++ app/templates/widgets/pagination.html | 23 +++++++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 app/templates/widgets/pagination.html diff --git a/app/processors/utilities.py b/app/processors/utilities.py index b3483f5..1531347 100644 --- a/app/processors/utilities.py +++ b/app/processors/utilities.py @@ -1,9 +1,11 @@ from app import app +from flask import url_for @app.context_processor def utilities_processor(): """ Add some utilities to render context """ return dict( - # len=len, - # enumerate=enumerate + len=len, + # enumerate=enumerate, + _url_for = lambda route, args, **other: url_for(route, **args, **other), ) diff --git a/app/templates/forum/topic.html b/app/templates/forum/topic.html index 0008d36..ae35e6e 100644 --- a/app/templates/forum/topic.html +++ b/app/templates/forum/topic.html @@ -1,6 +1,7 @@ {% extends "base/base.html" %} {% import "widgets/editor.html" as widget_editor %} {% import "widgets/member.html" as widget_member %} +{% import "widgets/pagination.html" as widget_pagination with context %} {% block title %} Forum de Planète Casio » {{ t.forum.name }} »

{{ t.title }}

@@ -14,6 +15,8 @@ {{ t.thread.top_comment.text }} + {{ widget_pagination.paginate(comments, 'forum_topic', {'f': t.forum, 't':t}) }} + {% for c in comments.items %} @@ -35,6 +38,8 @@ {% endfor %}
+ {{ widget_pagination.paginate(comments, 'forum_topic', {'f': t.forum, 't':t}) }} +

Commenter le sujet

diff --git a/app/templates/widgets/pagination.html b/app/templates/widgets/pagination.html new file mode 100644 index 0000000..b837fd9 --- /dev/null +++ b/app/templates/widgets/pagination.html @@ -0,0 +1,23 @@ +{% macro paginate(objects, route, route_args) %} + +{% endmacro %}