diff --git a/scipost_django/SciPost_v1/urls.py b/scipost_django/SciPost_v1/urls.py index 4eff807f97fa5318ab5e14210f9c884602bb6e8a..4cd2072104d4c58d6627e793d29956e3ea0c5b06 100644 --- a/scipost_django/SciPost_v1/urls.py +++ b/scipost_django/SciPost_v1/urls.py @@ -17,6 +17,7 @@ from comments.converters import ( CommentDOILabelConverter, AuthorReplyDOILabelConverter ) from common.converters import ( + UnicodeSlugConverter, FourDigitYearConverter, TwoDigitMonthConverter, TwoDigitDayConverter ) from journals.converters import ( @@ -45,6 +46,7 @@ register_converter(CollegeSlugConverter, 'college') register_converter(CommentDOILabelConverter, 'comment_doi_label') register_converter(AuthorReplyDOILabelConverter, 'author_reply_doi_label') # common +register_converter(UnicodeSlugConverter, 'slug') register_converter(FourDigitYearConverter, 'YYYY') register_converter(TwoDigitMonthConverter, 'MM') register_converter(TwoDigitDayConverter, 'DD') diff --git a/scipost_django/common/converters.py b/scipost_django/common/converters.py index 50f0767ed10f2a08c28e21fd27713393206ff6f3..76a8a94c268bb35644fa86a89147aba5d4d00362 100644 --- a/scipost_django/common/converters.py +++ b/scipost_django/common/converters.py @@ -2,6 +2,13 @@ __copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)" __license__ = "AGPL v3" +from django.urls.converters import StringConverter + + +class UnicodeSlugConverter(StringConverter): + regex = '[-\w_]+' + + class FourDigitYearConverter: regex = '[0-9]{4}'