2023-06-26 18:58:20 +08:00
|
|
|
"""
|
|
|
|
Django settings for stude project.
|
|
|
|
|
|
|
|
Generated by 'django-admin startproject' using Django 4.2.2.
|
|
|
|
|
|
|
|
For more information on this file, see
|
|
|
|
https://docs.djangoproject.com/en/4.2/topics/settings/
|
|
|
|
|
|
|
|
For the full list of settings and their values, see
|
|
|
|
https://docs.djangoproject.com/en/4.2/ref/settings/
|
|
|
|
"""
|
|
|
|
|
|
|
|
from pathlib import Path
|
|
|
|
from dotenv import load_dotenv # Python dotenv
|
|
|
|
import os
|
|
|
|
|
2023-07-09 17:30:00 +08:00
|
|
|
|
2023-06-26 18:58:20 +08:00
|
|
|
load_dotenv() # loads the configs from .env
|
|
|
|
|
|
|
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
|
|
|
|
|
|
|
|
|
# Quick-start development settings - unsuitable for production
|
|
|
|
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
|
|
|
|
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
|
|
SECRET_KEY = str(os.getenv('SECRET_KEY'))
|
|
|
|
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
|
|
DEBUG = True
|
|
|
|
|
2023-07-03 21:22:06 +08:00
|
|
|
ALLOWED_HOSTS = ['*', '127.0.0.1', 'localhost', '10.0.10.32', '10.0.10.8']
|
2023-06-26 18:58:20 +08:00
|
|
|
|
2023-06-26 20:36:58 +08:00
|
|
|
# Email credentials
|
|
|
|
EMAIL_HOST = ''
|
|
|
|
EMAIL_HOST_USER = ''
|
|
|
|
EMAIL_HOST_PASSWORD = ''
|
|
|
|
EMAIL_PORT = ''
|
2023-07-04 19:22:21 +08:00
|
|
|
EMAIL_USE_TLS = False
|
2023-06-26 20:36:58 +08:00
|
|
|
|
|
|
|
if (DEBUG == True):
|
|
|
|
EMAIL_HOST = str(os.getenv('DEV_EMAIL_HOST'))
|
|
|
|
EMAIL_HOST_USER = str(os.getenv('DEV_EMAIL_HOST_USER'))
|
|
|
|
EMAIL_HOST_PASSWORD = str(os.getenv('DEV_EMAIL_HOST_PASSWORD'))
|
|
|
|
EMAIL_PORT = str(os.getenv('DEV_EMAIL_PORT'))
|
|
|
|
else:
|
|
|
|
EMAIL_HOST = str(os.getenv('PROD_EMAIL_HOST'))
|
|
|
|
EMAIL_HOST_USER = str(os.getenv('PROD_EMAIL_HOST_USER'))
|
|
|
|
EMAIL_HOST_PASSWORD = str(os.getenv('PROD_EMAIL_HOST_PASSWORD'))
|
|
|
|
EMAIL_PORT = str(os.getenv('PROD_EMAIL_PORT'))
|
2023-07-04 19:22:21 +08:00
|
|
|
EMAIL_USE_TLS = str(os.getenv('PROD_EMAIL_TLS'))
|
2023-06-26 20:36:58 +08:00
|
|
|
|
2023-07-09 19:07:33 +08:00
|
|
|
# Will need to install OSGeo4W for this!
|
|
|
|
if os.name == 'nt':
|
|
|
|
OSGEO4W = r"C:\OSGeo4W"
|
2023-07-09 19:12:36 +08:00
|
|
|
if not os.path.isdir(OSGEO4W):
|
|
|
|
OSGEO4W += '64'
|
2023-07-09 19:07:33 +08:00
|
|
|
os.environ['OSGEO4W_ROOT'] = OSGEO4W
|
|
|
|
os.environ['GDAL_DATA'] = "C:\Program Files\GDAL\gdal-data"
|
|
|
|
os.environ['PROJ_LIB'] = OSGEO4W + r"\share\proj"
|
|
|
|
GDAL_LIBRARY_PATH = r'C:\OSGeo4W64\bin\gdal204'
|
|
|
|
os.environ['PATH'] = OSGEO4W + r"\bin;" + os.environ['PATH']
|
|
|
|
|
2023-07-09 17:30:00 +08:00
|
|
|
GEOS_LIBRARY_PATH = str(os.environ.get('VIRTUAL_ENV') +
|
|
|
|
r"\Lib\site-packages\osgeo\geos_c.dll")
|
|
|
|
GDAL_LIBRARY_PATH = str(os.environ.get('VIRTUAL_ENV') +
|
|
|
|
r"\Lib\site-packages\osgeo\gdal304.dll")
|
2023-06-26 18:58:20 +08:00
|
|
|
|
|
|
|
INSTALLED_APPS = [
|
2023-07-01 11:40:49 +08:00
|
|
|
'daphne',
|
2023-06-26 18:58:20 +08:00
|
|
|
'django.contrib.admin',
|
|
|
|
'django.contrib.auth',
|
|
|
|
'django.contrib.contenttypes',
|
|
|
|
'django.contrib.sessions',
|
|
|
|
'django.contrib.messages',
|
|
|
|
'django.contrib.staticfiles',
|
2023-07-09 17:30:00 +08:00
|
|
|
'django.contrib.gis',
|
2023-06-26 18:58:20 +08:00
|
|
|
'rest_framework',
|
2023-07-04 16:59:18 +08:00
|
|
|
'rest_framework_simplejwt',
|
2023-06-26 19:10:04 +08:00
|
|
|
'djoser',
|
2023-06-26 20:36:58 +08:00
|
|
|
'accounts',
|
2023-06-26 22:06:05 +08:00
|
|
|
'student_status',
|
2023-06-27 14:16:40 +08:00
|
|
|
'courses',
|
2023-06-27 15:41:34 +08:00
|
|
|
'year_levels',
|
2023-06-27 15:48:43 +08:00
|
|
|
'semesters',
|
2023-06-27 18:15:31 +08:00
|
|
|
'subjects',
|
2023-06-27 21:12:03 +08:00
|
|
|
'study_groups',
|
2023-06-28 00:49:11 +08:00
|
|
|
'studygroup_messages',
|
2023-06-26 18:58:20 +08:00
|
|
|
]
|
|
|
|
|
|
|
|
MIDDLEWARE = [
|
|
|
|
'django.middleware.security.SecurityMiddleware',
|
2023-06-26 22:10:29 +08:00
|
|
|
"whitenoise.middleware.WhiteNoiseMiddleware",
|
2023-06-26 18:58:20 +08:00
|
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
|
|
'django.middleware.common.CommonMiddleware',
|
|
|
|
'django.middleware.csrf.CsrfViewMiddleware',
|
|
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
|
|
'django.contrib.messages.middleware.MessageMiddleware',
|
|
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
|
|
]
|
|
|
|
|
2023-06-26 22:10:29 +08:00
|
|
|
STATIC_URL = 'static/'
|
|
|
|
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
|
|
|
|
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
|
|
|
|
|
2023-06-26 18:58:20 +08:00
|
|
|
ROOT_URLCONF = 'config.urls'
|
|
|
|
|
2023-07-01 11:40:49 +08:00
|
|
|
ASGI_APPLICATION = "config.asgi.application"
|
|
|
|
|
2023-06-26 18:58:20 +08:00
|
|
|
TEMPLATES = [
|
|
|
|
{
|
|
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
2023-07-04 19:22:21 +08:00
|
|
|
'DIRS': [
|
|
|
|
BASE_DIR / 'templates',
|
|
|
|
],
|
2023-06-26 18:58:20 +08:00
|
|
|
'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',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
2023-06-26 19:10:04 +08:00
|
|
|
REST_FRAMEWORK = {
|
|
|
|
'DEFAULT_AUTHENTICATION_CLASSES': (
|
2023-07-03 23:19:03 +08:00
|
|
|
'rest_framework_simplejwt.authentication.JWTAuthentication',
|
2023-06-26 19:10:04 +08:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2023-06-26 18:58:20 +08:00
|
|
|
WSGI_APPLICATION = 'config.wsgi.application'
|
|
|
|
|
|
|
|
|
|
|
|
# Database
|
|
|
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
|
|
|
|
|
2023-07-09 17:30:00 +08:00
|
|
|
"""DATABASES = {
|
2023-06-26 18:58:20 +08:00
|
|
|
'default': {
|
|
|
|
'ENGINE': 'django.db.backends.sqlite3',
|
|
|
|
'NAME': BASE_DIR / 'db.sqlite3',
|
|
|
|
}
|
2023-07-09 17:30:00 +08:00
|
|
|
}"""
|
|
|
|
|
|
|
|
DATABASES = {
|
|
|
|
'default': {
|
|
|
|
'ENGINE': 'django.contrib.gis.db.backends.spatialite',
|
|
|
|
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
|
|
|
}
|
2023-06-26 18:58:20 +08:00
|
|
|
}
|
|
|
|
|
2023-06-26 19:45:58 +08:00
|
|
|
AUTH_USER_MODEL = 'accounts.CustomUser'
|
|
|
|
|
|
|
|
DJOSER = {
|
|
|
|
'SEND_ACTIVATION_EMAIL': True,
|
|
|
|
'SEND_CONFIRMATION_EMAIL': True,
|
2023-07-04 19:22:21 +08:00
|
|
|
'EMAIL': {
|
|
|
|
'activation': 'config.email.ActivationEmail'
|
|
|
|
},
|
2023-06-26 19:45:58 +08:00
|
|
|
'ACTIVATION_URL': 'activation/{uid}/{token}',
|
|
|
|
'USER_AUTHENTICATION_RULES': ['djoser.authentication.TokenAuthenticationRule'],
|
|
|
|
'SERIALIZERS': {
|
|
|
|
'user': 'accounts.serializers.CustomUserSerializer',
|
2023-07-04 20:34:12 +08:00
|
|
|
'current_user': 'accounts.serializers.CustomUserSerializer',
|
2023-06-26 19:45:58 +08:00
|
|
|
'user_create': 'accounts.serializers.UserRegistrationSerializer',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2023-06-26 18:58:20 +08:00
|
|
|
# Password validation
|
|
|
|
# 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 = 'Asia/Manila'
|
|
|
|
|
|
|
|
USE_I18N = True
|
|
|
|
|
|
|
|
USE_TZ = True
|
|
|
|
|
|
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
|
|
# https://docs.djangoproject.com/en/4.2/howto/static-files/
|
|
|
|
|
|
|
|
STATIC_URL = 'static/'
|
2023-06-26 20:42:22 +08:00
|
|
|
MEDIA_URL = '/media/'
|
|
|
|
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
|
|
|
|
2023-06-26 18:58:20 +08:00
|
|
|
|
|
|
|
# Default primary key field type
|
|
|
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
|
|
|
|
|
|
|
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
2023-07-04 18:06:47 +08:00
|
|
|
|
2023-07-04 19:22:21 +08:00
|
|
|
DOMAIN = ''
|
|
|
|
if (DEBUG):
|
|
|
|
DOMAIN = 'exp'
|
|
|
|
else:
|
|
|
|
DOMAIN = 'stude'
|
|
|
|
|
2023-07-04 19:36:29 +08:00
|
|
|
|
2023-07-04 19:22:21 +08:00
|
|
|
SITE_NAME = 'Stud-E'
|
2023-07-07 18:34:11 +08:00
|
|
|
|
|
|
|
JWT_TOKEN_LIFETIME = 10800
|
|
|
|
ACCESS_TOKEN_LIFETIME = JWT_TOKEN_LIFETIME
|
|
|
|
REFRESH_TOKEN_LIFETIME = 24 * JWT_TOKEN_LIFETIME
|