Snipt: Glitch Edition
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

138 lines
4.6KB

  1. from urllib.parse import urlparse
  2. import dj_database_url
  3. import os
  4. if "DATABASE_URL" in os.environ:
  5. DATABASES = {"default": dj_database_url.config()}
  6. ABSOLUTE_URL_OVERRIDES = {"auth.user": lambda u: "/%s/" % u.username}
  7. ACCOUNT_ACTIVATION_DAYS = 0
  8. ADMINS = (('Nick Sergeant', 'nick@snipt.net'),)
  9. ALLOWED_HOSTS = ['*']
  10. AUTH_PROFILE_MODULE = 'accounts.UserProfile'
  11. AUTHENTICATION_BACKENDS = ('utils.backends.EmailOrUsernameModelBackend',)
  12. BASE_PATH = os.path.dirname(__file__)
  13. CSRF_COOKIE_SECURE = True if "USE_SSL" in os.environ else False
  14. CORS_ORIGIN_ALLOW_ALL = True
  15. DEBUG = True if 'DEBUG' in os.environ else False
  16. DEFAULT_FROM_EMAIL = os.environ.get('POSTMARK_EMAIL', 'support@snipt.net')
  17. EMAIL_BACKEND = 'postmark.django_backend.EmailBackend'
  18. HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
  19. INTERNAL_IPS = ('127.0.0.1',)
  20. LANGUAGE_CODE = 'en-us'
  21. LOGIN_REDIRECT_URL = '/login-redirect/'
  22. LOGIN_URL = '/login/'
  23. LOGOUT_URL = '/logout/'
  24. MANAGERS = ADMINS
  25. MEDIA_ROOT = os.path.join(BASE_PATH, "media/uploads")
  26. MEDIA_URL = "/media/uploads/"
  27. MESSAGE_STORAGE = "django.contrib.messages.storage.cookie.CookieStorage"
  28. PASSWORD_HASHERS = (
  29. "django.contrib.auth.hashers.BCryptPasswordHasher",
  30. "django.contrib.auth.hashers.BCryptSHA256PasswordHasher",
  31. "django.contrib.auth.hashers.PBKDF2PasswordHasher",
  32. "django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher",
  33. "django.contrib.auth.hashers.SHA1PasswordHasher",
  34. "django.contrib.auth.hashers.MD5PasswordHasher",
  35. "django.contrib.auth.hashers.CryptPasswordHasher",
  36. )
  37. POSTMARK_API_KEY = os.environ.get("POSTMARK_API_KEY", "")
  38. PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
  39. REGISTRATION_EMAIL_HTML = False
  40. ROOT_URLCONF = "urls"
  41. SECRET_KEY = os.environ.get("SECRET_KEY", "changeme")
  42. SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
  43. SECURE_SSL_REDIRECT = True if "USE_SSL" in os.environ else False
  44. SEND_BROKEN_LINK_EMAILS = False
  45. SERVER_EMAIL = os.environ.get('POSTMARK_EMAIL', 'support@snipt.net')
  46. SESSION_COOKIE_AGE = 15801100
  47. SESSION_COOKIE_SECURE = True if "USE_SSL" in os.environ else False
  48. SITE_ID = 1
  49. STATICFILES_DIRS = (os.path.join(BASE_PATH, "media"),)
  50. STATICFILES_FINDERS = (
  51. "django.contrib.staticfiles.finders.FileSystemFinder",
  52. "django.contrib.staticfiles.finders.AppDirectoriesFinder",
  53. )
  54. STATICFILES_STORAGE = "whitenoise.django.GzipManifestStaticFilesStorage"
  55. STATIC_ROOT = os.path.join(BASE_PATH, "static")
  56. STATIC_URL = "/static/"
  57. TASTYPIE_CANNED_ERROR = """There was an error with your request. The site
  58. developers have a record of this error, please email api@snipt.net and
  59. we'll help you out."""
  60. TEMPLATES = [
  61. {
  62. "BACKEND": "django.template.backends.django.DjangoTemplates",
  63. "DIRS": [os.path.join(PROJECT_PATH, "templates")],
  64. "APP_DIRS": True,
  65. "OPTIONS": {
  66. "context_processors": [
  67. "django.template.context_processors.debug",
  68. "django.template.context_processors.request",
  69. "django.template.context_processors.static",
  70. "django.contrib.auth.context_processors.auth",
  71. "django.contrib.messages.context_processors.messages",
  72. ]
  73. },
  74. }
  75. ]
  76. TIME_ZONE = "America/New_York"
  77. USE_HTTPS = True if "USE_SSL" in os.environ else False
  78. USE_I18N = True
  79. USE_L10N = True
  80. USE_TZ = True
  81. INSTALLED_APPS = (
  82. "accounts",
  83. "blogs",
  84. "corsheaders",
  85. "django.contrib.admin",
  86. "django.contrib.auth",
  87. "django.contrib.contenttypes",
  88. "django.contrib.humanize",
  89. "django.contrib.messages",
  90. "django.contrib.sessions",
  91. "django.contrib.sites",
  92. "django.contrib.staticfiles",
  93. "django_extensions",
  94. "gunicorn",
  95. # "haystack",
  96. "markdown_deux",
  97. "pagination",
  98. "postmark",
  99. "registration",
  100. "snipts",
  101. "storages",
  102. "taggit",
  103. "tastypie",
  104. "teams",
  105. "user-admin",
  106. "utils",
  107. )
  108. LOGGING = {
  109. "version": 1,
  110. "disable_existing_loggers": False,
  111. "filters": {"require_debug_false": {"()": "django.utils.log.RequireDebugFalse"}},
  112. "handlers": {},
  113. "loggers": {},
  114. }
  115. MIDDLEWARE_CLASSES = (
  116. "django.middleware.security.SecurityMiddleware",
  117. "django.middleware.csrf.CsrfViewMiddleware",
  118. "django.middleware.clickjacking.XFrameOptionsMiddleware",
  119. "corsheaders.middleware.CorsMiddleware",
  120. "django.middleware.common.CommonMiddleware",
  121. "django.contrib.sessions.middleware.SessionMiddleware",
  122. "django.contrib.auth.middleware.AuthenticationMiddleware",
  123. "django.contrib.messages.middleware.MessageMiddleware",
  124. "pagination.middleware.PaginationMiddleware",
  125. "blogs.middleware.BlogMiddleware",
  126. )
  127. try:
  128. from settings_local import *
  129. except ImportError:
  130. pass