· 8 years ago · Jan 19, 2018, 11:20 PM
1# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
2import os
3
4from decouple import config, Csv
5from dj_database_url import parse as db_url
6
7BASE_DIR = os.path.dirname(os.path.dirname(__file__))
8
9# Quick-start development settings - unsuitable for production
10# See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/
11
12# SECURITY WARNING: keep the secret key used in production secret!
13SECRET_KEY = config('SECRET_KEY')
14
15# SECURITY WARNING: don't run with debug turned on in production!
16DEBUG = config('DEBUG', default=False, cast=bool)
17
18INTERNAL_IPS = config('INTERNAL_IPS', default='', cast=Csv())
19
20ALLOWED_HOSTS = config('ALLOWED_HOSTS', default='', cast=Csv())
21
22# Application definition
23
24DJANGO_APPS = (
25 'django.contrib.admin',
26 'django.contrib.auth',
27 'django.contrib.contenttypes',
28 'django.contrib.sessions',
29 'django.contrib.messages',
30 'django.contrib.sites',
31 'django.contrib.staticfiles',
32 'django.contrib.sitemaps',
33)
34
35THIRD_PARTS_APPS = (
36 'compressor',
37 'corsheaders',
38 'crispy_forms',
39 'easy_thumbnails',
40 'opbeat.contrib.django',
41 'password_reset',
42 'rest_framework',
43 'social_django',
44)
45
46PROJECT_APPS = (
47 'cities',
48 'common',
49 'meupet',
50 'users',
51)
52
53INSTALLED_APPS = DJANGO_APPS + PROJECT_APPS + THIRD_PARTS_APPS
54
55SITE_ID = 1
56
57MIDDLEWARE_CLASSES = (
58 'opbeat.contrib.django.middleware.OpbeatAPMMiddleware',
59 'django.contrib.sessions.middleware.SessionMiddleware',
60 'corsheaders.middleware.CorsMiddleware',
61 'django.middleware.common.CommonMiddleware',
62 'django.middleware.csrf.CsrfViewMiddleware',
63 'django.contrib.auth.middleware.AuthenticationMiddleware',
64 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
65 'django.contrib.messages.middleware.MessageMiddleware',
66 'django.middleware.clickjacking.XFrameOptionsMiddleware',
67)
68
69PROJECT_TEMPLATE_LOADERS = [
70 'django.template.loaders.filesystem.Loader',
71 'django.template.loaders.app_directories.Loader',
72]
73
74TEMPLATES = [
75 {
76 'BACKEND': 'django.template.backends.django.DjangoTemplates',
77 'DIRS': [
78 os.path.join(BASE_DIR, '../templates'),
79 ],
80 'OPTIONS': {
81 'context_processors': [
82 'django.contrib.auth.context_processors.auth',
83 'django.template.context_processors.debug',
84 'django.template.context_processors.i18n',
85 'django.template.context_processors.media',
86 'django.template.context_processors.static',
87 'django.template.context_processors.tz',
88 'django.contrib.messages.context_processors.messages',
89 'social_django.context_processors.backends',
90 'social_django.context_processors.login_redirect',
91 'meupet.context_processors.pets_count',
92 'meupet.context_processors.kinds_count',
93 'users.context_processors.users_count',
94 ],
95 'loaders': [
96 ('django.template.loaders.cached.Loader', PROJECT_TEMPLATE_LOADERS),
97 ],
98 },
99 },
100]
101
102AUTHENTICATION_BACKENDS = (
103 'social_core.backends.facebook.FacebookOAuth2',
104 'social_core.backends.twitter.TwitterOAuth',
105 'django.contrib.auth.backends.ModelBackend',
106)
107
108SOCIAL_AUTH_PIPELINE = (
109 'social_core.pipeline.social_auth.social_details',
110 'social_core.pipeline.social_auth.social_uid',
111 'social_core.pipeline.social_auth.auth_allowed',
112 'social_core.pipeline.social_auth.social_user',
113 'social_core.pipeline.user.get_username',
114 'social_core.pipeline.user.create_user',
115 'users.pipeline.add_facebook_link',
116 'social_core.pipeline.social_auth.associate_user',
117 'social_core.pipeline.social_auth.load_extra_data',
118 'social_core.pipeline.user.user_details',
119)
120
121ROOT_URLCONF = 'pets.urls'
122
123WSGI_APPLICATION = 'pets.wsgi.application'
124
125# Database
126# https://docs.djangoproject.com/en/dev/ref/settings/#databases
127
128conn_max_age = config('DB_CONN_MAX_AGE', default=0, cast=int)
129default_db_url = config('DATABASE_URL')
130DATABASES = {
131 'default': postgres://postgres:caca12caca@127.0.0.1:5432/web
132}
133
134# Internationalization
135# https://docs.djangoproject.com/en/dev/topics/i18n/
136
137LANGUAGE_CODE = 'pt-BR'
138
139TIME_ZONE = 'America/Sao_Paulo'
140
141USE_I18N = True
142
143USE_L10N = True
144
145USE_TZ = True
146
147# Static files (CSS, JavaScript, Images)
148# https://docs.djangoproject.com/en/dev/howto/static-files/
149
150STATIC_URL = '/static/'
151
152# Setting static folder for site-wide files
153STATICFILES_DIRS = (
154 os.path.join(BASE_DIR, '../static'),
155)
156
157# static root folder, where static files will be collected to
158STATIC_ROOT = os.path.join(BASE_DIR, '../../static_root')
159
160LOCALE_PATHS = [
161 os.path.join(BASE_DIR, '../locale')
162]
163
164STATICFILES_FINDERS = [
165 "django.contrib.staticfiles.finders.FileSystemFinder",
166 "django.contrib.staticfiles.finders.AppDirectoriesFinder",
167 "compressor.finders.CompressorFinder"
168]
169
170COMPRESS_OFFLINE = True
171
172# Setting media configuration
173MEDIA_URL = '/media/'
174MEDIA_ROOT = os.path.join(BASE_DIR, '../../media')
175
176# Setting easy_thumbnails
177THUMBNAIL_ALIASES = {
178 '': {
179 'pet_thumb': {'size': (350, 350), 'crop': True, 'upscale': True},
180 'pet_poster': {'size': (550, 550), 'crop': True, 'upscale': True},
181 }
182}
183
184THUMBNAIL_BASEDIR = 'pet_thumbs'
185
186LOGIN_URL = 'users:login'
187
188CRISPY_TEMPLATE_PACK = 'bootstrap3'
189
190AUTH_USER_MODEL = 'users.OwnerProfile'
191
192CITIES_DATA_LOCATION = os.path.join(BASE_DIR, '../../data/cities_data')
193
194# Authentication
195LOGIN_REDIRECT_URL = 'meupet:index'
196LOGOUT_REDIRECT_URL = LOGIN_REDIRECT_URL
197
198SOCIAL_AUTH_LOGIN_REDIRECT_URL = 'users:confirm_information'
199
200SOCIAL_AUTH_FACEBOOK_SCOPE = [
201 'email',
202]
203
204# Number of days used to consider a register staled
205DAYS_TO_STALE_REGISTER = config('DAYS_TO_STALE_REGISTER', default=90, cast=int)
206
207SOCIAL_AUTH_FACEBOOK_KEY = config('SOCIAL_AUTH_FACEBOOK_KEY', default='')
208SOCIAL_AUTH_FACEBOOK_SECRET = config('SOCIAL_AUTH_FACEBOOK_SECRET', default='')
209
210SOCIAL_AUTH_TWITTER_KEY = config('SOCIAL_AUTH_TWITTER_KEY', default='')
211SOCIAL_AUTH_TWITTER_SECRET = config('SOCIAL_AUTH_TWITTER_SECRET', default='')
212
213FACEBOOK_SHARE_URL = 'https://www.facebook.com/sharer.php?u=http://cademeubicho.com/pets/{}/'
214TWITTER_SHARE_URL = 'https://twitter.com/share?url=http://cademeubicho.com/pets/{}/'
215
216OPBEAT = {
217 'ORGANIZATION_ID': config('OPBEAT_ORGANIZATION_ID', default=''),
218 'APP_ID': config('OPBEAT_APP_ID', default=''),
219 'SECRET_TOKEN': config('OPBEAT_SECRET_TOKEN', default=''),
220}
221
222SENDGRID_API_KEY = config('SENDGRID_API_KEY', default='')
223DEFAULT_FROM_EMAIL = config('EMAIL_HOST_USER', default='dummy@example.com')
224
225CORS_ORIGIN_ALLOW_ALL = True
226CORS_URLS_REGEX = r'^/api/.*$'
227
228REST_FRAMEWORK = {
229 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
230 'PAGE_SIZE': 20
231}