/
settings.py
328 lines (269 loc) · 9.97 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
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# -*- coding: utf-8 -*-
# Django settings for gcd project.
import datetime
from os.path import abspath, dirname, join
from os import environ # helps determine MEDIA_URL.
"""
This is the main settings file. It should not be changed unless the change
is meant to apply to all installations, development and production, of the project.
In order to make local changes for your particular environment, create
a file called "settings_local.py" in the same directory. You can override
the contents of any variable. Go through the comments in this file to see
which variables you can or must override.
"""
#################################################################################
# Standard Django settings
#################################################################################
# disable on production!
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ALLOWED_HOSTS = [
'.comics.org',
'.comics.org.', # Allow FQDN and subdomains. Can be dropped in 1.7
]
# absolute path to the directory that holds templates.
TEMPLATE_DIRS = ( abspath(join(dirname(__file__), 'templates')),
abspath(join(dirname(__file__), 'apps', 'voting', 'templates')),)
# absolute path to the directory that holds media.
# URL that handles the media served from MEDIA_ROOT.
MEDIA_ROOT = abspath(join(dirname(__file__), 'media'))
MEDIA_URL = '/site_media/'
# We're not using django.contrib.staticfiles yet, but the admin site
# is happier with a STATIC_URL.
STATIC_URL = MEDIA_URL
# Database settings. Override yours in a settings_local.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'gcdonline',
'USER': 'gcdonline',
'PASSWORD': '',
'HOST': '',
'PORT': '',
},
}
# middleware settings, LocalMiddleware is for internationalisation
MIDDLEWARE_CLASSES = (
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.transaction.TransactionMiddleware',
'django_mobile.middleware.MobileDetectionMiddleware',
'django_mobile.middleware.SetFlavourMiddleware',
'apps.gcd.locale_query.LocaleQueryMiddleware'
)
LANGUAGES = (
('de', 'German'),
('en', 'English'),
)
# The router where all our site URLs is defined.
ROOT_URLCONF = 'urls'
# Email these if there's a site exception and debug isn't on.
ADMINS = (
('GCD Admins', 'sysadmin@comics.org'),
)
MANAGERS = ADMINS
# All enabled apps for this install.
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'django.contrib.humanize',
'django.contrib.sites',
'django.contrib.messages',
'django_mobile',
'apps.gcd',
'apps.oi',
'apps.voting',
'compressor',
'templatesadmin',
'taggit',
'imagekit',
'south',
'haystack',
'elasticstack',
)
# Used to provide a seed in secret-key hashing algorithms.
# Overridden in production via settings_local.py.
SECRET_KEY = 'th0lnu%wjs_8=r4u_km3shvogzd%1n)t-5eosi964g0ek+a4p+'
# Callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django_mobile.loader.Loader',
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.request',
'django.core.context_processors.static',
'django_mobile.context_processors.flavour',
'apps.gcd.context_processors.gcd',
)
AUTH_PROFILE_MODULE = 'gcd.Indexer'
AUTHENTICATION_BACKENDS = (
'apps.gcd.backends.EmailBackend',
'django.contrib.auth.backends.ModelBackend',
)
ABSOLUTE_URL_OVERRIDES = {
'auth.user': lambda o: "/accounts/profile/%d/" % o.id,
}
# for local installations, who don't have memcached, put this:
#CACHES = {
# 'default': {
# 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
# 'LOCATION': 'unique-snowflake'
# }
#}
# in your settings_local.py as an override.
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
}
}
# have two choices for caches, this one has persistent, cached session data
SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'
# Corresponds to the django_site database table. As far
# as I know, we won't be using this for the GCD.
SITE_ID = 1
# Local time zone for this installation. Choices can be found here:
# http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
TIME_ZONE = 'UTC'
# International DateTime string format
DATETIME_FORMAT = 'Y-m-d H:i:s'
#################################################################################
# 3rd-party app settings
#################################################################################
COMPRESS_CSS_FILTERS = ['compressor.filters.css_default.CssAbsoluteFilter',
'compressor.filters.csstidy.CSSTidyFilter']
# for front page editing
TEMPLATESADMIN_TEMPLATE_DIRS = [abspath(join(dirname(__file__),
'templates/gcd/front_page/')),]
TEMPLATESADMIN_GROUP = 'prteam'
#################################################################################
# Haystack and search
#################################################################################
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'elasticstack.backends.ConfigurableElasticSearchEngine',
'URL': 'http://127.0.0.1:9200/',
'INDEX_NAME': 'haystack',
'INCLUDE_SPELLING': True,
},
}
ELASTICSEARCH_INDEX_SETTINGS = {
# index settings
'settings': {
"analysis": {
"analyzer": {
"default": {
"type": "custom",
"tokenizer": "standard",
"filter": ["standard", "lowercase", "stop", "asciifolding"]
}
}
}
}
}
ELASTICSEARCH_DEFAULT_ANALYZER = 'default'
USE_ELASTICSEARCH = False
#################################################################################
# GCD site settings
#################################################################################
###
# Debugging and development environment settings
BETA = False
ADVERTISING = True
CALENDAR = True
# Set to True to avoid hitting comics.org for every cover image.
# If True, the same cover image will be used for every issue.
FAKE_COVER_IMAGES = False
# site management defaults- change these in settings_local.py as needed.
SITE_DOWN = False
SITE_DOWN_MESSAGE = ''
SITE_BACK_UP_AT = ''
READ_ONLY = False
NO_OI = False
###
# General GCD site settings
DEFAULT_FROM_EMAIL = 'GCD Contact <contact@comics.org>'
EMAIL_NEW_ACCOUNTS_FROM = 'GCD New Accounts <new.accounts@comics.org>'
EMAIL_EDITORS = 'gcd-editor@googlegroups.com'
EMAIL_PRTEAM = 'pr-team@comics.org'
EMAIL_CONTACT = 'contact@comics.org'
EMAIL_INDEXING = 'GCD Online Indexing <no-reply@comics.org>'
CHAIRMAN = 'Don Milne'
EMAIL_CHAIRMAN = '%s <chair@comics.org>' % CHAIRMAN
# Number of days for which a registraton confirmation token is valid.
REGISTRATION_EXPIRATION_DELTA = 2
# These will do for new users only until the Board finishes setting the policy.
# Pre-Vieux Bois users have very high numbers set via migration script.
RESERVE_MAX_INITIAL = 1
RESERVE_MAX_PROBATION = 6 # half-year monthly miniseries
RESERVE_MAX_DEFAULT = 12 # full year of a monthly
RESERVE_MAX_ONGOING_INITIAL = 0
RESERVE_MAX_ONGOING_PROBATION = 2
RESERVE_MAX_ONGOING_DEFAULT = 4
MEMBERSHIP_IMPS = 4000
LIMIT_SYNOPSIS_LENGTH = 600
RECENTS_COUNT = 5
SITE_URL = 'http://www.comics.org/'
SITE_NAME = 'Grand Comics Database'
# image directories
IMAGE_SERVER_URL = 'http://images.comics.org/'
COVERS_DIR = '/img/gcd/covers_by_id/'
NEW_COVERS_DIR = '/img/gcd/new_covers/'
GENERIC_IMAGE_DIR = 'img/gcd/generic_images/'
NEW_GENERIC_IMAGE_DIR = 'img/gcd/new_generic_images/'
# Name of the directory in the gcd/icons tree under the media root
# to use for icons within the app.
ICON_SET = "gnome"
BLOCKED_DOMAINS = ('mailinator.com', 'mintemail.com', 'trash-mail.com')
ANON_USER_NAME = 'anon'
# Date taken from Ray's press release.
# These were primarily used for migrating change history and filling in blanks.
OLD_SITE_CREATION_DATE = datetime.date(2002, 11, 13)
NEW_SITE_CREATION_DATE = datetime.date(2009, 12, 1)
NEW_SITE_COVER_CREATION_DATE = datetime.datetime(2009,10,2,14,0,0)
###
# Voting app settings
EMAIL_VOTING_FROM = 'GCD Voting <voting@comics.org>'
EMAIL_VOTING_ADMIN = EMAIL_CONTACT
# absolute path to the directory that holds election files.
VOTING_DIR = abspath(join(dirname(__file__), 'voting'))
###
# Data dump settings
# data dump directories, relative to MEDIA_ROOT
DUMP_DIR = 'dumps'
MYSQL_DUMP = 'current.zip'
POSTGRES_DUMP = 'pg-current.zip'
# Amount of time that must pass before a user can download the same
# dump (or similar) file again, in minutes.
DOWNLOAD_DELTA = 5
#################################################################################
# settings_local usage
#################################################################################
# get local settings, will override settings from here
try:
from settings_local import *
except ImportError, exp:
pass
try:
import more_settings
more_settings.modify(globals())
except ImportError:
pass
#################################################################################
# Code dependent on debug or maintenance flag states.
#################################################################################
if READ_ONLY or NO_OI:
MIDDLEWARE_CLASSES += \
('apps.middleware.read_only.ReadOnlyMiddleware',)