Amélioration des slugs (utilisation de python-slugify)
This commit is contained in:
parent
b5e875e136
commit
1434b3152b
|
@ -16,4 +16,5 @@ python-ldap
|
|||
python-uwsgi
|
||||
python-psycopg2
|
||||
python-pyyaml
|
||||
python-slugify
|
||||
```
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue