forked from djangopackages/djangopackages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
urls.py
129 lines (120 loc) · 4.73 KB
/
urls.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.contrib.sitemaps import views as sitemap_views
from django.urls import include, path, re_path
from django.views.decorators.cache import cache_page
from django.views.generic.base import TemplateView
from blog.sitemaps import BlogSitemap
from core import __version__
from core.apiv1 import apiv1_gone
from core.sitemaps import StaticViewSitemap
from grid.sitemaps import GridSitemap
from homepage.views import error_404_view
from homepage.views import error_500_view
from homepage.views import error_503_view
from homepage.views import health_check_view
from homepage.views import homepage
from homepage.views import OpenView
from homepage.views import ReadinessDetailView
from homepage.views import ReadinessView
from package.sitemaps import PackageSitemap
from package.views import PackageByCategoryListView, PackagePython3ListView
from profiles.views import LogoutView
admin_header = f"Django Packages v{__version__}"
admin.site.enable_nav_sidebar = False # disabled until Django 3.x
admin.site.site_header = admin_header
admin.site.site_title = admin_header
SITEMAPS_CACHE_TTL = 12 * 60 * 60 # 12 Hours
sitemaps = {
"static": StaticViewSitemap,
"packages": PackageSitemap,
"grids": GridSitemap,
"blog": BlogSitemap,
}
urlpatterns = [
# url(r'^login/\{\{item\.absolute_url\}\}/', RedirectView.as_view(url="/login/github/")),
path("auth/", include("social_django.urls", namespace="social")),
# url('', include('social_auth.urls')),
path("", homepage, name="home"),
path(
"robots.txt",
TemplateView.as_view(content_type="text/plain", template_name="robots.txt"),
name="robots_txt",
),
path("health_check/", health_check_view, name="health_check"),
path("404", error_404_view, name="404"),
path("500", error_500_view, name="500"),
path("503", error_503_view, name="503"),
re_path(settings.ADMIN_URL_BASE, admin.site.urls),
path("changelog/", include("blog.urls")),
path("profiles/", include("profiles.urls")),
path("packages/", include("package.urls")),
path("grids/", include("grid.urls")),
path("feeds/", include("feeds.urls")),
path(
"categories/<slug:slug>/", PackageByCategoryListView.as_view(), name="category"
),
path("categories/", homepage, name="categories"),
path("python3/", PackagePython3ListView.as_view(), name="py3_compat"),
# url(regex=r'^login/$', view=TemplateView.as_view(template_name='pages/login.html'), name='login',),
path("logout/", LogoutView.as_view(), name="logout"),
# static pages
path("about/", TemplateView.as_view(template_name="pages/faq.html"), name="about"),
path(
"terms/", TemplateView.as_view(template_name="pages/terms.html"), name="terms"
),
path("faq/", TemplateView.as_view(template_name="pages/faq.html"), name="faq"),
path(
"stack/", TemplateView.as_view(template_name="pages/stack.html"), name="stack"
),
path("open/", OpenView.as_view(), name="open"),
path("readiness/", ReadinessView.as_view(), name="readiness"),
path(
"readiness/<slug:product_slug>/<str:cycle>/",
ReadinessDetailView.as_view(),
name="readiness_detail",
),
path(
"syndication/",
TemplateView.as_view(template_name="pages/syndication.html"),
name="syndication",
),
path("help/", TemplateView.as_view(template_name="pages/help.html"), name="help"),
path(
"funding/",
TemplateView.as_view(template_name="pages/funding.html"),
name="funding",
),
path(
"sitemap.xml",
cache_page(SITEMAPS_CACHE_TTL)(sitemap_views.index),
{"sitemaps": sitemaps, "sitemap_url_name": "sitemaps"},
name="sitemap_index",
),
path(
"sitemap-<section>.xml",
cache_page(SITEMAPS_CACHE_TTL)(sitemap_views.sitemap),
{"sitemaps": sitemaps},
name="sitemaps",
),
path("maintenance-mode/", include("maintenance_mode.urls")),
# new apps
path("search/", include("searchv2.urls")),
path("favorites/", include("favorites.urls")),
# apiv3
path("api/v3/", include("apiv3.urls", namespace="apiv3")),
# apiv4
path("api/v4/", include("apiv4.urls", namespace="apiv4")),
path("api-auth/", include("rest_framework.urls", namespace="rest_framework")),
re_path(
r"^api/v1/.*$",
view=apiv1_gone,
name="apiv1_gone",
),
# url(r'^api/v1/', include('core.apiv1', namespace="apitest")),
]
if settings.DEBUG and not settings.TEST_MODE:
import debug_toolbar
urlpatterns.append(path("__debug__/", include(debug_toolbar.urls)))
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)