Files
ihrm/horilla/settings.py

244 lines
6.1 KiB
Python
Raw Normal View History

2024-01-09 16:23:16 +05:30
"""
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
2024-01-09 16:23:16 +05:30
# 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)
2024-01-09 16:23:16 +05:30
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = env("SECRET_KEY")
2024-01-09 16:23:16 +05:30
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env("DEBUG")
2024-01-09 16:23:16 +05:30
ALLOWED_HOSTS = env("ALLOWED_HOSTS")
2024-01-09 16:23:16 +05:30
# 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",
[IMP] Remove inter module dependency (#274) This commit introduces significant changes to the architecture of the Horilla HRMS system by decoupling interdependent modules. The following modifications were made: 1. **Module Independence**: Each module has been refactored to eliminate reliance on other modules, promoting a more modular and maintainable codebase. 2. **Refactored Imports and Dependencies**: Adjusted import statements and dependency injections to support independent module operation. 3. **Compatibility and Functionality**: Ensured that all modules are compatible with existing systems and maintain their intended functionality both independently and when integrated with other modules. These changes enhance the modularity, maintainability, and scalability of the Horilla HRMS, allowing developers to work on individual modules without affecting the entire system. Future development and deployment will be more efficient and less prone to issues arising from tightly coupled code. **NOTE** For existing Horilla users, if you face any issues during the migrations, please run the following command and try again the migrations. - `python3 manage.py makemigrations` - `python3 manage.py migrate base` - `python3 manage.py migrate` * [IMP] ASSET: Asset module dependency removal from other Horilla apps * [IMP] ATTENDANCE: Attendance module dependency removal from other Horilla apps * [IMP] BASE: Base module dependency removal from other Horilla apps * [IMP] EMPLOYEE: Employee module dependency removal from other Horilla apps * [IMP] HELPDESK: Helpdesk module dependency removal from other Horilla apps * [IMP] HORILLA AUDIT: Horilla Audit module dependency removal from other Horilla apps * [IMP] HORILLA CRUMBS: Horilla Crumbs module dependency removal from other Horilla apps * [IMP] HORILLA AUTOMATIONS: Horilla Automations module dependency removal from other Horilla apps * [IMP] HORILLA VIEWS: Horilla Views module dependency removal from other Horilla apps * [IMP] LEAVE: Leave module dependency removal from other Horilla apps * [IMP] OFFBOARDING: Offboarding module dependency removal from other Horilla apps * [IMP] ONBOARDING: Onboarding module dependency removal from other Horilla apps * [IMP] PMS: PMS module dependency removal from other Horilla apps * [IMP] PAYROLL: Payroll module dependency removal from other Horilla apps * [IMP] RECRUITMENT: Recruitment module dependency removal from other Horilla apps * [IMP] HORILLA: Dependency removal updates * [IMP] TEMPLATES: Dependency removal updates * [IMP] STATIC: Dependency removal updates * [IMP] HORILLA DOCUMENTS: Horilla Documents module dependency removal from other Horilla apps * [ADD] HORILLA: methods.py * [UPDT] HORILLA: Settings.py * [FIX] EMPLOYEE: About tab issue * Update horilla_settings.py * Remove dummy db init password
2024-08-05 14:22:44 +05:30
"recruitment",
"leave",
"pms",
"onboarding",
"asset",
"attendance",
"payroll",
"widget_tweaks",
2024-01-09 16:23:16 +05:30
"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",
]
2024-01-09 16:23:16 +05:30
ROOT_URLCONF = "horilla.urls"
2024-01-09 16:23:16 +05:30
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",
2024-01-09 16:23:16 +05:30
],
},
},
]
WSGI_APPLICATION = "horilla.wsgi.application"
2024-01-09 16:23:16 +05:30
# 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=""),
}
2024-01-09 16:23:16 +05:30
}
# Password validation
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
2024-01-09 16:23:16 +05:30
},
{
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
2024-01-09 16:23:16 +05:30
},
{
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
2024-01-09 16:23:16 +05:30
},
{
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
2024-01-09 16:23:16 +05:30
},
]
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.1/howto/static-files/
STATIC_URL = "static/"
STATIC_ROOT = BASE_DIR / "staticfiles"
2024-01-09 16:23:16 +05:30
STATICFILES_DIRS = [
BASE_DIR / "static",
]
STATICFILES_STORAGE = "whitenoise.storage.CompressedStaticFilesStorage"
MEDIA_URL = "/media/"
MEDIA_ROOT = os.path.join(BASE_DIR, "media/")
2024-01-09 16:23:16 +05:30
# Default primary key field type
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
2024-01-09 16:23:16 +05:30
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",
}
2024-01-09 16:23:16 +05:30
CSRF_TRUSTED_ORIGINS = env("CSRF_TRUSTED_ORIGINS")
2024-01-09 16:23:16 +05:30
LOGIN_URL = "/login"
2024-01-09 16:23:16 +05:30
SIMPLE_HISTORY_REVERT_DISABLED = True
2024-01-09 16:23:16 +05:30
DJANGO_NOTIFICATIONS_CONFIG = {
"USE_JSONFIELD": True,
"SOFT_DELETE": True,
"USE_WATCHED": True,
"NOTIFICATIONS_STORAGE": "notifications.storage.DatabaseStorage",
"TEMPLATE": "notifications.html", # Add this line
2024-01-09 16:23:16 +05:30
}
X_FRAME_OPTIONS = "SAMEORIGIN"
2024-01-09 16:23:16 +05:30
LANGUAGES = (
("en", "English (US)"),
("de", "Deutsche"),
("es", "Español"),
("fr", "France"),
("ar", "عربى"),
("pt-br", "Português (Brasil)"),
("zh-hans", "Simplified Chinese"),
2024-01-09 16:23:16 +05:30
)
LOCALE_PATHS = [
join(BASE_DIR, "horilla", "locale"),
2024-01-09 16:23:16 +05:30
]
# Internationalization
# https://docs.djangoproject.com/en/4.1/topics/i18n/
LANGUAGE_CODE = "en-us"
TIME_ZONE = env("TIME_ZONE", default="Asia/Kolkata")
2024-01-09 16:23:16 +05:30
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")