Coverage for conf/urls/deprecations.py: 100%
6 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 06:14 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 06:14 +0000
1from django.urls import path, re_path
2from django.views.generic import RedirectView
4from api.utils.status_code_view import get_status_code_view
7discontinuation_message = {
8 "error": "Gone",
9 "reason": "This API endpoint has been discontinued.",
10}
12mappings = [
13 ("sources", "image-stats", "about-image"),
14 ("recommendations/images/<str:identifier>", "image-related", "related-images"),
15 ("oembed", "image-oembed", "oembed"),
16 ("thumbs/<str:identifier>", "image-thumb", "thumbs"),
17]
19urlpatterns = [
20 path(
21 source,
22 RedirectView.as_view(
23 pattern_name=dest, permanent=True, query_string=(source == "oembed")
24 ),
25 name=name,
26 )
27 for source, dest, name in mappings
28] + [
29 # Discontinued, return 410 Gone
30 re_path(
31 r"^link/",
32 get_status_code_view(discontinuation_message, 410).as_view(),
33 name="make-link",
34 ),
35]