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()