|
| 1 | +""" |
| 2 | +Django settings for myhackupc2 project. |
| 3 | +
|
| 4 | +Generated by 'django-admin startproject' using Django 4.0.4. |
| 5 | +
|
| 6 | +For more information on this file, see |
| 7 | +https://docs.djangoproject.com/en/4.0/topics/settings/ |
| 8 | +
|
| 9 | +For the full list of settings and their values, see |
| 10 | +https://docs.djangoproject.com/en/4.0/ref/settings/ |
| 11 | +""" |
| 12 | +import os |
| 13 | +from pathlib import Path |
| 14 | + |
| 15 | +from django.contrib.messages import constants as message_constants |
| 16 | + |
| 17 | +from .hackathon_variables import * |
| 18 | + |
| 19 | +# Build paths inside the project like this: BASE_DIR / 'subdir'. |
| 20 | +BASE_DIR = Path(__file__).resolve().parent.parent |
| 21 | + |
| 22 | + |
| 23 | +# Quick-start development settings - unsuitable for production |
| 24 | +# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ |
| 25 | + |
| 26 | +# SECURITY WARNING: keep the secret key used in production secret! |
| 27 | +SECRET_KEY = os.environ.get('SECRET_KEY', 'django-insecure-*9+h@8wtz_f0i#0i@*8(dt#y1ktpb^1*)ddwr)su8$doq6ny1w') |
| 28 | + |
| 29 | +# SECURITY WARNING: don't run with debug turned on in production! |
| 30 | +DEBUG = os.environ.get('DEBUG', 'true').lower() != 'false' |
| 31 | + |
| 32 | +ALLOWED_HOSTS = [] |
| 33 | +HOST = os.environ.get('HOST') |
| 34 | + |
| 35 | +if DEBUG: |
| 36 | + ALLOWED_HOSTS.extend(['localhost', '127.0.0.1']) |
| 37 | +elif HOST is not None: |
| 38 | + ALLOWED_HOSTS.append(HOST) |
| 39 | + |
| 40 | + |
| 41 | +# Application definition |
| 42 | + |
| 43 | +INSTALLED_APPS = [ |
| 44 | + 'django.contrib.admin', |
| 45 | + 'django.contrib.auth', |
| 46 | + 'django.contrib.contenttypes', |
| 47 | + 'django.contrib.sessions', |
| 48 | + 'django.contrib.messages', |
| 49 | + 'django.contrib.staticfiles', |
| 50 | + 'django_jwt', |
| 51 | + 'django_jwt.server', |
| 52 | + 'django_bootstrap5', |
| 53 | + 'corsheaders', |
| 54 | + 'user', |
| 55 | +] |
| 56 | + |
| 57 | +MIDDLEWARE = [ |
| 58 | + 'django.middleware.security.SecurityMiddleware', |
| 59 | + 'django.contrib.sessions.middleware.SessionMiddleware', |
| 60 | + 'corsheaders.middleware.CorsMiddleware', |
| 61 | + 'django.middleware.common.CommonMiddleware', |
| 62 | + 'django.middleware.csrf.CsrfViewMiddleware', |
| 63 | + 'django.contrib.auth.middleware.AuthenticationMiddleware', |
| 64 | + 'django.contrib.messages.middleware.MessageMiddleware', |
| 65 | + 'django.middleware.clickjacking.XFrameOptionsMiddleware', |
| 66 | +] |
| 67 | + |
| 68 | +ROOT_URLCONF = 'app.urls' |
| 69 | + |
| 70 | +TEMPLATES = [ |
| 71 | + { |
| 72 | + 'BACKEND': 'django.template.backends.django.DjangoTemplates', |
| 73 | + 'DIRS': [BASE_DIR / 'app' / 'templates'] |
| 74 | + , |
| 75 | + 'APP_DIRS': True, |
| 76 | + 'OPTIONS': { |
| 77 | + 'context_processors': [ |
| 78 | + 'django.template.context_processors.debug', |
| 79 | + 'django.template.context_processors.request', |
| 80 | + 'django.contrib.auth.context_processors.auth', |
| 81 | + 'django.contrib.messages.context_processors.messages', |
| 82 | + 'app.template.app_variables', |
| 83 | + ], |
| 84 | + 'libraries': { |
| 85 | + 'util': 'app.templatetags.util', |
| 86 | + }, |
| 87 | + }, |
| 88 | + }, |
| 89 | +] |
| 90 | + |
| 91 | +WSGI_APPLICATION = 'app.wsgi.application' |
| 92 | + |
| 93 | + |
| 94 | +# Database |
| 95 | +# https://docs.djangoproject.com/en/4.0/ref/settings/#databases |
| 96 | + |
| 97 | +DATABASES = { |
| 98 | + 'default': { |
| 99 | + 'ENGINE': 'django.db.backends.sqlite3', |
| 100 | + 'NAME': BASE_DIR / 'db.sqlite3', |
| 101 | + } |
| 102 | +} |
| 103 | + |
| 104 | + |
| 105 | +# Password validation |
| 106 | +# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators |
| 107 | + |
| 108 | +AUTH_PASSWORD_VALIDATORS = [ |
| 109 | + { |
| 110 | + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', |
| 111 | + }, |
| 112 | + { |
| 113 | + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', |
| 114 | + }, |
| 115 | + { |
| 116 | + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', |
| 117 | + }, |
| 118 | + { |
| 119 | + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', |
| 120 | + }, |
| 121 | +] |
| 122 | + |
| 123 | + |
| 124 | +# Internationalization |
| 125 | +# https://docs.djangoproject.com/en/4.0/topics/i18n/ |
| 126 | + |
| 127 | +LANGUAGE_CODE = 'en-us' |
| 128 | + |
| 129 | +TIME_ZONE = 'UTC' |
| 130 | + |
| 131 | +USE_I18N = True |
| 132 | + |
| 133 | +USE_TZ = True |
| 134 | + |
| 135 | + |
| 136 | +# Static files (CSS, JavaScript, Images) |
| 137 | +# https://docs.djangoproject.com/en/4.0/howto/static-files/ |
| 138 | + |
| 139 | +STATIC_URL = 'static/' |
| 140 | +STATIC_ROOT = BASE_DIR / 'staticfiles' |
| 141 | +STATICFILES_DIRS = [ |
| 142 | + BASE_DIR / 'app' / 'static', |
| 143 | +] |
| 144 | + |
| 145 | +# Default primary key field type |
| 146 | +# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field |
| 147 | + |
| 148 | +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' |
| 149 | + |
| 150 | +# App theme: dark, light, both |
| 151 | +THEME = 'both' |
| 152 | + |
| 153 | +# UserModel default |
| 154 | +AUTH_USER_MODEL = 'user.User' |
| 155 | + |
| 156 | +# JWT settings |
| 157 | +JWT_CLIENT = { |
| 158 | + 'OPENID2_URL': os.environ.get('OPENID_CLIENT_ID', 'http://localhost:8000/openid'), # Required |
| 159 | + 'CLIENT_ID': os.environ.get('OPENID_CLIENT_ID', 'client_id'), # Required |
| 160 | + 'TYPE': 'fake' if DEBUG else 'local', # Required |
| 161 | + 'RESPONSE_TYPE': 'id_token', # Required |
| 162 | + 'RENAME_ATTRIBUTES': {'sub': 'email'}, # Optional |
| 163 | + |
| 164 | +} |
| 165 | +JWT_SERVER = { |
| 166 | + 'JWK_EXPIRATION_TIME': 3600, # Optional |
| 167 | + 'JWT_EXPIRATION_TIME': 14400 # Optional |
| 168 | +} |
| 169 | + |
| 170 | +# Toast styles |
| 171 | +MESSAGE_TAGS = { |
| 172 | + message_constants.DEBUG: 'info text-dark', |
| 173 | + message_constants.INFO: 'info text-dark', |
| 174 | + message_constants.SUCCESS: 'success', |
| 175 | + message_constants.WARNING: 'warning text-dark', |
| 176 | + message_constants.ERROR: 'danger', |
| 177 | +} |
| 178 | + |
| 179 | +# Google recaptcha |
| 180 | +GOOGLE_RECAPTCHA_SECRET_KEY = os.environ.get('GOOGLE_RECAPTCHA_SECRET_KEY', '') |
| 181 | +GOOGLE_RECAPTCHA_SITE_KEY = os.environ.get('GOOGLE_RECAPTCHA_SITE_KEY', '') |
| 182 | + |
| 183 | +# Login tries |
| 184 | +LOGIN_TRIES = 1000 if DEBUG else 4 |
0 commit comments