-
Notifications
You must be signed in to change notification settings - Fork 74
/
settings.py
214 lines (177 loc) · 6.64 KB
/
settings.py
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
# -*- coding: utf-8 -*-
import os
import sys
import re
import datetime
sys.path.insert(0, 'lib')
DEBUG = ("DEBUG" in os.environ)
INTERNAL_IPS = ('127.0.0.1',)
ADMINS = []
MANAGERS = ADMINS
if DEBUG and "SSH_CONNECTION" in os.environ:
# When launched from an SSH session, add the remote host to
# the list of INTERNAL_IPSs so that he can see the SQL.
# debugging output.
INTERNAL_IPS = ('127.0.0.1', os.environ["SSH_CONNECTION"].split(" ")[0])
if sys.argv == ['./manage.py', 'runserver']: print("Internal IPs:", repr(INTERNAL_IPS))
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/New_York'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = 'media'
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = '/media/'
STATIC_URL = '/static/'
STATICFILES_DIRS = ['static']
# django-regitration-pv
APP_NICE_SHORT_NAME = "GovTrack" # a short name for your site
SITE_ROOT_URL = "https://www.govtrack.us"
LOGIN_REDIRECT_URL = "/accounts/profile"
SERVER_EMAIL = "GovTrack.us <noreply@alerts.GovTrack.us>" # From: address on verification emails, error emails
DEFAULT_FROM_EMAIL = SERVER_EMAIL # send_email management command
REGISTRATION_ASK_USERNAME = False
SECURE_PROXY_SSL_HEADER = ("HTTPS", "on")
SESSION_COOKIE_AGE = 6*604800 # seconds in six weeks
SESSION_COOKIE_SECURE = not DEBUG # send session cookies over SSL only
CSRF_COOKIE_SECURE = not DEBUG # similarly
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer' # needed by openid login
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
EMAIL_SUBJECT_PREFIX = '[GovTrack] '
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django_otp.middleware.OTPMiddleware', # must be after AuthenticationMiddleware
'django.contrib.messages.middleware.MessageMiddleware',
#'debug_toolbar.middleware.DebugToolbarMiddleware',
'twostream.middleware.CacheLogic',
'website.middleware.GovTrackMiddleware',
]
ROOT_URLCONF = 'urls'
INSTALLED_APPS = [
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.humanize',
'django.contrib.sitemaps',
'django.contrib.staticfiles',
'django.contrib.messages',
# 3rd party libraries
'common',
#'south',
#'debug_toolbar',
#'silk',
'crispy_forms',
'django_otp',
'django_otp.plugins.otp_totp',
#'django_otp.plugins.otp_static', # necessary for bootstrapping access to the admin
'markdownx',
'haystack',
'htmlemailer',
# project modules
'twostream',
'simplegetapi',
'person',
'committee',
'website',
'vote',
'parser',
'events',
'smartsearch',
'bill',
'oversight',
'userpanels',
# for django-registration-pv
'emailverification',
'registration',
]
# in production...
try:
import django_mysql
INSTALLED_APPS.append("django_mysql")
except ImportError:
pass
AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.ModelBackend', # only used for the admin but the default admin page is hidden by the OTP login so not used directly, but the OTP login depends on this backend to do the password check
'registration.views.EmailPasswordLoginBackend', # regular login
'registration.views.DirectLoginBackend', # social login
]
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['templates'],
'OPTIONS': {
'debug': DEBUG,
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.template.context_processors.static',
'events.middleware.template_context_processor',
'website.middleware.template_context_processor',
],
'loaders': [
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
],
},
},
]
CRISPY_TEMPLATE_PACK = 'bootstrap3'
TEST_DATABASE_CHARSET = 'utf8'
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
DATETIME_FORMAT = 'M j, Y P'
DATE_FORMAT = 'M j, Y'
SEND_BROKEN_LINK_EMAILS = False
IGNORABLE_404_ENDS = ('spinner.gif', 'billtext/images/quote.png')
IGNORABLE_404_STARTS = ('/phpmyadmin/',)
import re
IGNORABLE_404_URLS = (
re.compile(r'^/phpmyadmin/'),
re.compile(r'spinner\.gif'),
re.compile(r'billtext/images/quote.png$'),
)
CURRENT_CONGRESS = 118
CURRENT_ELECTION_DATE = datetime.date(2024, 11, 8)
EMAIL_UPDATES_FROMADDR = "GovTrack.us Email Updates <noreply@alerts.GovTrack.us>"
EMAIL_UPDATES_RETURN_PATH = "GovTrack.us Email Updates <bounces+uid=%d@alerts.GovTrack.us>"
# Load settings from the environment
from settings_env import *
if not SECRET_KEY:
raise Exception('You must provide SECRET_KEY value in an env variable')
# Since we rely on external APIs in a few places, make sure
# that downed APIs elsewhere don't hold us too long. Not
# sure this has any useful effect. Also affects outbound SMTP?
import socket
socket.setdefaulttimeout(20.0)
# Restrict silk profile information to staff users. Don't
# log request/response bodies because we will go crazy in
# production.
SILKY_AUTHENTICATION = True
SILKY_AUTHORISATION = True
SILKY_MAX_REQUEST_BODY_SIZE = 0
SILKY_MAX_RESPONSE_BODY_SIZE = 0
SILKY_META = True
SILKY_INTERCEPT_PERCENT = 1
SILKY_PYTHON_PROFILER = True
SHOW_TOOLBAR_CALLBACK = lambda : True
OTP_TOTP_ISSUER = "GovTrack.us"
MARKDOWNX_MARKDOWNIFY_FUNCTION = 'website.templatetags.govtrack_utils.markdown'