fix(urls): Use modern syntax

This commit is contained in:
Tom Hubrecht 2024-10-23 13:18:37 +02:00
parent eab76e9d0c
commit 0c35609496
Signed by: thubrecht
SSH key fingerprint: SHA256:r+nK/SIcWlJ0zFZJGHtlAoRwq1Rm+WcKAm5ADYMoQPc

View file

@ -1,20 +1,33 @@
from django.conf.urls import url from django.urls import path, register_converter
from . import views from . import views
class FourDigitYearConverter:
regex = "[0-9]{4}"
def to_python(self, value):
return int(value)
def to_url(self, value):
return "%04d" % value
register_converter(FourDigitYearConverter, "yyyy")
urlpatterns = [ urlpatterns = [
url(r"^$", views.HomeView.as_view(), name="homepage"), path("", views.HomeView.as_view(), name="homepage"),
url(r"^robots.txt$", views.robots_view, name="robots"), path("robots.txt", views.robots_view, name="robots"),
url(r"^ecrire$", views.WriteArticleView.as_view(), name="write_article"), path("ecrire/", views.WriteArticleView.as_view(), name="write_article"),
url( path(
r"^speciaux/", "speciaux/",
views.SpecialPublicationsView.as_view(), views.SpecialPublicationsView.as_view(),
name="special_publications", name="special_publications",
), ),
url( path(
r"^(?P<year>\d{4})-(?P<nYear>\d{4})/", "<yyyy:year>-<yyyy:nYear>/",
views.YearView.as_view(), views.YearView.as_view(),
name="year_view", name="year_view",
), ),
url(r"^latest$", views.latestPublication, name="latestPublication"), path("latest/", views.latestPublication, name="latestPublication"),
] ]