280 lines
7.3 KiB
Python
280 lines
7.3 KiB
Python
"""
|
|
Django settings for manufacturing_app project.
|
|
|
|
Generated by 'django-admin startproject' using Django 4.2.23.
|
|
|
|
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
|
|
import os
|
|
from decouple import config
|
|
|
|
# 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 = config('SECRET_KEY', default='django-insecure-#(1g5(=rjs1aiff#^o38m1q21p9t846ae*j!+&_ie!bse+nl4f')
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
DEBUG = config('DEBUG', default=True, cast=bool)
|
|
|
|
ALLOWED_HOSTS = config('ALLOWED_HOSTS', default='localhost,127.0.0.1', cast=lambda v: [s.strip() for s in v.split(',')])
|
|
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = [
|
|
"django.contrib.admin",
|
|
"django.contrib.auth",
|
|
"django.contrib.contenttypes",
|
|
"django.contrib.sessions",
|
|
"django.contrib.messages",
|
|
"django.contrib.staticfiles",
|
|
|
|
# Third-party apps
|
|
"django_bootstrap5",
|
|
"crispy_forms",
|
|
"crispy_bootstrap5",
|
|
|
|
# Local apps
|
|
"apps.accounts",
|
|
"apps.inventory",
|
|
"apps.purchasing",
|
|
"apps.sales",
|
|
"apps.manufacturing",
|
|
"apps.database_management",
|
|
"apps.reports",
|
|
]
|
|
|
|
MIDDLEWARE = [
|
|
"django.middleware.security.SecurityMiddleware",
|
|
"whitenoise.middleware.WhiteNoiseMiddleware", # For static files
|
|
"django.contrib.sessions.middleware.SessionMiddleware",
|
|
"django.middleware.locale.LocaleMiddleware", # For internationalization
|
|
"django.middleware.common.CommonMiddleware",
|
|
"django.middleware.csrf.CsrfViewMiddleware",
|
|
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
|
"django.contrib.messages.middleware.MessageMiddleware",
|
|
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
|
]
|
|
|
|
ROOT_URLCONF = "manufacturing_app.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",
|
|
"apps.accounts.context_processors.custom_permissions",
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
WSGI_APPLICATION = "manufacturing_app.wsgi.application"
|
|
|
|
|
|
# Database
|
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
|
|
|
|
# Database
|
|
# SQLite for development, PostgreSQL for production
|
|
if config('DATABASE_URL', default=None):
|
|
# Production - PostgreSQL
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.postgresql',
|
|
'NAME': config('DB_NAME'),
|
|
'USER': config('DB_USER'),
|
|
'PASSWORD': config('DB_PASSWORD'),
|
|
'HOST': config('DB_HOST'),
|
|
'PORT': config('DB_PORT', default='5432'),
|
|
}
|
|
}
|
|
else:
|
|
# Development - SQLite
|
|
DATABASES = {
|
|
"default": {
|
|
"ENGINE": "django.db.backends.sqlite3",
|
|
"NAME": BASE_DIR / "db.sqlite3",
|
|
}
|
|
}
|
|
|
|
|
|
# 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 = "id" # Indonesian language code
|
|
USE_I18N = True
|
|
TIME_ZONE = "Asia/Jakarta"
|
|
USE_TZ = True
|
|
|
|
# Additional localization settings
|
|
LANGUAGES = [
|
|
("id", "Indonesian"),
|
|
("en", "English"),
|
|
]
|
|
|
|
LOCALE_PATHS = [
|
|
BASE_DIR / "locale",
|
|
]
|
|
|
|
# Format localization
|
|
USE_L10N = True
|
|
USE_THOUSAND_SEPARATOR = True
|
|
|
|
# Indonesian number formatting
|
|
DECIMAL_SEPARATOR = ','
|
|
THOUSAND_SEPARATOR = '.'
|
|
NUMBER_GROUPING = 3
|
|
|
|
# Custom template settings
|
|
TEMPLATES[0]['OPTIONS']['context_processors'].append('django.template.context_processors.i18n')
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
# https://docs.djangoproject.com/en/4.2/howto/static-files/
|
|
|
|
STATIC_URL = "/static/"
|
|
STATIC_ROOT = BASE_DIR / "staticfiles"
|
|
STATICFILES_DIRS = [
|
|
BASE_DIR / "static",
|
|
]
|
|
|
|
# Media files (User uploads)
|
|
MEDIA_URL = "/media/"
|
|
MEDIA_ROOT = BASE_DIR / "media"
|
|
|
|
# Static files storage for production
|
|
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
|
|
|
|
|
|
# Authentication and Security
|
|
AUTH_USER_MODEL = "accounts.User" # Custom user model
|
|
|
|
LOGIN_URL = "/accounts/login/"
|
|
LOGIN_REDIRECT_URL = "/"
|
|
LOGOUT_REDIRECT_URL = "/"
|
|
|
|
# Security settings
|
|
SECURE_BROWSER_XSS_FILTER = True
|
|
SECURE_CONTENT_TYPE_NOSNIFF = True
|
|
X_FRAME_OPTIONS = "DENY"
|
|
|
|
|
|
# Third-party app settings
|
|
# Bootstrap 5 settings
|
|
BOOTSTRAP5 = {
|
|
"css_url": {
|
|
"url": "https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css",
|
|
},
|
|
"javascript_url": {
|
|
"url": "https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js",
|
|
},
|
|
"theme_url": None,
|
|
"javascript_in_head": False,
|
|
"include_jquery": False,
|
|
"use_i18n": True,
|
|
}
|
|
|
|
# Crispy forms settings
|
|
CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap5"
|
|
CRISPY_TEMPLATE_PACK = "bootstrap5"
|
|
|
|
# Session settings
|
|
SESSION_COOKIE_AGE = 3600 # 1 hour
|
|
SESSION_SAVE_EVERY_REQUEST = True
|
|
|
|
|
|
# Email settings
|
|
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
|
|
EMAIL_HOST = config("EMAIL_HOST", default="localhost")
|
|
EMAIL_PORT = config("EMAIL_PORT", default=587, cast=int)
|
|
EMAIL_USE_TLS = config("EMAIL_USE_TLS", default=True, cast=bool)
|
|
EMAIL_HOST_USER = config("EMAIL_HOST_USER", default="")
|
|
EMAIL_HOST_PASSWORD = config("EMAIL_HOST_PASSWORD", default="")
|
|
DEFAULT_FROM_EMAIL = "noreply@manufacturing-app.com"
|
|
|
|
|
|
# Logging
|
|
LOGGING = {
|
|
"version": 1,
|
|
"disable_existing_loggers": False,
|
|
"handlers": {
|
|
"file": {
|
|
"level": "DEBUG",
|
|
"class": "logging.FileHandler",
|
|
"filename": BASE_DIR / "logs/django.log",
|
|
},
|
|
"console": {
|
|
"level": "DEBUG",
|
|
"class": "logging.StreamHandler",
|
|
},
|
|
},
|
|
"root": {
|
|
"handlers": ["file", "console"],
|
|
"level": "DEBUG",
|
|
},
|
|
"loggers": {
|
|
"django": {
|
|
"handlers": ["file", "console"],
|
|
"level": "WARNING",
|
|
"propagate": False,
|
|
},
|
|
},
|
|
}
|
|
|
|
|
|
# Custom application settings
|
|
# Reporting settings
|
|
REPORTS_PER_PAGE = 20
|
|
EXCEL_EXPORT_LIMIT = 10000
|
|
|
|
# Inventory settings
|
|
DEFAULT_REORDER_LEVEL = 10
|
|
STOCK_ALERT_THRESHOLD = 5
|
|
|
|
# Manufacturing settings
|
|
DEFAULT_MO_STATUS = "draft"
|
|
PRODUCTION_SCHEDULING_DAYS = 7
|
|
|
|
|
|
# Default primary key field type
|
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
|
|
|
|
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|