|
@@ -1,31 +1,34 @@
|
|
-"""
|
|
|
|
-Django settings for store_back project.
|
|
|
|
|
|
|
|
-Generated by 'django-admin startproject' using Django 4.0.4.
|
|
|
|
|
|
|
|
-For more information on this file, see
|
|
|
|
-https://docs.djangoproject.com/en/4.0/topics/settings/
|
|
|
|
|
|
+import os,sys
|
|
|
|
+from datetime import timedelta
|
|
|
|
|
|
-For the full list of settings and their values, see
|
|
|
|
-https://docs.djangoproject.com/en/4.0/ref/settings/
|
|
|
|
-"""
|
|
|
|
|
|
+# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
|
|
|
+BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
+PROJECT_ROOT = os.path.dirname(__file__)
|
|
|
|
+sys.path.insert(0,os.path.join(PROJECT_ROOT,'apps'))
|
|
|
|
|
|
-from pathlib import Path
|
|
|
|
|
|
+AUTH_USER_MODEL = 'authAPI.CustomUser'
|
|
|
|
|
|
-# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
|
|
-BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
|
|
|
+try:
|
|
|
|
+ if os.environ['debug'] == 'False':
|
|
|
|
+ DEBUG = False
|
|
|
|
+ else:
|
|
|
|
+ DEBUG = True
|
|
|
|
+except:
|
|
|
|
+ DEBUG = True
|
|
|
|
|
|
|
|
|
|
-# Quick-start development settings - unsuitable for production
|
|
|
|
-# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
|
|
|
|
|
|
|
|
-# SECURITY WARNING: keep the secret key used in production secret!
|
|
|
|
-SECRET_KEY = 'django-insecure-@&mo#&9)pe=y_r#4i+teev4_u*_4p-#$6(z9gdtzzt0vw6mdw9'
|
|
|
|
|
|
|
|
-# SECURITY WARNING: don't run with debug turned on in production!
|
|
|
|
-DEBUG = True
|
|
|
|
-
|
|
|
|
-ALLOWED_HOSTS = []
|
|
|
|
|
|
+if DEBUG:
|
|
|
|
+ SECRET_KEY = 'django-insecure-e*vqkvk_c%y&(v-^isb_%uwxq#y4eun3xhf4al_5f_)&14e5f0'
|
|
|
|
+else:
|
|
|
|
+ try:
|
|
|
|
+ SECRET_KEY = os.environ["SECRET_KEY"]
|
|
|
|
+ except KeyError as e:
|
|
|
|
+ raise RuntimeError("Could not find a SECRET_KEY in environment") from e
|
|
|
|
+ from .prod import *
|
|
|
|
|
|
|
|
|
|
# Application definition
|
|
# Application definition
|
|
@@ -37,6 +40,11 @@ INSTALLED_APPS = [
|
|
'django.contrib.sessions',
|
|
'django.contrib.sessions',
|
|
'django.contrib.messages',
|
|
'django.contrib.messages',
|
|
'django.contrib.staticfiles',
|
|
'django.contrib.staticfiles',
|
|
|
|
+ 'rest_framework',
|
|
|
|
+ 'goods.apps.GoodsConfig',
|
|
|
|
+ 'authAPI.apps.AuthAPIConfig',
|
|
|
|
+ 'orders.apps.OrdersConfig',
|
|
|
|
+ 'categories.apps.CategoriesConfig',
|
|
]
|
|
]
|
|
|
|
|
|
MIDDLEWARE = [
|
|
MIDDLEWARE = [
|
|
@@ -70,20 +78,6 @@ TEMPLATES = [
|
|
WSGI_APPLICATION = 'store_back.wsgi.application'
|
|
WSGI_APPLICATION = 'store_back.wsgi.application'
|
|
|
|
|
|
|
|
|
|
-# Database
|
|
|
|
-# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
|
|
|
|
-
|
|
|
|
-DATABASES = {
|
|
|
|
- 'default': {
|
|
|
|
- 'ENGINE': 'django.db.backends.sqlite3',
|
|
|
|
- 'NAME': BASE_DIR / 'db.sqlite3',
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-# Password validation
|
|
|
|
-# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators
|
|
|
|
-
|
|
|
|
AUTH_PASSWORD_VALIDATORS = [
|
|
AUTH_PASSWORD_VALIDATORS = [
|
|
{
|
|
{
|
|
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
@@ -111,13 +105,75 @@ USE_I18N = True
|
|
|
|
|
|
USE_TZ = True
|
|
USE_TZ = True
|
|
|
|
|
|
|
|
+DATABASES = {
|
|
|
|
+ 'default': {
|
|
|
|
+ 'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
|
|
|
+ 'NAME': 'dfi11snf6cpamj',
|
|
|
|
+ 'USER' : 'qvkowaptdjfexz',
|
|
|
|
+ 'PASSWORD' : '3ef6f3a16c918da406cd2b388042a45080ff7f9dd10d5f9cc1df0ec0eca8ab7a',
|
|
|
|
+ 'HOST' : 'ec2-52-48-159-67.eu-west-1.compute.amazonaws.com',
|
|
|
|
+ 'PORT' : '5432',
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
# Static files (CSS, JavaScript, Images)
|
|
# https://docs.djangoproject.com/en/4.0/howto/static-files/
|
|
# https://docs.djangoproject.com/en/4.0/howto/static-files/
|
|
|
|
|
|
-STATIC_URL = 'static/'
|
|
|
|
|
|
+STATIC_ROOT = os.path.join(BASE_DIR, 'static')
|
|
|
|
+STATIC_URL = 'api/static/'
|
|
|
|
+
|
|
|
|
+MEDIA_ROOT = os.path.join(BASE_DIR, 'media').replace('\\', '/')
|
|
|
|
+MEDIA_URL = 'api/media/'
|
|
|
|
+
|
|
|
|
|
|
# Default primary key field type
|
|
# Default primary key field type
|
|
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
|
|
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
|
|
|
|
|
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+SIMPLE_JWT = {
|
|
|
|
+ 'ACCESS_TOKEN_LIFETIME': timedelta(days=30),
|
|
|
|
+ 'REFRESH_TOKEN_LIFETIME': timedelta(days=1),
|
|
|
|
+ 'ROTATE_REFRESH_TOKENS': False,
|
|
|
|
+ 'BLACKLIST_AFTER_ROTATION': False,
|
|
|
|
+ 'UPDATE_LAST_LOGIN': False,
|
|
|
|
+
|
|
|
|
+ 'ALGORITHM': 'HS256',
|
|
|
|
+ 'SIGNING_KEY': SECRET_KEY,
|
|
|
|
+ 'VERIFYING_KEY': None,
|
|
|
|
+ 'AUDIENCE': None,
|
|
|
|
+ 'ISSUER': None,
|
|
|
|
+ 'JWK_URL': None,
|
|
|
|
+ 'LEEWAY': 0,
|
|
|
|
+
|
|
|
|
+ 'AUTH_HEADER_TYPES': ('Bearer',),
|
|
|
|
+ 'AUTH_HEADER_NAME': 'HTTP_AUTHORIZATION',
|
|
|
|
+ 'USER_ID_FIELD': '_id',
|
|
|
|
+ 'USER_ID_CLAIM': 'user_id',
|
|
|
|
+ 'USER_AUTHENTICATION_RULE': 'rest_framework_simplejwt.authentication.default_user_authentication_rule',
|
|
|
|
+
|
|
|
|
+ 'AUTH_TOKEN_CLASSES': ('rest_framework_simplejwt.tokens.AccessToken',),
|
|
|
|
+ 'TOKEN_TYPE_CLAIM': 'token_type',
|
|
|
|
+ 'TOKEN_USER_CLASS': 'rest_framework_simplejwt.models.TokenUser',
|
|
|
|
+
|
|
|
|
+ 'JTI_CLAIM': 'jti',
|
|
|
|
+
|
|
|
|
+ 'SLIDING_TOKEN_REFRESH_EXP_CLAIM': 'refresh_exp',
|
|
|
|
+ 'SLIDING_TOKEN_LIFETIME': timedelta(minutes=5),
|
|
|
|
+ 'SLIDING_TOKEN_REFRESH_LIFETIME': timedelta(days=1),
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+REST_FRAMEWORK = {
|
|
|
|
+ 'DEFAULT_AUTHENTICATION_CLASSES': (
|
|
|
|
+ 'rest_framework_simplejwt.authentication.JWTAuthentication',
|
|
|
|
+ )
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|