Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-27 07:41:45

0001 """
0002 Django settings for swf-remote — external ePIC PanDA monitoring frontend.
0003 
0004 Consumes swf-monitor REST endpoints via SSH tunnel.
0005 """
0006 
0007 from pathlib import Path
0008 from decouple import config
0009 
0010 BASE_DIR = Path(__file__).resolve().parent.parent
0011 
0012 SECRET_KEY = config('SWF_REMOTE_SECRET_KEY')
0013 DEBUG = config('SWF_REMOTE_DEBUG', default=False, cast=bool)
0014 ALLOWED_HOSTS = config('SWF_REMOTE_ALLOWED_HOSTS', default='localhost,127.0.0.1').split(',')
0015 
0016 INSTALLED_APPS = [
0017     'django.contrib.admin',
0018     'django.contrib.auth',
0019     'django.contrib.contenttypes',
0020     'django.contrib.sessions',
0021     'django.contrib.messages',
0022     'django.contrib.staticfiles',
0023     'django.contrib.humanize',
0024     'remote_app',
0025 ]
0026 
0027 MIDDLEWARE = [
0028     'django.middleware.security.SecurityMiddleware',
0029     'django.contrib.sessions.middleware.SessionMiddleware',
0030     'django.middleware.common.CommonMiddleware',
0031     'django.middleware.csrf.CsrfViewMiddleware',
0032     'django.contrib.auth.middleware.AuthenticationMiddleware',
0033     'django.contrib.messages.middleware.MessageMiddleware',
0034     'django.middleware.clickjacking.XFrameOptionsMiddleware',
0035     'swf_remote_project.expire_old_cookies.ExpireOldCookiesMiddleware',
0036 ]
0037 
0038 ROOT_URLCONF = 'swf_remote_project.urls'
0039 
0040 TEMPLATES = [
0041     {
0042         'BACKEND': 'django.template.backends.django.DjangoTemplates',
0043         'DIRS': [
0044             BASE_DIR / 'templates',                    # swf-remote overrides (base.html, etc.)
0045             BASE_DIR / 'monitor_templates',            # symlink to swf-monitor templates
0046         ],
0047         'APP_DIRS': True,
0048         'OPTIONS': {
0049             'context_processors': [
0050                 'django.template.context_processors.debug',
0051                 'django.template.context_processors.request',
0052                 'django.contrib.auth.context_processors.auth',
0053                 'django.contrib.messages.context_processors.messages',
0054             ],
0055         },
0056     },
0057 ]
0058 
0059 WSGI_APPLICATION = 'swf_remote_project.wsgi.application'
0060 
0061 DATABASES = {
0062     'default': {
0063         'ENGINE': 'django.db.backends.postgresql',
0064         'NAME': config('SWF_REMOTE_DB_NAME', default='swf_remote'),
0065         'USER': config('SWF_REMOTE_DB_USER', default='swf_remote'),
0066         'PASSWORD': config('SWF_REMOTE_DB_PASSWORD', default=''),
0067         'HOST': config('SWF_REMOTE_DB_HOST', default='localhost'),
0068         'PORT': config('SWF_REMOTE_DB_PORT', default='5432'),
0069     },
0070 }
0071 
0072 LANGUAGE_CODE = 'en-us'
0073 TIME_ZONE = 'America/New_York'
0074 USE_I18N = True
0075 USE_TZ = True
0076 
0077 # Subpath deployment (e.g. /prod on epic-devcloud.org)
0078 FORCE_SCRIPT_NAME = config('SWF_REMOTE_FORCE_SCRIPT_NAME', default='') or None
0079 
0080 STATIC_URL = config('SWF_REMOTE_STATIC_URL', default='/static/')
0081 STATIC_ROOT = BASE_DIR.parent / 'staticfiles'
0082 
0083 DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
0084 
0085 # Cookie scoping — unique names prevent conflicts with other apps on same domain
0086 _subpath = FORCE_SCRIPT_NAME or ""
0087 CSRF_COOKIE_PATH = _subpath or "/"
0088 SESSION_COOKIE_PATH = _subpath or "/"
0089 CSRF_COOKIE_NAME = 'csrftoken_prod'
0090 SESSION_COOKIE_NAME = 'sessionid_prod'
0091 
0092 # Behind Apache reverse proxy
0093 USE_X_FORWARDED_HOST = True
0094 SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
0095 
0096 
0097 # Authentication
0098 LOGIN_URL = 'login'
0099 LOGIN_REDIRECT_URL = 'monitor_app:prod_home'
0100 LOGOUT_REDIRECT_URL = 'monitor_app:home'
0101 
0102 # swf-monitor REST base URL (via SSH tunnel to pandaserver02)
0103 SWF_MONITOR_URL = config('SWF_REMOTE_MONITOR_URL', default='https://localhost:18443/swf-monitor')