[chore] Global project refactoring
This commit is contained in:
@@ -33,26 +33,21 @@ MIGRATING = len(sys.argv) > 1 and (
|
||||
)
|
||||
|
||||
|
||||
def register_debug_toolbar():
|
||||
INSTALLED_APPS.append("debug_toolbar")
|
||||
MIDDLEWARE.append("debug_toolbar.middleware.DebugToolbarMiddleware")
|
||||
|
||||
|
||||
INSTALLED_APPS = [
|
||||
# django apps
|
||||
# Built-in apps
|
||||
"django.contrib.admin",
|
||||
"django.contrib.auth",
|
||||
"django.contrib.contenttypes",
|
||||
"django.contrib.sessions",
|
||||
"django.contrib.messages",
|
||||
"django.contrib.staticfiles",
|
||||
# third party apps
|
||||
# Third-party apps
|
||||
"rest_framework",
|
||||
"rest_framework_simplejwt",
|
||||
"drf_yasg",
|
||||
# project apps
|
||||
"users.apps.UsersConfig",
|
||||
"notifications.apps.NotificationsConfig",
|
||||
# Developed apps
|
||||
"api.ping.apps.PingConfig",
|
||||
"api.users.apps.UsersConfig",
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
@@ -131,23 +126,33 @@ AUTH_PASSWORD_VALIDATORS = [
|
||||
},
|
||||
]
|
||||
|
||||
LANGUAGE_CODE = "ru-ru"
|
||||
LANGUAGE_CODE = "en-us"
|
||||
|
||||
TIME_ZONE = "UTC"
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
STATIC_URL = "static/"
|
||||
|
||||
STATIC_ROOT = BASE_DIR / "static"
|
||||
|
||||
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
||||
|
||||
AUTH_USER_MODEL = "users.User"
|
||||
|
||||
REST_FRAMEWORK = {
|
||||
"DEFAULT_AUTHENTICATION_CLASSES": [
|
||||
"rest_framework_simplejwt.authentication.JWTAuthentication",
|
||||
"DEFAULT_FILTER_BACKENDS": [
|
||||
"django_filters.rest_framework.DjangoFilterBackend"
|
||||
],
|
||||
"DEFAULT_AUTHENTICATION_CLASSES": (
|
||||
"api.users.authentication.JWTAuthentication",
|
||||
),
|
||||
}
|
||||
|
||||
APPEND_SLASH = False
|
||||
|
||||
if DEBUG and not (TESTING or MIGRATING):
|
||||
register_debug_toolbar()
|
||||
INSTALLED_APPS.append("debug_toolbar")
|
||||
MIDDLEWARE.append("debug_toolbar.middleware.DebugToolbarMiddleware")
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
import django.conf
|
||||
import django.contrib.admin
|
||||
import django.urls
|
||||
import rest_framework_simplejwt.views
|
||||
import users.views
|
||||
from django.conf import settings
|
||||
from django.contrib import admin
|
||||
from django.urls import include, path
|
||||
from drf_yasg import openapi
|
||||
from drf_yasg.views import get_schema_view
|
||||
from rest_framework import permissions, routers
|
||||
from users.views import UserViewSet
|
||||
|
||||
router = routers.DefaultRouter()
|
||||
router.register("users", UserViewSet)
|
||||
from rest_framework import permissions
|
||||
|
||||
schema_view = get_schema_view(
|
||||
openapi.Info(title="SkillHub API", default_version="v1"),
|
||||
@@ -20,6 +13,16 @@ schema_view = get_schema_view(
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
# Built-in urls
|
||||
path("admin/", admin.site.urls),
|
||||
path(
|
||||
"api-auth/",
|
||||
include(
|
||||
"rest_framework.urls",
|
||||
namespace="rest_framework",
|
||||
),
|
||||
),
|
||||
# API documentation
|
||||
path(
|
||||
"swagger<format>/",
|
||||
schema_view.without_ui(cache_timeout=0),
|
||||
@@ -35,34 +38,9 @@ urlpatterns = [
|
||||
schema_view.with_ui("redoc", cache_timeout=0),
|
||||
name="schema-redoc",
|
||||
),
|
||||
path("api/", include(router.urls)),
|
||||
path("api/registration/", users.views.RegisterView.as_view()),
|
||||
django.urls.path(
|
||||
"api/token/",
|
||||
rest_framework_simplejwt.views.TokenObtainPairView.as_view(),
|
||||
name="token_obtain_pair",
|
||||
),
|
||||
django.urls.path(
|
||||
"api/token/refresh/",
|
||||
rest_framework_simplejwt.views.TokenRefreshView.as_view(),
|
||||
name="token_refresh",
|
||||
),
|
||||
django.urls.path(
|
||||
"api/token/verify/",
|
||||
rest_framework_simplejwt.views.TokenVerifyView.as_view(),
|
||||
name="token_verify",
|
||||
),
|
||||
django.urls.path("admin/", django.contrib.admin.site.urls),
|
||||
# API
|
||||
path("api/", include("api.urls")),
|
||||
]
|
||||
|
||||
if django.conf.settings.DEBUG and not (
|
||||
django.conf.settings.TESTING or django.conf.settings.MIGRATING
|
||||
):
|
||||
import debug_toolbar
|
||||
|
||||
urlpatterns.append(
|
||||
django.urls.path(
|
||||
"__debug__/",
|
||||
django.urls.include(debug_toolbar.urls),
|
||||
),
|
||||
)
|
||||
if settings.DEBUG and not (settings.TESTING or settings.MIGRATING):
|
||||
urlpatterns += (path("__debug__/", include("debug_toolbar.urls")),)
|
||||
|
||||
Reference in New Issue
Block a user