-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbase.py
More file actions
252 lines (191 loc) · 7.38 KB
/
base.py
File metadata and controls
252 lines (191 loc) · 7.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
"""
Django settings for PennCourses project.
Generated by 'django-admin startproject' using Django 2.2.
For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""
import os
import boto3
import dj_database_url
import dotenv
dotenv.load_dotenv()
DOMAINS = os.environ.get("DOMAINS", "example.com").split(",")
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get("SECRET_KEY", "&3!f%)t!o$+dwu3(jao7ipi2f4(k-2ua7@28+^yge-cn7c!_14")
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ["*"]
# Application definition
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"rest_framework",
"corsheaders",
"shortener.apps.ShortenerConfig",
"accounts.apps.AccountsConfig",
"options.apps.OptionsConfig",
"django.contrib.admindocs",
"django_extensions",
"alert",
"courses",
"plan",
"review",
"degree",
]
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 = os.environ.get("ROOT_URLCONF", "PennCourses.urls")
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": ["PennCourses/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",
],
},
},
]
WSGI_APPLICATION = "PennCourses.wsgi.application"
# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
DATABASES = {
"default": dj_database_url.config(
# this is overriden by the DATABASE_URL env var
default="postgres://penn-courses:postgres@localhost:5432/postgres"
)
}
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
# Explicitly setting DEFAULT_AUTO_FIELD is necessary to silence warnings after Django 3.2
# We don't need the range of BigAutoField for auto fields so we can stick with the old behavior
# Password validation
# https://docs.djangoproject.com/en/2.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",
},
]
# Authentication Backends
AUTHENTICATION_BACKENDS = [
"accounts.backends.LabsUserBackend",
"django.contrib.auth.backends.ModelBackend",
]
# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/
LANGUAGE_CODE = "en-us"
TIME_ZONE = "America/New_York"
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/
STATIC_URL = "/assets/"
STATIC_ROOT = os.path.join(BASE_DIR, "static")
# DLA Settings
PLATFORM_ACCOUNTS = {
"REDIRECT_URI": os.environ.get("LABS_REDIRECT_URI", "http://localhost:8000/accounts/callback/"),
"CLIENT_ID": "clientid",
"CLIENT_SECRET": "supersecretclientsecret",
"PLATFORM_URL": "https://platform-dev.pennlabs.org",
"CUSTOM_ADMIN": False,
}
# Penn OpenData API
OPEN_DATA_CLIENT_ID = os.environ.get("OPEN_DATA_CLIENT_ID", "")
OPEN_DATA_OIDC_SECRET = os.environ.get("OPEN_DATA_OIDC_SECRET", "")
OPEN_DATA_TOKEN_URL = (
"https://sso.apps.k8s.upenn.edu/auth/realms/master/protocol/openid-connect/token"
)
OPEN_DATA_API_BASE = "https://3scale-public-prod-open-data.apps.k8s.upenn.edu/api"
# Penn OpenData Course Status Webhook Auth
WEBHOOK_USERNAME = os.environ.get("WEBHOOK_USERNAME", "webhook")
WEBHOOK_PASSWORD = os.environ.get("WEBHOOK_PASSWORD", "password")
# Penn Labs Platform JWKs
JWKS_URI = f"https://platform.pennlabs.org/accounts/.well-known/jwks.json"
AUTH_OIDC_CLIENT_ID = os.environ.get("AUTH_OIDC_CLIENT_ID", "")
# Email Configuration
SMTP_HOST = os.environ.get("SMTP_HOST", "")
SMTP_PORT = os.environ.get("SMTP_PORT", 587)
SMTP_USERNAME = os.environ.get("SMTP_USERNAME", "")
SMTP_PASSWORD = os.environ.get("SMTP_PASSWORD", "")
# Twilio Credentials
TWILIO_SID = os.environ.get("TWILIO_SID", "")
TWILIO_AUTH_TOKEN = os.environ.get("TWILIO_TOKEN", "")
TWILIO_NUMBER = os.environ.get("TWILIO_NUMBER", "+12153984277")
# Redis
REDIS_URL = os.environ.get("REDIS_URL", "redis://localhost:6379/1")
# Celery
MESSAGE_BROKER_URL = REDIS_URL
# Django REST Framework
REST_FRAMEWORK = {
"COERCE_DECIMAL_TO_STRING": False,
"DEFAULT_SCHEMA_CLASS": "PennCourses.docs_settings.PcxAutoSchema",
"DEFAULT_AUTHENTICATION_CLASSES": [
"rest_framework.authentication.SessionAuthentication",
"rest_framework.authentication.BasicAuthentication",
"accounts.authentication.PlatformAuthentication",
"PennCourses.authentication.jwt.JWTAuthentication",
],
}
STATS_WEBHOOK = os.environ.get("STATS_WEBHOOK", None)
S3_client = boto3.client("s3")
S3_resource = boto3.resource("s3")
# NGSS course code crosswalk stored in S3
XWALK_S3_BUCKET = "penn.courses"
XWALK_SRC = "xwalk_csre_number.txt"
# The first semester that used Banner/NGSS for course data.
# This was when course codes changed from 3-digit to 4-digit.
# Note that the above crosswalk connects pre and post NGSS courses
FIRST_BANNER_SEM = "2022B"
# Registration Metrics Settings
STATUS_UPDATES_RECORDED_SINCE = "2019C" # How far back does our valid Status Update data span?
PCA_REGISTRATIONS_RECORDED_SINCE = "2020A" # How far back does our valid Registration data span?
WAITLIST_DEPARTMENT_CODES = [] # Which departments (referenced by code) have a waitlist system
# or require permits for registration during the add/drop period?
PRE_NGSS_PERMIT_REQ_RESTRICTION_CODES = [
"PCG",
"PAD",
"PCW",
"PCD",
"PLC",
"PIN",
"PDP",
] # Which pre-NGSS restriction codes indicate registration was handled by permit issuance?
ROUGH_MINIMUM_DEMAND_DISTRIBUTION_ESTIMATES = (
200 # Aim for at least 200 demand distribution estimates over the course of a semester
)
# The name of the schedule that is created/verified by Penn Mobile,
# containing the user's active course registrations from Path.
PATH_REGISTRATION_SCHEDULE_NAME = "Path Registration"
# Manually Set Cache Prefix
CACHE_PREFIX = "MANUAL_CACHE_"