Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.93 KB | None | 0 0
  1. # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  2. import os
  3.  
  4. from decouple import config, Csv
  5. from dj_database_url import parse as db_url
  6.  
  7. BASE_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!
  13. SECRET_KEY = config('SECRET_KEY')
  14.  
  15. # SECURITY WARNING: don't run with debug turned on in production!
  16. DEBUG = config('DEBUG', default=False, cast=bool)
  17.  
  18. INTERNAL_IPS = config('INTERNAL_IPS', default='', cast=Csv())
  19.  
  20. ALLOWED_HOSTS = config('ALLOWED_HOSTS', default='', cast=Csv())
  21.  
  22. # Application definition
  23.  
  24. DJANGO_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.  
  35. THIRD_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.  
  46. PROJECT_APPS = (
  47. 'cities',
  48. 'common',
  49. 'meupet',
  50. 'users',
  51. )
  52.  
  53. INSTALLED_APPS = DJANGO_APPS + PROJECT_APPS + THIRD_PARTS_APPS
  54.  
  55. SITE_ID = 1
  56.  
  57. MIDDLEWARE_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.  
  69. PROJECT_TEMPLATE_LOADERS = [
  70. 'django.template.loaders.filesystem.Loader',
  71. 'django.template.loaders.app_directories.Loader',
  72. ]
  73.  
  74. TEMPLATES = [
  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.  
  102. AUTHENTICATION_BACKENDS = (
  103. 'social_core.backends.facebook.FacebookOAuth2',
  104. 'social_core.backends.twitter.TwitterOAuth',
  105. 'django.contrib.auth.backends.ModelBackend',
  106. )
  107.  
  108. SOCIAL_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.  
  121. ROOT_URLCONF = 'pets.urls'
  122.  
  123. WSGI_APPLICATION = 'pets.wsgi.application'
  124.  
  125. # Database
  126. # https://docs.djangoproject.com/en/dev/ref/settings/#databases
  127.  
  128. conn_max_age = config('DB_CONN_MAX_AGE', default=0, cast=int)
  129. default_db_url = config('DATABASE_URL')
  130. DATABASES = {
  131. 'default': db_url(default_db_url, conn_max_age=conn_max_age)
  132. }
  133.  
  134. # Internationalization
  135. # https://docs.djangoproject.com/en/dev/topics/i18n/
  136.  
  137. LANGUAGE_CODE = 'pt-BR'
  138.  
  139. TIME_ZONE = 'America/Sao_Paulo'
  140.  
  141. USE_I18N = True
  142.  
  143. USE_L10N = True
  144.  
  145. USE_TZ = True
  146.  
  147. # Static files (CSS, JavaScript, Images)
  148. # https://docs.djangoproject.com/en/dev/howto/static-files/
  149.  
  150. STATIC_URL = '/static/'
  151.  
  152. # Setting static folder for site-wide files
  153. STATICFILES_DIRS = (
  154. os.path.join(BASE_DIR, '../static'),
  155. )
  156.  
  157. # static root folder, where static files will be collected to
  158. STATIC_ROOT = os.path.join(BASE_DIR, '../../static_root')
  159.  
  160. LOCALE_PATHS = [
  161. os.path.join(BASE_DIR, '../locale')
  162. ]
  163.  
  164. STATICFILES_FINDERS = [
  165. "django.contrib.staticfiles.finders.FileSystemFinder",
  166. "django.contrib.staticfiles.finders.AppDirectoriesFinder",
  167. "compressor.finders.CompressorFinder"
  168. ]
  169.  
  170. COMPRESS_OFFLINE = True
  171.  
  172. # Setting media configuration
  173. MEDIA_URL = '/media/'
  174. MEDIA_ROOT = os.path.join(BASE_DIR, '../../media')
  175.  
  176. # Setting easy_thumbnails
  177. THUMBNAIL_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.  
  184. THUMBNAIL_BASEDIR = 'pet_thumbs'
  185.  
  186. LOGIN_URL = 'users:login'
  187.  
  188. CRISPY_TEMPLATE_PACK = 'bootstrap3'
  189.  
  190. AUTH_USER_MODEL = 'users.OwnerProfile'
  191.  
  192. CITIES_DATA_LOCATION = os.path.join(BASE_DIR, '../../data/cities_data')
  193.  
  194. # Authentication
  195. LOGIN_REDIRECT_URL = 'meupet:index'
  196. LOGOUT_REDIRECT_URL = LOGIN_REDIRECT_URL
  197.  
  198. SOCIAL_AUTH_LOGIN_REDIRECT_URL = 'users:confirm_information'
  199.  
  200. SOCIAL_AUTH_FACEBOOK_SCOPE = [
  201. 'email',
  202. ]
  203.  
  204. # Number of days used to consider a register staled
  205. DAYS_TO_STALE_REGISTER = config('DAYS_TO_STALE_REGISTER', default=90, cast=int)
  206.  
  207. SOCIAL_AUTH_FACEBOOK_KEY = config('SOCIAL_AUTH_FACEBOOK_KEY', default='')
  208. SOCIAL_AUTH_FACEBOOK_SECRET = config('SOCIAL_AUTH_FACEBOOK_SECRET', default='')
  209.  
  210. SOCIAL_AUTH_TWITTER_KEY = config('SOCIAL_AUTH_TWITTER_KEY', default='')
  211. SOCIAL_AUTH_TWITTER_SECRET = config('SOCIAL_AUTH_TWITTER_SECRET', default='')
  212.  
  213. FACEBOOK_SHARE_URL = 'https://www.facebook.com/sharer.php?u=http://cademeubicho.com/pets/{}/'
  214. TWITTER_SHARE_URL = 'https://twitter.com/share?url=http://cademeubicho.com/pets/{}/'
  215.  
  216. OPBEAT = {
  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.  
  222. SENDGRID_API_KEY = config('SENDGRID_API_KEY', default='')
  223. DEFAULT_FROM_EMAIL = config('EMAIL_HOST_USER', default='dummy@example.com')
  224.  
  225. CORS_ORIGIN_ALLOW_ALL = True
  226. CORS_URLS_REGEX = r'^/api/.*$'
  227.  
  228. REST_FRAMEWORK = {
  229. 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
  230. 'PAGE_SIZE': 20
  231. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement