Skip to content

Commit 473a374

Browse files
committed
Move the api_docs_view to the view module #313
Signed-off-by: tdruez <[email protected]>
1 parent ef5a4ef commit 473a374

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

dejacode/urls.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,11 @@
1111
from django.contrib import admin
1212
from django.contrib.auth import views as auth_views
1313
from django.contrib.auth.decorators import login_required
14-
from django.template.loader import render_to_string
1514
from django.urls import path
1615
from django.views.defaults import page_not_found
1716
from django.views.generic import RedirectView
1817
from django.views.generic import TemplateView
1918

20-
from drf_yasg import openapi
21-
from drf_yasg.views import get_schema_view
2219
from notifications.views import mark_all_as_read
2320
from rest_framework.routers import DefaultRouter
2421

@@ -40,6 +37,7 @@
4037
from dje.views import GlobalSearchListView
4138
from dje.views import IntegrationsStatusView
4239
from dje.views import UnreadNotificationsList
40+
from dje.views import api_docs_view
4341
from dje.views import home_view
4442
from dje.views import index_dispatch
4543
from dje.views import urn_resolve_view
@@ -162,26 +160,11 @@
162160

163161
urlpatterns += [
164162
path("notifications/", include((notification_patterns, "notifications"))),
165-
]
166-
167-
urlpatterns += [
168163
path("purldb/", include(("purldb.urls", "purldb"))),
169164
]
170165

171-
api_docs_view = get_schema_view(
172-
openapi.Info(
173-
title="DejaCode REST API",
174-
default_version="v2",
175-
description=render_to_string(
176-
"rest_framework/docs/description.html",
177-
context={"site_url": settings.SITE_URL.rstrip("/")},
178-
),
179-
),
180-
public=False,
181-
)
182-
183166
api_docs_patterns = [
184-
path("", login_required(api_docs_view.with_ui("redoc", cache_timeout=0)), name="docs-index"),
167+
path("", login_required(api_docs_view.with_ui("redoc")), name="docs-index"),
185168
]
186169

187170
urlpatterns += [

dje/views.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
from django.shortcuts import redirect
5050
from django.shortcuts import render
5151
from django.template.defaultfilters import pluralize
52+
from django.template.loader import render_to_string
5253
from django.test import RequestFactory
5354
from django.urls import NoReverseMatch
5455
from django.urls import reverse
@@ -70,6 +71,8 @@
7071

7172
import django_otp
7273
from django_filters.views import FilterView
74+
from drf_yasg import openapi
75+
from drf_yasg.views import get_schema_view
7376
from grappelli.views.related import AutocompleteLookup
7477
from grappelli.views.related import RelatedLookup
7578
from notifications import views as notifications_views
@@ -2429,3 +2432,16 @@ def get(self, request, *args, **kwargs):
24292432
filename=filename,
24302433
content_type="application/json",
24312434
)
2435+
2436+
2437+
api_docs_view = get_schema_view(
2438+
openapi.Info(
2439+
title="DejaCode REST API",
2440+
default_version="v2",
2441+
description=render_to_string(
2442+
"rest_framework/docs/description.html",
2443+
context={"site_url": settings.SITE_URL.rstrip("/")},
2444+
),
2445+
),
2446+
public=False,
2447+
)

0 commit comments

Comments
 (0)