Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/api/v1/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
TemplateViewSet,
FavTemplateAPIview,
FavDocumentAPIview,
RegisterView,
# RegisterView,
)
from django.urls import include, path, re_path
from rest_framework.routers import DefaultRouter
Expand Down Expand Up @@ -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")),
Expand Down
59 changes: 29 additions & 30 deletions backend/api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 (
Expand Down Expand Up @@ -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)
4 changes: 0 additions & 4 deletions backend/backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"django.contrib.messages",
"django.contrib.staticfiles",
"drf_yasg",
# "corsheaders",
"rest_framework",
"djoser",
"rest_framework.authtoken",
Expand Down Expand Up @@ -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

4 changes: 2 additions & 2 deletions backend/request/documents.http
Original file line number Diff line number Diff line change
@@ -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}}

Expand Down
7 changes: 3 additions & 4 deletions backend/request/template.http
Original file line number Diff line number Diff line change
@@ -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/
Expand Down
10 changes: 5 additions & 5 deletions backend/request/users.http
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -19,7 +19,7 @@ POST {{URL}}/api/auth/token/login/
Content-Type: application/json

{
"email": "nik3ox1e21@mail.ru",
"email": "nikox112@mail.ru",
"password": "456852Zx"
}

Expand Down
58 changes: 58 additions & 0 deletions qweю.json
Original file line number Diff line number Diff line change
@@ -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
}