Amélioration des slugs (utilisation de python-slugify)

This commit is contained in:
Darks 2019-12-03 21:03:23 +01:00
parent b5e875e136
commit 1434b3152b
Signed by: Darks
GPG Key ID: F61F10FA138E797C
2 changed files with 3 additions and 1 deletions

View File

@ -16,4 +16,5 @@ python-ldap
python-uwsgi
python-psycopg2
python-pyyaml
python-slugify
```

View File

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