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.
108 lines
3.6 KiB
108 lines
3.6 KiB
"""
|
|
URL configuration for backend project.
|
|
|
|
The `urlpatterns` list routes URLs to views. For more information please see:
|
|
https://docs.djangoproject.com/en/5.0/topics/http/urls/
|
|
Examples:
|
|
Function views
|
|
1. Add an import: from my_app import views
|
|
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
|
Class-based views
|
|
1. Add an import: from other_app.views import Home
|
|
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
|
Including another URLconf
|
|
1. Import the include() function: from django.urls import include, path
|
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
|
"""
|
|
from django.contrib import admin
|
|
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 utils import UploadTmpMedia
|
|
from django.http import JsonResponse
|
|
from django.shortcuts import render
|
|
from django.views.decorators.csrf import csrf_exempt
|
|
from rest_framework.decorators import api_view
|
|
from rest_framework.response import Response
|
|
|
|
from utils import absolute_url
|
|
|
|
from utils.admin import project_admin_site, HomeView
|
|
|
|
from drf_yasg.views import get_schema_view
|
|
from drf_yasg import openapi
|
|
from rest_framework import permissions
|
|
import requests
|
|
from filer import views
|
|
schema_view = get_schema_view(
|
|
openapi.Info(
|
|
title="Snippets API",
|
|
default_version='v1',
|
|
description="Project API Documentation",
|
|
terms_of_service="https://www.google.com/policies/terms/",
|
|
contact=openapi.Contact(email="nwhco.com"),
|
|
license=openapi.License(name="BSD License"),
|
|
),
|
|
public=True,
|
|
permission_classes=(permissions.AllowAny,),
|
|
)
|
|
|
|
def oneapi_translate(request):
|
|
dist_lang = request.GET.get('dist_lang')
|
|
q = request.GET.get('q')
|
|
url = f"https://one-api.ir/translate/?token=169700:6485a38c34b00&action=google&lang={dist_lang}&q={q}"
|
|
try:
|
|
data = requests.get(url).json()
|
|
except Exception as e:
|
|
data = {}
|
|
|
|
return JsonResponse(data)
|
|
|
|
|
|
api_patterns = [
|
|
path('test/', include('apps.api.urls')),
|
|
|
|
path('account/', include('apps.account.urls')),
|
|
path('courses/', include('apps.course.urls')),
|
|
path('quiz/', include('apps.quiz.urls')),
|
|
path('transaction/', include('apps.transaction.urls')),
|
|
path('certificates/', include('apps.certificate.urls')),
|
|
path('hadis/', include('apps.hadis.urls')),
|
|
path('library/', include('apps.library.urls')),
|
|
path('videos/', include('apps.video.urls')),
|
|
path('bookmarks/', include('apps.bookmark.urls')),
|
|
|
|
path('settings/', include('dynamic_preferences.urls')),
|
|
|
|
path('upload-tmp-media/', UploadTmpMedia.as_view()),
|
|
|
|
]
|
|
|
|
|
|
urlpatterns = [
|
|
path("admin/", HomeView.as_view(), name="home"),
|
|
path("i18n/", include("django.conf.urls.i18n")),
|
|
|
|
# path('admin/', admin.site.urls),
|
|
path('api/', include(api_patterns)),
|
|
# path('test/', include('apps.api.urls'))
|
|
path('oneapi-translation/', oneapi_translate),
|
|
path('admin/filer/', include('filer.urls')),
|
|
|
|
]
|
|
urlpatterns+= i18n_patterns(
|
|
path("admin/", project_admin_site.urls),
|
|
re_path(r'^swagger(?P<format>\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'),
|
|
re_path(r'^swagger/$', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
|
|
re_path(r'^redoc/$', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
|
|
path('admin/filer/', include('filer.urls')),
|
|
)
|
|
|
|
if settings.DEBUG:
|
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
|
|
|
|
|
|
|
|
|
|