2023-08-17 03:57:46 +00:00
|
|
|
# global settings and live production settings
|
|
|
|
|
|
|
|
from pathlib import Path
|
|
|
|
import os
|
|
|
|
|
|
|
|
import environ
|
|
|
|
env = environ.Env()
|
|
|
|
environ.Env.read_env()
|
|
|
|
|
|
|
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
|
|
|
|
|
# set to False for production
|
2023-08-17 05:00:32 +00:00
|
|
|
DEBUG = env('DEV_MODE')
|
2023-08-17 03:57:46 +00:00
|
|
|
|
|
|
|
# SECURE_SSL_REDIRECT=True
|
|
|
|
# SESSION_COOKIE_SECURE=True
|
|
|
|
# CSRF_COOKIE_SECURE=True
|
|
|
|
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
|
|
SECRET_KEY = env('SECRET_KEY')
|
|
|
|
|
|
|
|
'''
|
|
|
|
TODO: set these when testing payments
|
|
|
|
|
|
|
|
# get stripe endpoint's webhook secret by running `stripe listen` in CLI
|
|
|
|
# STRIPE_WEBHOOK_SECRET = env("STRIPE_WEBHOOK_SECRET")
|
|
|
|
|
|
|
|
# stripe data
|
|
|
|
# STRIPE_PK = env("STRIPEPK")
|
|
|
|
# STRIPE_SK = env("STRIPESK")
|
|
|
|
# STRIPE_DOMAIN = env("STRIPE_DOMAIN")
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
# add server ips
|
|
|
|
ALLOWED_HOSTS = ['localhost', '127.0.0.1']
|
|
|
|
|
|
|
|
|
|
|
|
# rest framework global settings
|
|
|
|
# authentication classes: https://www.django-rest-framework.org/api-guide/settings/#default_authentication_classes
|
|
|
|
REST_FRAMEWORK = {
|
|
|
|
'DEFAULT_AUTHENTICATION_CLASSES': (
|
|
|
|
'rest_framework.authentication.TokenAuthentication',
|
|
|
|
),
|
|
|
|
# permission policy: https://www.django-rest-framework.org/api-guide/permissions/#setting-the-permission-policy
|
|
|
|
# can override these in views. Don't forget to add a comma
|
|
|
|
'DEFAULT_PERMISSION_CLASSES': (
|
|
|
|
# allow anyone to access api data
|
|
|
|
# 'rest_framework.permissions.AllowAny',
|
|
|
|
# do not allow anyone to access API endpoints unless user is authenticated
|
|
|
|
# 'rest_framework.permissions.IsAuthenticated',
|
|
|
|
# allow full access to authenticated users, but allow read-only access to unauthenticated users
|
|
|
|
'rest_framework.permissions.IsAuthenticatedOrReadOnly',
|
|
|
|
),
|
|
|
|
'DEFAULT_RENDERER_CLASSES': (
|
|
|
|
'rest_framework.renderers.JSONRenderer', # makes api views JSON data only
|
|
|
|
),
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Application definition
|
|
|
|
|
|
|
|
INSTALLED_APPS = [
|
|
|
|
'django.contrib.admin',
|
|
|
|
'django.contrib.auth',
|
|
|
|
'django.contrib.contenttypes',
|
|
|
|
'django.contrib.sessions',
|
|
|
|
'django.contrib.messages',
|
|
|
|
'django.contrib.staticfiles',
|
|
|
|
# DRF dependencies
|
|
|
|
'rest_framework',
|
|
|
|
'rest_framework.authtoken',
|
|
|
|
'corsheaders',
|
|
|
|
# djoser is a REST implementation of Django authentication system. Provides token based authentication
|
|
|
|
'djoser',
|
|
|
|
# Django image processing
|
|
|
|
'imagekit',
|
|
|
|
# custom user model
|
|
|
|
'users_app',
|
|
|
|
]
|
|
|
|
|
|
|
|
# set custom user model (appname.model name) to prevent Django from using
|
|
|
|
# its default model
|
|
|
|
AUTH_USER_MODEL = 'users_app.Users'
|
|
|
|
|
|
|
|
|
|
|
|
# add custom backend, if it fails, Django will use default backend
|
|
|
|
AUTHENTICATION_BACKENDS = [
|
|
|
|
'users_app.custom_backend.Custom_Backend',
|
|
|
|
]
|
|
|
|
|
|
|
|
MIDDLEWARE = [
|
|
|
|
'django.middleware.security.SecurityMiddleware',
|
|
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
|
|
'corsheaders.middleware.CorsMiddleware', # this has to go above CommonMiddleware
|
|
|
|
'django.middleware.common.CommonMiddleware',
|
|
|
|
'django.middleware.csrf.CsrfViewMiddleware',
|
|
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
|
|
'django.contrib.messages.middleware.MessageMiddleware',
|
|
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
# change to whatever hostname react-native runs on
|
|
|
|
# CORS_ALLOWED_ORIGINS = [
|
|
|
|
# "http://127.0.0.1:8080",
|
|
|
|
# "http://localhost:8080",
|
|
|
|
# "https://sheriffcrandymusic.local:9443",
|
|
|
|
# "https://sheriffcrandymusic.com"
|
|
|
|
# ]
|
|
|
|
|
|
|
|
ROOT_URLCONF = 'main_project.urls'
|
|
|
|
|
|
|
|
TEMPLATES = [
|
|
|
|
{
|
|
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
|
|
'DIRS': [os.path.join(BASE_DIR,'templates')],
|
|
|
|
'APP_DIRS': True,
|
|
|
|
'OPTIONS': {
|
|
|
|
'context_processors': [
|
|
|
|
'django.template.context_processors.debug',
|
|
|
|
'django.template.context_processors.request',
|
|
|
|
'django.contrib.auth.context_processors.auth',
|
|
|
|
'django.contrib.messages.context_processors.messages',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
WSGI_APPLICATION = 'main_project.wsgi.application'
|
|
|
|
|
|
|
|
|
|
|
|
# Database
|
|
|
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
|
|
|
|
|
|
|
|
# PostgreSQL config
|
|
|
|
DATABASES = {
|
|
|
|
'default': {
|
|
|
|
# postgresql
|
|
|
|
'ENGINE': env('DBENGINE'),
|
|
|
|
# name of database
|
|
|
|
'NAME': env('DBNAME'),
|
|
|
|
# owner of database
|
|
|
|
'USER': env('DBUSER'),
|
|
|
|
'PASSWORD': env('DBPASSWORD'),
|
|
|
|
# specify which machine where db is installed
|
|
|
|
# connect through TCP sockets,
|
|
|
|
'HOST': env('DBHOST')
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Password validation. Turning this off, handling custom password validation manually
|
|
|
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
|
|
|
|
'''
|
|
|
|
AUTH_PASSWORD_VALIDATORS = [
|
|
|
|
{
|
|
|
|
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
|
|
},
|
|
|
|
]
|
|
|
|
'''
|
|
|
|
|
|
|
|
# Internationalization
|
|
|
|
# https://docs.djangoproject.com/en/4.2/topics/i18n/
|
|
|
|
|
|
|
|
LANGUAGE_CODE = 'en-us'
|
|
|
|
|
|
|
|
TIME_ZONE = 'UTC'
|
|
|
|
|
|
|
|
USE_I18N = True
|
|
|
|
|
|
|
|
USE_TZ = True
|
|
|
|
|
|
|
|
'''
|
|
|
|
# allow python to send emails
|
|
|
|
# Simple Mail Transfer Protocol SMPT config
|
|
|
|
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
|
|
|
|
EMAIL_HOST = env('EMAIL_HOST')
|
|
|
|
EMAIL_PORT = env('EMAIL_PORT')
|
|
|
|
EMAIL_USE_TLS = True
|
|
|
|
# email address that sends emails
|
|
|
|
EMAIL_HOST_USER = env('EMAIL_HOST_USER')
|
|
|
|
# EMAIL_HOST_PASSWORD generated by Google. First you have to enable 2-step verification
|
|
|
|
# Go to Google-> manage Google account -> Security -> Sigining in to Google -> App passwords ->
|
|
|
|
# if you can't find app passwords. Search for it in the searchbar above
|
|
|
|
# click select app and choose Mail or Other -> select device name (make a custom name) -> generate -> get password and put it in .env file
|
|
|
|
EMAIL_HOST_PASSWORD = env('EMAIL_HOST_PASSWORD')
|
|
|
|
|
|
|
|
EMAIL_ACTIVE_FIELD = 'is_active'
|
|
|
|
'''
|
|
|
|
|
|
|
|
# URL to use when referring to static files located in STATIC_ROOT.
|
|
|
|
# manually add this folder to the parent (backend) dir
|
|
|
|
STATIC_URL = '/static/'
|
|
|
|
|
|
|
|
STATICFILES_DIRS = [
|
|
|
|
os.path.join(BASE_DIR, 'static'),
|
|
|
|
]
|
|
|
|
STATIC_ROOT = os.path.join(BASE_DIR,'staticfiles')
|
|
|
|
# media dir for files. This dir is created when the first model objects are created (either through admin page or otherwise)
|
|
|
|
MEDIA_URL = '/media/'
|
|
|
|
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
|
|
|
|
|
|
|
|
|
|
|
|
# Default primary key field type
|
|
|
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
|
|
|
|
|
|
|
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
|
|
|
|
|
|
|
# receive error details of exceptions raised in the request/response cycle.
|
|
|
|
# https://docs.djangoproject.com/en/4.1/ref/settings/#std-setting-ADMINS
|
|
|
|
# ADMINS = [('name', 'email')]
|
|
|
|
|
|
|
|
# managers get broken link notifications
|
|
|
|
# MANAGERS = [('name', 'email')]
|