Resolved merge conflicts integrating PR #13 (Home Page with MUI v2): Backend changes: - settings.py: Combined INSTALLED_APPS (accounts + jobs + corsheaders), kept HEAD's REST_FRAMEWORK (AllowAny + throttling) and SIMPLE_JWT, added origin/main's CORS config - urls.py: Combined admin/, api/auth/, api/ routes - pyproject.toml: Combined all dependencies (simplejwt + cors-headers) - uv.lock: Regenerated with updated dependencies Frontend changes: - package.json: Combined all deps (axios + MUI + emotion) - App.tsx: Integrated AuthProvider with MUI AppLayout, all routes - HomePage.tsx: Show landing view when unauthenticated, MUI dashboard when authenticated - main.tsx, tsconfig.json, vite-env.d.ts: Combined both versions - yarn.lock: Kept origin/main's version (regenerated on install)
129 lines
3.5 KiB
Python
129 lines
3.5 KiB
Python
import os
|
|
from pathlib import Path
|
|
from datetime import timedelta
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
|
SECRET_KEY = os.environ.get(
|
|
"DJANGO_SECRET_KEY",
|
|
"django-insecure-change-me-in-production",
|
|
)
|
|
|
|
DEBUG = os.environ.get("DJANGO_DEBUG", "True").lower() in ("true", "1", "yes")
|
|
|
|
ALLOWED_HOSTS: list[str] = ["*"]
|
|
|
|
INSTALLED_APPS = [
|
|
"django.contrib.contenttypes",
|
|
"django.contrib.auth",
|
|
"django.contrib.admin",
|
|
"django.contrib.sessions",
|
|
"django.contrib.messages",
|
|
"django.contrib.staticfiles",
|
|
# Third-party
|
|
"rest_framework",
|
|
"corsheaders",
|
|
# Local
|
|
"accounts",
|
|
"jobs",
|
|
]
|
|
|
|
MIDDLEWARE = [
|
|
"corsheaders.middleware.CorsMiddleware",
|
|
"django.middleware.security.SecurityMiddleware",
|
|
"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",
|
|
]
|
|
|
|
ROOT_URLCONF = "project.urls"
|
|
|
|
TEMPLATES = [
|
|
{
|
|
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
"DIRS": [],
|
|
"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 = "project.wsgi.application"
|
|
|
|
# Parse DATABASE_URL
|
|
_database_url = os.environ.get(
|
|
"DATABASE_URL",
|
|
"postgres://jobtracker:***@localhost:5432/jobtracker",
|
|
)
|
|
|
|
# postgres://user:***@host:port/dbname → django settings dict
|
|
_db_parts = _database_url.replace("postgres://", "").split("@")
|
|
_credentials, _host_db = _db_parts[0], _db_parts[1]
|
|
_db_user, _db_pass = _credentials.split(":")
|
|
_host_port, _db_name = _host_db.split("/")
|
|
_db_host = _host_port.split(":")[0]
|
|
_db_port = _host_port.split(":")[1] if ":" in _host_port else "5432"
|
|
|
|
DATABASES = {
|
|
"default": {
|
|
"ENGINE": "django.db.backends.postgresql",
|
|
"NAME": _db_name,
|
|
"USER": _db_user,
|
|
"PASSWORD": _db_pass,
|
|
"HOST": _db_host,
|
|
"PORT": _db_port,
|
|
}
|
|
}
|
|
|
|
AUTH_USER_MODEL = "accounts.User"
|
|
|
|
REST_FRAMEWORK = {
|
|
"DEFAULT_AUTHENTICATION_CLASSES": (
|
|
"rest_framework_simplejwt.authentication.JWTAuthentication",
|
|
),
|
|
"DEFAULT_PERMISSION_CLASSES": (
|
|
"rest_framework.permissions.AllowAny",
|
|
),
|
|
"DEFAULT_RENDERER_CLASSES": (
|
|
"rest_framework.renderers.JSONRenderer",
|
|
),
|
|
"DEFAULT_THROTTLE_CLASSES": [
|
|
"rest_framework.throttling.AnonRateThrottle",
|
|
],
|
|
"DEFAULT_THROTTLE_RATES": {
|
|
"anon": os.environ.get("DJANGO_THROTTLE_ANON_RATE", "10/hour"),
|
|
"auth": os.environ.get("DJANGO_THROTTLE_AUTH_RATE", "5/minute"),
|
|
},
|
|
}
|
|
|
|
SIMPLE_JWT = {
|
|
"ACCESS_TOKEN_LIFETIME": timedelta(hours=24),
|
|
"REFRESH_TOKEN_LIFETIME": timedelta(days=30),
|
|
"AUTH_HEADER_TYPES": ("Bearer",),
|
|
}
|
|
|
|
# CORS
|
|
CORS_ALLOW_ALL_ORIGINS = os.environ.get("CORS_ALLOW_ALL_ORIGINS", "False").lower() in ("true", "1", "yes")
|
|
CORS_ALLOWED_ORIGINS = os.environ.get(
|
|
"CORS_ALLOWED_ORIGINS",
|
|
"http://localhost:3000,http://localhost:5173,http://127.0.0.1:3000",
|
|
).split(",")
|
|
|
|
LANGUAGE_CODE = "en-us"
|
|
TIME_ZONE = "UTC"
|
|
USE_I18N = True
|
|
USE_TZ = True
|
|
|
|
STATIC_URL = "/static/"
|
|
|
|
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|