diff --git a/backend/api/v1/urls.py b/backend/api/v1/urls.py index e63462f..d8861ea 100644 --- a/backend/api/v1/urls.py +++ b/backend/api/v1/urls.py @@ -6,7 +6,7 @@ TemplateViewSet, FavTemplateAPIview, FavDocumentAPIview, - RegisterView, + # RegisterView, ) from django.urls import include, path, re_path from rest_framework.routers import DefaultRouter @@ -52,7 +52,7 @@ AnonymousDownloadPreviewAPIView.as_view(), name="download_preview", ), - path("users/", RegisterView.as_view(), name="register"), + # path("users/", RegisterView.as_view(), name="register"), path("", include(router_v1.urls)), path("", include("djoser.urls")), path("auth/", include("djoser.urls.authtoken")), diff --git a/backend/api/v1/views.py b/backend/api/v1/views.py index d89ee29..4d88fb4 100644 --- a/backend/api/v1/views.py +++ b/backend/api/v1/views.py @@ -20,12 +20,11 @@ from rest_framework.permissions import AllowAny, IsAuthenticated from rest_framework.response import Response from rest_framework.views import APIView -from rest_framework_simplejwt.tokens import RefreshToken from api.v1.permissions import IsOwner, IsOwnerOrAdminOrReadOnly from api.v1.serializers import ( CategorySerializer, - CustomUserSerializer, + DocumentFieldForPreviewSerializer, DocumentFieldSerializer, DocumentReadSerializer, @@ -36,7 +35,7 @@ TemplateSerializer, TemplateSerializerMinified, ) -from api.v1.utils import Util +# from api.v1.utils import Util from core.constants import Messages from core.template_render import DocumentTemplate from documents.models import ( @@ -367,30 +366,30 @@ def post(self, request, template_id): return response -class RegisterView(generics.GenericAPIView): - serializer_class = CustomUserSerializer - - def post(self, request): - user = request.data - serializer = self.serializer_class(data=user) - serializer.is_valid(raise_exception=True) - serializer.save() - user_data = serializer.data - user = User.objects.get(email=user_data["email"]) - token = RefreshToken.for_user(user).access_token - - absurl = "https://documents-template.site/" + "?token=" + str(token) - email_body = ( - "Hi " - + user.username - + " Use the link below to verify your email \n" - + absurl - ) - data = { - "email_body": email_body, - "to_email": user.email, - "email_subject": "Verify your email", - } - - Util.send_email(data) - return Response(user_data, status=status.HTTP_201_CREATED) +# class RegisterView(generics.GenericAPIView): +# serializer_class = CustomUserSerializer + +# def post(self, request): +# user = request.data +# serializer = self.serializer_class(data=user) +# serializer.is_valid(raise_exception=True) +# serializer.save() +# user_data = serializer.data +# user = User.objects.get(email=user_data["email"]) +# token = RefreshToken.for_user(user).access_token + +# absurl = "https://documents-template.site/" + "?token=" + str(token) +# email_body = ( +# "Hi " +# + user.username +# + " Use the link below to verify your email \n" +# + absurl +# ) +# data = { +# "email_body": email_body, +# "to_email": user.email, +# "email_subject": "Verify your email", +# } + +# Util.send_email(data) +# return Response(user_data, status=status.HTTP_201_CREATED) diff --git a/backend/backend/settings.py b/backend/backend/settings.py index 5350ecd..3dbc708 100644 --- a/backend/backend/settings.py +++ b/backend/backend/settings.py @@ -23,7 +23,6 @@ "django.contrib.messages", "django.contrib.staticfiles", "drf_yasg", - # "corsheaders", "rest_framework", "djoser", "rest_framework.authtoken", @@ -173,6 +172,3 @@ }, "BASE_PATH": "https://documents-template.site/api/", } - -# CORS_ALLOW_ALL_ORIGINS = True # If this is used then `CORS_ALLOWED_ORIGINS` will not have any effect - diff --git a/backend/request/documents.http b/backend/request/documents.http index f992c23..32ec0d5 100644 --- a/backend/request/documents.http +++ b/backend/request/documents.http @@ -1,8 +1,8 @@ -@TOKEN = Token 77435c1657026635eda41cb962fb9d39d4054e17 +@TOKEN = Token bb4f5dbedaafd2730f35803e7087e797479d68f5 @URL = https://documents-template.site/ ### -GET {{URL}}/api/documents/ +GET {{URL}}/api/documents/32/ Content-Type: application/json Authorization: {{TOKEN}} diff --git a/backend/request/template.http b/backend/request/template.http index d6d65d2..46c00cf 100644 --- a/backend/request/template.http +++ b/backend/request/template.http @@ -1,8 +1,7 @@ -@TOKEN = Token 991672cea059f046c5f893b70548e1cef7a2c987 +@TOKEN = Token 640063c217c9693de37f04d65249f35a19705efb +# @URL = https://documents-template.site/ +@URL = http://localhost:8000 -@URL = https://documents-template.site/ -# @URL = http://localhost:8000/ -# @TOKEN = Token 77435c1657026635eda41cb962fb9d39d4054e17 ### Все шаблоны GET {{URL}}/api/templates/ diff --git a/backend/request/users.http b/backend/request/users.http index fdd10de..e41207b 100644 --- a/backend/request/users.http +++ b/backend/request/users.http @@ -1,14 +1,14 @@ @TOKEN = Token b5b767cb36da725f900892f627a28dc1c0e40488 -@URL = https://documents-template.site/ -# @URL = http://127.0.0.1:8000 +# @URL = https://documents-template.site/ +@URL = http://127.0.0.1:8000 ### POST {{URL}}/api/users/ Content-Type: application/json { - "email": "nikox12@mail.ru", - "username": "nikox122@mail.ru", + "email": "nikox112@mail.ru", + "username": "nikox1122@mail.ru", "password": "456852Zx", "first_name": "kewk", "last_name": "wsq" @@ -19,7 +19,7 @@ POST {{URL}}/api/auth/token/login/ Content-Type: application/json { - "email": "nik3ox1e21@mail.ru", + "email": "nikox112@mail.ru", "password": "456852Zx" } diff --git "a/qwe\321\216.json" "b/qwe\321\216.json" new file mode 100644 index 0000000..acaf910 --- /dev/null +++ "b/qwe\321\216.json" @@ -0,0 +1,58 @@ +{ + "id": 1, + "is_favorited": false, + "groups_fields": [ + { + "group_id": 1, + "group_name": "Ребенок", + "fields": [ + { + "id": 1, + "name": "Чебурашка", + "hint": "Олень", + "type": "fio", + "lenth": 100, + "mask": "" + }, + { + "id": 52, + "name": "Олег", + "hint": "жменька", + "type": "fio", + "lenth": 100, + "mask": "" + } + + ] + }, + { + "group_id": "", + "group_name": "No_group", + "fields": [ + { + "id": 13, + "name": "Чейцйцбурашка", + "hint": "Олейцйцнь", + "type": "fйцйцio", + "lenth": 100, + "mask": "" + }, + { + "id": 5112, + "name": "Олчясясег", + "hint": "жмячсясенька", + "type": "fiячсясo", + "lenth": 100, + "mask": "" + } + + ] + } + ], + "name": "Заявление в детский сад", + "modified": "2023-10-18", + "deleted": false, + "description": "Данный шаблон необходим для заполнения заявления в детский сад. Заявление может быть составлено в простой письменной форме. Можно доработать шаблон под себя и прописать наиболее важные поля после его скачивания.", + "owner": null, + "category": null +} \ No newline at end of file