From dab99b17cf8f4dde05a444159518d99dc723b0dd Mon Sep 17 00:00:00 2001 From: keannu125 Date: Tue, 28 Feb 2023 22:16:45 +0800 Subject: [PATCH] Added accounts --- Pipfile | 1 + Pipfile.lock | 4 ++-- ivy/accounts/__init__.py | 0 ivy/accounts/admin.py | 3 +++ ivy/accounts/apps.py | 6 ++++++ ivy/accounts/migrations/__init__.py | 0 ivy/accounts/models.py | 3 +++ ivy/accounts/tests.py | 3 +++ ivy/accounts/urls.py | 7 +++++++ ivy/accounts/views.py | 3 +++ ivy/api/urls.py | 2 +- ivy/config/settings.py | 19 ++++++++++++++++++- 12 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 ivy/accounts/__init__.py create mode 100644 ivy/accounts/admin.py create mode 100644 ivy/accounts/apps.py create mode 100644 ivy/accounts/migrations/__init__.py create mode 100644 ivy/accounts/models.py create mode 100644 ivy/accounts/tests.py create mode 100644 ivy/accounts/urls.py create mode 100644 ivy/accounts/views.py diff --git a/Pipfile b/Pipfile index 432ec5b..8faada7 100644 --- a/Pipfile +++ b/Pipfile @@ -7,6 +7,7 @@ name = "pypi" django = "*" djangorestframework = "*" djoser = "*" +djangorestframework-simplejwt = "*" [dev-packages] autopep8 = "*" diff --git a/Pipfile.lock b/Pipfile.lock index 372c85f..eb12124 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "61283271cb703ae19a49d5f7e87bf45e11f8f8528f976137f957d2912347dceb" + "sha256": "309b0b7b7b2f3dce9f8501a57dac5257ba3cca7d8e01cfc7284aa6c48279b23b" }, "pipfile-spec": 6, "requires": { @@ -273,7 +273,7 @@ "sha256:153c973c5c154baf566be431de8527c2bd62557fde7373ebcb0f02b73b28e07a", "sha256:6f09f97cb015265e85d1d02dc6bfc299c72c231eecbe261c5bee5c6b2867f2b4" ], - "markers": "python_version >= '3.7'", + "index": "pypi", "version": "==4.8.0" }, "djoser": { diff --git a/ivy/accounts/__init__.py b/ivy/accounts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ivy/accounts/admin.py b/ivy/accounts/admin.py new file mode 100644 index 0000000..ea5d68b --- /dev/null +++ b/ivy/accounts/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/ivy/accounts/apps.py b/ivy/accounts/apps.py new file mode 100644 index 0000000..d69d316 --- /dev/null +++ b/ivy/accounts/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class AccountsConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'accounts' diff --git a/ivy/accounts/migrations/__init__.py b/ivy/accounts/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ivy/accounts/models.py b/ivy/accounts/models.py new file mode 100644 index 0000000..fd18c6e --- /dev/null +++ b/ivy/accounts/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/ivy/accounts/tests.py b/ivy/accounts/tests.py new file mode 100644 index 0000000..de8bdc0 --- /dev/null +++ b/ivy/accounts/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/ivy/accounts/urls.py b/ivy/accounts/urls.py new file mode 100644 index 0000000..1f37290 --- /dev/null +++ b/ivy/accounts/urls.py @@ -0,0 +1,7 @@ +from django.contrib import admin +from django.urls import path, include + +urlpatterns = [ + path('', include('djoser.urls')), + path('', include('djoser.urls.authtoken')) +] diff --git a/ivy/accounts/views.py b/ivy/accounts/views.py new file mode 100644 index 0000000..c60c790 --- /dev/null +++ b/ivy/accounts/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/ivy/api/urls.py b/ivy/api/urls.py index c99a589..b296cca 100644 --- a/ivy/api/urls.py +++ b/ivy/api/urls.py @@ -2,5 +2,5 @@ from django.contrib import admin from django.urls import path, include urlpatterns = [ - path('', include('djoser.urls')) + path('accounts/', include('accounts.urls')) ] diff --git a/ivy/config/settings.py b/ivy/config/settings.py index ca36373..5da41fe 100644 --- a/ivy/config/settings.py +++ b/ivy/config/settings.py @@ -38,8 +38,8 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', + 'rest_framework.authtoken', 'djoser', - 'api', ] MIDDLEWARE = [ @@ -124,3 +124,20 @@ STATIC_URL = 'static/' # https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' + +REST_FRAMEWORK = { + 'DEFAULT_AUTHENTICATION_CLASSES': ( + 'rest_framework.authentication.TokenAuthentication', + ) +} + +DJOSER = { + 'SEND_ACTIVATION_EMAIL': True, + 'SEND_CONFIRMATION_EMAIL': True, + 'ACTIVATION_URL': 'activation/{uid}/{token}', +} + +EMAIL_HOST = 'sandbox.smtp.mailtrap.io' +EMAIL_HOST_USER = '54ff6949e39105' +EMAIL_HOST_PASSWORD = 'c59d3eaa05f98d' +EMAIL_PORT = '2525'