You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
2.3 KiB
62 lines
2.3 KiB
"""
|
|
URL configuration for Admin Subdomain (admin.imamjavad.nwhco.ir)
|
|
|
|
This handles all admin-related URLs and Swagger/Redoc when accessed via the admin subdomain.
|
|
"""
|
|
from django.urls import path, include, re_path
|
|
from django.conf import settings
|
|
from django.conf.urls.static import static
|
|
from django.conf.urls.i18n import i18n_patterns
|
|
|
|
from drf_yasg.views import get_schema_view
|
|
from drf_yasg import openapi
|
|
|
|
from utils.admin import project_admin_site, dovoodi_admin_site, HomeView
|
|
from apps.api.views import CustomAPIDocumentationView, CustomSwaggerView, SwaggerTokenAuthView, clear_swagger_auth
|
|
from apps.api.permissions import IsAdminOrSwaggerToken
|
|
from apps.api.decorators import swagger_auth_required
|
|
|
|
# Schema view for documentation
|
|
schema_view = get_schema_view(
|
|
openapi.Info(
|
|
title="Imam Javad API",
|
|
default_version='v1',
|
|
description="Comprehensive API documentation for the Imam Javad educational platform",
|
|
contact=openapi.Contact(email="contact@imamjavad.com"),
|
|
license=openapi.License(name="MIT License"),
|
|
),
|
|
public=False,
|
|
permission_classes=(IsAdminOrSwaggerToken,),
|
|
)
|
|
|
|
# Swagger URL patterns
|
|
swagger_urlpatterns = [
|
|
path('swagger-auth/', SwaggerTokenAuthView.as_view(), name='swagger-token-auth'),
|
|
path('swagger-auth/clear/', clear_swagger_auth, name='clear-swagger-auth'),
|
|
re_path(r'^swagger(?P<format>\.json|\.yaml)$',
|
|
swagger_auth_required(schema_view.without_ui(cache_timeout=0)),
|
|
name='schema-json'),
|
|
path('swagger/', CustomSwaggerView.as_view(), name='schema-swagger-ui'),
|
|
re_path(r'^redoc/$',
|
|
swagger_auth_required(schema_view.with_ui('redoc', cache_timeout=0)),
|
|
name='schema-redoc'),
|
|
]
|
|
|
|
urlpatterns = [
|
|
# Root redirect to admin
|
|
path("", HomeView.as_view(), name="home"),
|
|
path("i18n/", include("django.conf.urls.i18n")),
|
|
path('filer/', include('filer.urls')),
|
|
]
|
|
|
|
# i18n admin + swagger patterns
|
|
urlpatterns += i18n_patterns(
|
|
path("imam-javad/admin/", project_admin_site.urls),
|
|
path("dovoodi/admin/", dovoodi_admin_site.urls),
|
|
path('docs/', CustomAPIDocumentationView.as_view(), name='docs-index'),
|
|
*swagger_urlpatterns,
|
|
path('filer/', include('filer.urls')),
|
|
)
|
|
|
|
if settings.DEBUG:
|
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|