247 lines
6.2 KiB
Python
Executable File
247 lines
6.2 KiB
Python
Executable File
"""
|
|
Django settings for horilla project.
|
|
|
|
Generated by 'django-admin startproject' using Django 4.1.4.
|
|
|
|
For more information on this file, see
|
|
https://docs.djangoproject.com/en/4.1/topics/settings/
|
|
|
|
For the full list of settings and their values, see
|
|
https://docs.djangoproject.com/en/4.1/ref/settings/
|
|
"""
|
|
|
|
import os
|
|
from os.path import join
|
|
from pathlib import Path
|
|
|
|
import environ
|
|
from django.contrib.messages import constants as messages
|
|
|
|
# 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.1/howto/deployment/checklist/
|
|
|
|
env = environ.Env(
|
|
DEBUG=(bool, True),
|
|
SECRET_KEY=(
|
|
str,
|
|
"django-insecure-j8op9)1q8$1&0^s&p*_0%d#pr@w9qj@1o=3#@d=a(^@9@zd@%j",
|
|
),
|
|
ALLOWED_HOSTS=(list, ["*"]),
|
|
CSRF_TRUSTED_ORIGINS=(list, ["http://localhost:8000"]),
|
|
)
|
|
|
|
env.read_env(os.path.join(BASE_DIR, ".env"), overwrite=True)
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
SECRET_KEY = env("SECRET_KEY")
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
DEBUG = env("DEBUG")
|
|
|
|
ALLOWED_HOSTS = env("ALLOWED_HOSTS")
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = [
|
|
"django.contrib.admin",
|
|
"django.contrib.auth",
|
|
"django.contrib.contenttypes",
|
|
"django.contrib.sessions",
|
|
"django.contrib.messages",
|
|
"django.contrib.staticfiles",
|
|
"notifications",
|
|
"mathfilters",
|
|
"corsheaders",
|
|
"simple_history",
|
|
"django_filters",
|
|
"base",
|
|
"employee",
|
|
"recruitment",
|
|
"leave",
|
|
"pms",
|
|
"onboarding",
|
|
"asset",
|
|
"attendance",
|
|
"payroll",
|
|
"widget_tweaks",
|
|
"django_apscheduler",
|
|
]
|
|
APSCHEDULER_DATETIME_FORMAT = "N j, Y, f:s a"
|
|
|
|
APSCHEDULER_RUN_NOW_TIMEOUT = 25 # Seconds
|
|
|
|
|
|
MIDDLEWARE = [
|
|
"django.middleware.security.SecurityMiddleware",
|
|
"whitenoise.middleware.WhiteNoiseMiddleware",
|
|
"django.contrib.sessions.middleware.SessionMiddleware",
|
|
"django.middleware.common.CommonMiddleware",
|
|
"corsheaders.middleware.CorsMiddleware",
|
|
"simple_history.middleware.HistoryRequestMiddleware",
|
|
"django.middleware.locale.LocaleMiddleware",
|
|
"django.middleware.csrf.CsrfViewMiddleware",
|
|
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
|
"django.contrib.messages.middleware.MessageMiddleware",
|
|
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
|
]
|
|
|
|
ROOT_URLCONF = "horilla.urls"
|
|
|
|
TEMPLATES = [
|
|
{
|
|
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
"DIRS": [
|
|
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 = "horilla.wsgi.application"
|
|
|
|
|
|
# Database
|
|
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
|
|
|
|
if env("DATABASE_URL", default=None):
|
|
DATABASES = {
|
|
"default": env.db(),
|
|
}
|
|
else:
|
|
DATABASES = {
|
|
"default": {
|
|
"ENGINE": env("DB_ENGINE", default="django.db.backends.sqlite3"),
|
|
"NAME": env(
|
|
"DB_NAME",
|
|
default=os.path.join(
|
|
BASE_DIR,
|
|
"TestDB_Horilla.sqlite3",
|
|
),
|
|
),
|
|
"USER": env("DB_USER", default=""),
|
|
"PASSWORD": env("DB_PASSWORD", default=""),
|
|
"HOST": env("DB_HOST", default=""),
|
|
"PORT": env("DB_PORT", default=""),
|
|
}
|
|
}
|
|
|
|
# Password validation
|
|
# https://docs.djangoproject.com/en/4.1/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",
|
|
},
|
|
]
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
# https://docs.djangoproject.com/en/4.1/howto/static-files/
|
|
|
|
STATIC_URL = "static/"
|
|
STATIC_ROOT = BASE_DIR / "staticfiles"
|
|
|
|
STATICFILES_DIRS = [
|
|
BASE_DIR / "static",
|
|
]
|
|
|
|
STATICFILES_STORAGE = "whitenoise.storage.CompressedStaticFilesStorage"
|
|
|
|
MEDIA_URL = "/media/"
|
|
MEDIA_ROOT = os.path.join(BASE_DIR, "media/")
|
|
# Default primary key field type
|
|
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
|
|
|
|
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
|
|
|
|
|
MESSAGE_TAGS = {
|
|
messages.DEBUG: "oh-alert--warning",
|
|
messages.INFO: "oh-alert--info",
|
|
messages.SUCCESS: "oh-alert--success",
|
|
messages.WARNING: "oh-alert--warning",
|
|
messages.ERROR: "oh-alert--danger",
|
|
}
|
|
|
|
|
|
CSRF_TRUSTED_ORIGINS = env("CSRF_TRUSTED_ORIGINS")
|
|
|
|
LOGIN_URL = "/login"
|
|
|
|
|
|
SIMPLE_HISTORY_REVERT_DISABLED = True
|
|
|
|
|
|
DJANGO_NOTIFICATIONS_CONFIG = {
|
|
"USE_JSONFIELD": True,
|
|
"SOFT_DELETE": True,
|
|
"USE_WATCHED": True,
|
|
"NOTIFICATIONS_STORAGE": "notifications.storage.DatabaseStorage",
|
|
"TEMPLATE": "notifications.html", # Add this line
|
|
}
|
|
|
|
X_FRAME_OPTIONS = "SAMEORIGIN"
|
|
|
|
LANGUAGES = (
|
|
("en", "English (US)"),
|
|
("de", "Deutsche"),
|
|
("es", "Español"),
|
|
("fr", "Français"),
|
|
("ar", "عربى"),
|
|
("pt-br", "Português (Brasil)"),
|
|
("zh-hans", "Simplified Chinese"),
|
|
("zh-hant", "Traditional Chinese"),
|
|
("it", "Italian"),
|
|
)
|
|
|
|
|
|
LOCALE_PATHS = [
|
|
join(BASE_DIR, "horilla", "locale"),
|
|
]
|
|
|
|
|
|
# Internationalization
|
|
# https://docs.djangoproject.com/en/4.1/topics/i18n/
|
|
|
|
LANGUAGE_CODE = "en-us"
|
|
|
|
TIME_ZONE = env("TIME_ZONE", default="Asia/Kolkata")
|
|
|
|
USE_I18N = True
|
|
|
|
USE_L10N = True
|
|
|
|
USE_TZ = True
|
|
|
|
# Production settings
|
|
if not DEBUG:
|
|
SECURE_BROWSER_XSS_FILTER = True
|
|
SECURE_SSL_REDIRECT = True
|
|
SECURE_HSTS_SECONDS = 31536000
|
|
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
|
|
SECURE_HSTS_PRELOAD = True
|
|
SECURE_CONTENT_TYPE_NOSNIFF = True
|
|
SESSION_COOKIE_SECURE = True
|
|
CSRF_COOKIE_SECURE = True
|
|
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
|