refactor. pre-deploy
This commit is contained in:
@@ -10,15 +10,24 @@ from .views import (
|
||||
from rest_framework.routers import DefaultRouter
|
||||
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView
|
||||
|
||||
router = DefaultRouter()
|
||||
class NoTrailingSlashRouter(DefaultRouter):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.trailing_slash = '/?'
|
||||
|
||||
router = NoTrailingSlashRouter()
|
||||
router.register('links', LinkViewSet, basename='link')
|
||||
router.register('groups', LinkGroupViewSet, basename='group')
|
||||
|
||||
urlpatterns = [
|
||||
path('auth/register/', RegisterView.as_view(), name='auth_register'),
|
||||
path('auth/register', RegisterView.as_view(), name='auth_register_no_slash'),
|
||||
path('auth/login/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
|
||||
path('auth/login', TokenObtainPairView.as_view(), name='token_obtain_pair_no_slash'),
|
||||
path('auth/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
|
||||
path('auth/refresh', TokenRefreshView.as_view(), name='token_refresh_no_slash'),
|
||||
path('auth/user/', UserProfileView.as_view(), name='user-profile'), # ← новый
|
||||
path('auth/user', UserProfileView.as_view(), name='user-profile-no-slash'),
|
||||
path('users/<str:username>/public/',
|
||||
PublicUserGroupsView.as_view(),
|
||||
name='public-user-groups'
|
||||
|
||||
@@ -5,6 +5,8 @@ from rest_framework_simplejwt.views import TokenObtainPairView
|
||||
from rest_framework.views import APIView
|
||||
from rest_framework.response import Response
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.utils.decorators import method_decorator
|
||||
from drf_spectacular.utils import extend_schema, OpenApiParameter
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
@@ -25,6 +27,7 @@ class RegisterView(generics.CreateAPIView):
|
||||
serializer_class = RegisterSerializer
|
||||
|
||||
|
||||
@method_decorator(csrf_exempt, name='dispatch')
|
||||
class LoginView(TokenObtainPairView):
|
||||
permission_classes = [permissions.AllowAny]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user