From 1434b3152bf6afdcc625c4b02971b90bf45e863d Mon Sep 17 00:00:00 2001 From: Darks Date: Tue, 3 Dec 2019 21:03:23 +0100 Subject: [PATCH] =?UTF-8?q?Am=C3=A9lioration=20des=20slugs=20(utilisation?= =?UTF-8?q?=20de=20python-slugify)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- REQUIREMENTS.md | 1 + app/utils/converters.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/REQUIREMENTS.md b/REQUIREMENTS.md index bcf94c9..0225ec2 100644 --- a/REQUIREMENTS.md +++ b/REQUIREMENTS.md @@ -16,4 +16,5 @@ python-ldap python-uwsgi python-psycopg2 python-pyyaml +python-slugify ``` diff --git a/app/utils/converters.py b/app/utils/converters.py index eb5bf3a..7344487 100644 --- a/app/utils/converters.py +++ b/app/utils/converters.py @@ -19,6 +19,7 @@ For more information, see the Werkzeug documentation: from werkzeug.routing import BaseConverter, ValidationError from app.models.forum import Forum from app.models.topic import Topic +from slugify import slugify import re import sys @@ -52,7 +53,7 @@ class TopicSlugConverter(BaseConverter): return Topic.query.get_or_404(int(m[1], 10)) def to_url(self, topic): - return str(topic.id) + return f'{topic.id}-{slugify(topic.title)}' # Export only the converter classes __all__ = "ForumConverter TopicSlugConverter".split()