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.

147 lines
3.9 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. """
  2. Django settings for hc project.
  3. Generated by 'django-admin startproject' using Django 1.8.2.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/1.8/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/1.8/ref/settings/
  8. """
  9. import os
  10. import warnings
  11. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  12. HOST = "localhost"
  13. SECRET_KEY = "---"
  14. DEBUG = True
  15. ALLOWED_HOSTS = []
  16. DEFAULT_FROM_EMAIL = '[email protected]'
  17. USE_PAYMENTS = False
  18. INSTALLED_APPS = (
  19. 'django.contrib.admin',
  20. 'django.contrib.auth',
  21. 'django.contrib.contenttypes',
  22. 'django.contrib.humanize',
  23. 'django.contrib.sessions',
  24. 'django.contrib.messages',
  25. 'django.contrib.staticfiles',
  26. 'compressor',
  27. 'djmail',
  28. 'hc.accounts',
  29. 'hc.api',
  30. 'hc.front',
  31. 'hc.payments'
  32. )
  33. MIDDLEWARE_CLASSES = (
  34. 'django.contrib.sessions.middleware.SessionMiddleware',
  35. 'django.middleware.common.CommonMiddleware',
  36. 'django.middleware.csrf.CsrfViewMiddleware',
  37. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  38. 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
  39. 'django.contrib.messages.middleware.MessageMiddleware',
  40. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  41. 'django.middleware.security.SecurityMiddleware',
  42. )
  43. AUTHENTICATION_BACKENDS = (
  44. 'hc.accounts.backends.EmailBackend',
  45. 'hc.accounts.backends.ProfileBackend'
  46. )
  47. ROOT_URLCONF = 'hc.urls'
  48. TEMPLATES = [
  49. {
  50. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  51. 'DIRS': [os.path.join(BASE_DIR, 'templates')],
  52. 'APP_DIRS': True,
  53. 'OPTIONS': {
  54. 'context_processors': [
  55. 'django.template.context_processors.debug',
  56. 'django.template.context_processors.request',
  57. 'django.contrib.auth.context_processors.auth',
  58. 'django.contrib.messages.context_processors.messages',
  59. 'hc.payments.context_processors.payments'
  60. ],
  61. },
  62. },
  63. ]
  64. WSGI_APPLICATION = 'hc.wsgi.application'
  65. TEST_RUNNER = 'hc.api.tests.CustomRunner'
  66. # Default database engine is SQLite. So one can just check out code,
  67. # install requirements.txt and do manage.py runserver and it works
  68. DATABASES = {
  69. 'default': {
  70. 'ENGINE': 'django.db.backends.sqlite3',
  71. 'NAME': './hc.sqlite',
  72. }
  73. }
  74. # You can switch database engine to postgres or mysql using environment
  75. # variable 'DB'. Travis CI does this.
  76. if os.environ.get("DB") == "postgres":
  77. DATABASES = {
  78. 'default': {
  79. 'ENGINE': 'django.db.backends.postgresql_psycopg2',
  80. 'NAME': 'hc',
  81. 'USER': 'postgres',
  82. 'TEST': {'CHARSET': 'UTF8'}
  83. }
  84. }
  85. if os.environ.get("DB") == "mysql":
  86. DATABASES = {
  87. 'default': {
  88. 'ENGINE': 'django.db.backends.mysql',
  89. 'USER': 'root',
  90. 'NAME': 'hc',
  91. 'TEST': {'CHARSET': 'UTF8'}
  92. }
  93. }
  94. LANGUAGE_CODE = 'en-us'
  95. TIME_ZONE = 'UTC'
  96. USE_I18N = True
  97. USE_L10N = True
  98. USE_TZ = True
  99. SITE_ROOT = "http://localhost:8000"
  100. PING_ENDPOINT = SITE_ROOT + "/ping/"
  101. PING_EMAIL_DOMAIN = HOST
  102. STATIC_URL = '/static/'
  103. STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")]
  104. STATIC_ROOT = os.path.join(BASE_DIR, 'static-collected')
  105. STATICFILES_FINDERS = (
  106. 'django.contrib.staticfiles.finders.FileSystemFinder',
  107. 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  108. 'compressor.finders.CompressorFinder',
  109. )
  110. COMPRESS_OFFLINE = True
  111. EMAIL_BACKEND = "djmail.backends.default.EmailBackend"
  112. # Pushover integration -- override these in local_settings
  113. PUSHOVER_API_TOKEN = None
  114. PUSHOVER_SUBSCRIPTION_URL = None
  115. PUSHOVER_EMERGENCY_RETRY_DELAY = 300
  116. PUSHOVER_EMERGENCY_EXPIRATION = 86400
  117. if os.path.exists(os.path.join(BASE_DIR, "hc/local_settings.py")):
  118. from .local_settings import *
  119. else:
  120. warnings.warn("local_settings.py not found, using defaults")