Advertisement
Guest User

Error

a guest
Mar 23rd, 2016
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.46 KB | None | 0 0
  1. """
  2. For more information on this file, see
  3. https://docs.djangoproject.com/en/1.8/topics/settings/
  4.  
  5. For the full list of settings and their values, see
  6. https://docs.djangoproject.com/en/1.8/ref/settings/
  7. """
  8.  
  9. DEBUG = True
  10.  
  11. # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  12. import os
  13. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  14.  
  15. # Quick-start development settings - unsuitable for production
  16. # See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
  17.  
  18. SECRET_KEY = os.environ.get("SECRET_KEY", 'km68=u49mi9y3$_yr%6g_jtngq@i^8-1ptag&((c6002q$p&rb')
  19.  
  20. ALLOWED_HOSTS = ["*"]
  21.  
  22. WSGI_APPLICATION = 'ModmailTicketer.wsgi.application'
  23. USE_X_FORWARDED_HOST = not DEBUG
  24.  
  25. # Logging
  26. if not DEBUG:
  27. LOGGING = {
  28. 'version': 1,
  29. 'disable_existing_loggers': False,
  30. 'formatters': {
  31. 'verbose': {
  32. 'format': '%(asctime)s %(levelname)s [%(name)s:%(lineno)s] %(module)s %(process)d %(thread)d %(message)s'
  33. }
  34. },
  35. 'handlers': {
  36. 'django_log': {
  37. 'level': 'DEBUG',
  38. 'class': 'logging.handlers.RotatingFileHandler',
  39. 'formatter': 'verbose',
  40. 'filename': '/root/web/ModmailTicketer/logs/django.log',
  41. 'maxBytes': 1024 * 1024 * 10, # 10 mb
  42. }
  43. },
  44. 'loggers': {
  45. 'django': {
  46. 'level': 'INFO',
  47. 'handlers': ['django_log'],
  48. 'propagate': True,
  49. },
  50. 'django.request': {
  51. 'level': 'INFO',
  52. 'handlers': ['django_log'],
  53. 'propagate': False,
  54. },
  55. 'django.security': {
  56. 'level': 'INFO',
  57. 'handlers': ['django_log'],
  58. 'propagate': False,
  59. },
  60. }
  61. }
  62.  
  63. # Application definition
  64.  
  65. INSTALLED_APPS = (
  66. 'django.contrib.admin',
  67. 'django.contrib.auth',
  68. 'django.contrib.contenttypes',
  69. 'django.contrib.sessions',
  70. 'django.contrib.messages',
  71. 'django.contrib.staticfiles',
  72. 'django_jinja',
  73. 'social.apps.django_app.default',
  74. 'widget_tweaks',
  75. 'main'
  76. )
  77.  
  78. MIDDLEWARE_CLASSES = (
  79. 'django.contrib.sessions.middleware.SessionMiddleware',
  80. 'django.middleware.common.CommonMiddleware',
  81. 'django.middleware.csrf.CsrfViewMiddleware',
  82. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  83. 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
  84. 'django.contrib.messages.middleware.MessageMiddleware',
  85. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  86. 'django.middleware.security.SecurityMiddleware',
  87. )
  88.  
  89. AUTHENTICATION_BACKENDS = (
  90. 'social.backends.reddit.RedditOAuth2',
  91. )
  92.  
  93. SOCIAL_AUTH_PIPELINE = (
  94. 'social.pipeline.social_auth.social_details',
  95. 'social.pipeline.social_auth.social_uid',
  96. 'social.pipeline.social_auth.auth_allowed',
  97. 'social.pipeline.social_auth.social_user',
  98. 'social.pipeline.user.get_username',
  99. 'social.pipeline.user.create_user',
  100. 'main.func.auth_util.create_user_from_oauth',
  101. 'social.pipeline.social_auth.associate_user',
  102. 'social.pipeline.social_auth.load_extra_data',
  103. 'social.pipeline.user.user_details'
  104. )
  105.  
  106. ROOT_URLCONF = 'ModmailTicketer.urls'
  107.  
  108. TEMPLATES = [
  109. {
  110. # See: http://niwinz.github.io/django-jinja/#_user_guide_for_django_1_8
  111. "BACKEND": "django_jinja.backend.Jinja2",
  112. "APP_DIRS": True,
  113. "DIRS": [os.path.join(BASE_DIR, 'templates'),],
  114. "OPTIONS": {
  115. "match_extension": ".jinja",
  116. "trim_blocks": True,
  117. "lstrip_blocks": True,
  118. }
  119. },
  120. {
  121. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  122. 'DIRS': [],
  123. 'APP_DIRS': True,
  124. 'OPTIONS': {
  125. 'context_processors': [
  126. 'django.template.context_processors.debug',
  127. 'django.template.context_processors.request',
  128. 'django.contrib.auth.context_processors.auth',
  129. 'django.contrib.messages.context_processors.messages',
  130. ],
  131. },
  132. },
  133. ]
  134.  
  135. TEMPLATE_DIRS = (
  136. os.path.join(BASE_DIR, 'templates'),
  137. )
  138.  
  139. TEMPLATE_LOADERS = (
  140. 'django_jinja.loaders.AppLoader',
  141. 'django_jinja.loaders.FileSystemLoader',
  142. )
  143.  
  144.  
  145. # Login configuration
  146.  
  147. LOGIN_URL = "main:login"
  148. LOGIN_REDIRECT_URL = "/"
  149.  
  150.  
  151. # Database
  152. # https://docs.djangoproject.com/en/1.8/ref/settings/#databases
  153.  
  154. import dj_database_url
  155. db_from_env = dj_database_url.config()
  156. DATABASES = {
  157. 'default': {
  158. 'ENGINE': 'django.db.backends.sqlite3',
  159. 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
  160. }
  161. }
  162. DATABASES['default'].update(db_from_env)
  163.  
  164.  
  165. # Internationalization v2
  166.  
  167. # https://docs.djangoproject.com/en/1.8/topics/i18n/
  168.  
  169. LANGUAGE_CODE = 'en-us'
  170.  
  171. TIME_ZONE = 'UTC'
  172.  
  173. USE_I18N = False
  174.  
  175. USE_L10N = False
  176.  
  177. USE_TZ = True
  178.  
  179.  
  180. # Static files (CSS, JavaScript, Images)
  181. # https://docs.djangoproject.com/en/1.8/howto/static-files/
  182.  
  183. STATIC_ROOT = os.path.join(BASE_DIR, 'static_public')
  184. STATIC_URL = '/static/'
  185.  
  186. STATICFILES_DIRS = (
  187. os.path.join(BASE_DIR, "static"),
  188. )
  189.  
  190. STATICFILES_FINDERS = (
  191. 'django.contrib.staticfiles.finders.FileSystemFinder',
  192. 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  193. )
  194.  
  195. STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
  196.  
  197. if 'SSL_ONLY' in os.environ and os.environ['SSL_ONLY'] == "1":
  198. SECURE_SSL_REDIRECT = True
  199. SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
  200.  
  201. # ticketer specific configs
  202. if 'SOCIAL_AUTH_REDDIT_KEY' not in os.environ or 'SOCIAL_AUTH_REDDIT_SECRET' not in os.environ:
  203. raise Exception("You need to set social keys in your env. Either do it on the command line\
  204. \nor set it in .env and use `heroku local:run !!` to run this")
  205.  
  206. REDDIT_USERAGENT = "S01780"
  207. REDDIT_OAUTH_SCOPES = {"identity", "privatemessages"}
  208.  
  209. SOCIAL_AUTH_REDDIT_KEY = os.environ['SOCIAL_AUTH_REDDIT_KEY']
  210. SOCIAL_AUTH_REDDIT_SECRET = os.environ['SOCIAL_AUTH_REDDIT_SECRET']
  211. SOCIAL_AUTH_REDDIT_AUTH_EXTRA_ARGUMENTS = {"duration": "permanent", "scope": ",".join(REDDIT_OAUTH_SCOPES)}
  212. SOCIAL_AUTH_REDDIT_REDIRECT = "https://reddit-modmail-ticketer.herokuapp.com/complete/reddit/"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement