-
Notifications
You must be signed in to change notification settings - Fork 189
Expand file tree
/
Copy pathcommon.py
More file actions
252 lines (202 loc) · 6.68 KB
/
common.py
File metadata and controls
252 lines (202 loc) · 6.68 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
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
# Standard Library
import datetime
import os
from os.path import dirname, join
# Third Party Stuff
from django.conf.global_settings import * # noqa
from django.utils.translation import ugettext_lazy as _
# Build paths inside the project like this: os.path.join(ROOT_DIR, ...)
ROOT_DIR = dirname(dirname(__file__))
APP_DIR = join(ROOT_DIR, 'junction')
SITE_ID = 1
ADMINS = ()
# Absolute Url of frontend hosted site. Used to render the urls in templattes,
# static and media files appropriately. e.g 'https://in.pycon.org/junction'
SITE_URL = os.environ.get('SITE_URL', '').rstrip('/')
# General project information
# These are available in the template as SITE_INFO.<title>
dt = datetime.datetime.now()
SITE_VARIABLES = {
'site_name': os.environ.get('SITE_NAME', 'Junction'),
'site_description': 'Junction is a software to manage proposals, reviews, schedule, feedback during conference.',
'google_analytics_id': os.environ.get('GOOGLE_ANALYTICS_ID', None),
'site_url': SITE_URL,
'footer': '© {} • Python Software Society of India'.format(dt.year),
# Enables Facebook sharing of proposals
'facebook_app_id': os.environ.get('FACEBOOK_APP_ID', None),
}
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'simple_history.middleware.HistoryRequestMiddleware',
)
CORE_APPS = (
'flat', # https://github.com/elky/django-flat-theme
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.humanize',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.webdesign',
)
THIRD_PARTY_APPS = (
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.github',
'bootstrap3',
'pagedown',
'django_markdown',
'django_bootstrap_breadcrumbs',
'rest_framework',
'simple_history',
)
OUR_APPS = (
'junction.base',
'junction.conferences',
'junction.proposals',
'junction.schedule',
'junction.profiles',
'junction.devices',
'junction.tickets',
'junction.feedback',
)
INSTALLED_APPS = CORE_APPS + THIRD_PARTY_APPS + OUR_APPS
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(APP_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.request',
"django.contrib.auth.context_processors.auth",
"junction.base.context_processors.site_info",
],
'debug': DEBUG, # noqa
},
},
]
AUTHENTICATION_BACKENDS = (
# Needed to login by username in Django admin, regardless of `allauth`
"django.contrib.auth.backends.ModelBackend",
# `allauth` specific authentication methods, such as login by e-mail
"allauth.account.auth_backends.AuthenticationBackend",
)
ACCOUNT_AUTHENTICATION_METHOD = "username_email"
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = "mandatory"
ACCOUNT_EMAIL_SUBJECT_PREFIX = "[{}] ".format(SITE_VARIABLES['site_name'])
ACCOUNT_LOGOUT_ON_GET = True
ACCOUNT_DEFAULT_HTTP_PROTOCOL = 'https'
EMAIL_SUBJECT_PREFIX = ACCOUNT_EMAIL_SUBJECT_PREFIX
LOGIN_REDIRECT_URL = '/'
# E-Mail Settings
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.sendgrid.com'
EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER', ''),
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD', ''),
EMAIL_PORT = 587
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = SITE_VARIABLES['site_name'] + ' <noreply@pssi.org.in>'
BOOTSTRAP3 = {
'required_css_class': 'required',
}
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
},
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': 'debug.log',
},
},
'loggers': {
'django.request': {
'handlers': ['mail_admins', ],
'level': 'ERROR',
'propagate': True,
},
'django.db.backends': {
'level': 'DEBUG',
'handlers': ['file', ],
},
}
}
LANGUAGES = (
("en", _("English")),
)
ROOT_URLCONF = 'junction.urls'
WSGI_APPLICATION = 'wsgi.application'
ATOMIC_REQUESTS = True
TIME_ZONE = 'Asia/Kolkata'
LANGUAGE_CODE = "en"
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(APP_DIR, 'assets', 'collected-static')
STATICFILES_DIRS = (
os.path.join(APP_DIR, 'static'),
)
MEDIA_ROOT = join(ROOT_DIR, '.media')
MEDIA_URL = '/m/'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.environ.get('DB_NAME', ''),
'USER': os.environ.get('DB_USER', ''),
'PASSWORD': os.environ.get('DB_PASSWORD', ''),
'HOST': os.environ.get('DB_HOST', ''),
'PORT': os.environ.get('DB_PORT', ''),
}
}
SECRET_KEY = os.environ.get(
'SECRET_KEY',
'z^bd9lk)o!03n#9e_u87zidd1zt7*^_oc4v6t!@@86vtbu0*&j')
ALLOWED_HOSTS = [] # TODO:
SITE_PROTOCOL = 'http'
# MARKDOWN_EXTENSIONS = ['linkify']
# twitter settings
TWITTER_CONSUMER_KEY = os.environ.get('TWITTER_CONSUMER_KEY', None)
TWITTER_CONSUMER_SECRET = os.environ.get('TWITTER_CONSUMER_SECRET', None)
TWITTER_ACCESS_TOKEN_KEY = os.environ.get('TWITTER_ACCESS_TOKEN_KEY', None)
TWITTER_ACCESS_TOKEN_SECRET = os.environ.get(
'TWITTER_ACCESS_TOKEN_SECRET', None)
# Add connection life time
# Make sure DB request held on for minimim 5 minutes
CONN_MAX_AGE = 300
REST_FRAMEWORK = {
'DEFAULT_FILTER_BACKENDS': ('rest_framework.filters.DjangoFilterBackend',)
}
EXPLARA_API_TOKEN = "shjbalkfbdskjlbdskljbdskaljfb"
QR_CODES_DIR = ROOT_DIR + '/qr_files'
USE_ASYNC_FOR_EMAIL = False
USER_SPAM_THRESHOLD = 2
SPAM_MODERATION_ADMINS = []