-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.example.py
More file actions
123 lines (104 loc) · 3.28 KB
/
settings.example.py
File metadata and controls
123 lines (104 loc) · 3.28 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
"""Django settings for doi-ui project."""
from pathlib import Path
# Website title.
UNIVERSITY = "University of Pennsylvania"
WEBSITE_TITLE = 'DOI'
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent
SECRET_KEY = 'xxx'
DEBUG = False
ALLOWED_HOSTS = ("doi.ericoc.com",)
# Logging.
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"handlers": {
"console": {
"class": "logging.StreamHandler",
},
},
"root": {
"handlers": ["console"],
"level": "DEBUG" if DEBUG else "INFO",
},
}
# Caching.
if DEBUG:
CACHE_BACKEND = "django.core.cache.backends.dummy.DummyCache"
else:
CACHE_BACKEND = "django.core.cache.backends.filebased.FileBasedCache"
CACHES = {
"default": {
"BACKEND": CACHE_BACKEND,
"LOCATION": Path(BASE_DIR, "cache"),
}
}
# CSRF and session cookies.
CSRF_COOKIE_HTTPONLY = SESSION_COOKIE_HTTPONLY = True
CSRF_COOKIE_SAMESITE = SESSION_COOKIE_SAMESITE = 'Lax'
CSRF_COOKIE_SECURE = SESSION_COOKIE_SECURE = False
CSRF_TRUSTED_ORIGINS = (f'http://{ALLOWED_HOSTS[0]}/',)
# E-mail.
ADMINS = MANAGERS = (('Eric OC', 'eric@ericoc.com'),)
DEFAULT_FROM_EMAIL = SERVER_EMAIL = 'doi@' + ALLOWED_HOSTS[0]
EMAIL_SUBJECT_PREFIX = f'[Django: {WEBSITE_TITLE}] '
EMAIL_HOST = 'localhost'
EMAIL_PORT = 25
EMAIL_HOST_USER = EMAIL_HOST_PASSWORD = None
# Application definition.
INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'apps.core.CoreConfig',
'apps.doi.DOIConfig',
]
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.cache.UpdateCacheMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.cache.FetchFromCacheMiddleware",
"django.middleware.locale.LocaleMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]
ROOT_URLCONF = 'urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': (Path(BASE_DIR, 'apps/core/templates/'),),
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.messages.context_processors.messages',
'apps.core.contexts.context_processors',
],
'libraries': {
'doi': 'apps.core.templatetags'
},
},
},
]
WSGI_APPLICATION = 'wsgi.application'
# Internationalization
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'America/New_York'
USE_I18N = True
USE_THOUSAND_SEPARATOR = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
STATIC_URL = 'static/'
STATIC_ROOT = Path(BASE_DIR, STATIC_URL)
# Media files.
MEDIA_URL = 'media/'
MEDIA_ROOT = Path(BASE_DIR, MEDIA_URL)
X_FRAME_OPTIONS = 'SAMEORIGIN'
# ORCID API settings.
ORCID_API_CLIENT_ID = "APP-0123ABCDEFG"
ORCID_API_CLIENT_SECRET = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
REQUEST_HEADERS = {"User-Agent": f"DOI Search / {WEBSITE_TITLE} v2.0"}
REQUEST_TIMEOUT = 5