settings.py 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. # -*- coding: utf-8 -*-
  2. import os
  3. import ldap
  4. # Django settings for coin project.
  5. # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  6. BASE_DIR = os.path.dirname(os.path.dirname(__file__))
  7. PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
  8. DEBUG = TEMPLATE_DEBUG = False
  9. ADMINS = (
  10. # ('Your Name', 'your_email@example.com'),
  11. )
  12. MANAGERS = ADMINS
  13. # Instance LDAP de développement:
  14. # adresse du serveur : ldapdev.illyse.org
  15. # port ldap: 389
  16. # port ldaps: 636
  17. ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_NEVER)
  18. DATABASES = {
  19. # Base de donnée du SI
  20. 'default': {
  21. 'ENGINE': 'django.db.backends.postgresql_psycopg2',
  22. 'NAME': 'illyse_coin',
  23. 'USER': 'illyse_coin',
  24. 'PASSWORD': '',
  25. 'HOST': '', # Empty for localhost through domain sockets
  26. 'PORT': '', # Empty for default
  27. },
  28. # LDAP backend pour stockage et mise à jour de données
  29. 'ldap': {
  30. 'ENGINE': 'ldapdb.backends.ldap',
  31. 'NAME': 'ldap://ldapdev.illyse.org:389/',
  32. 'TLS': True,
  33. 'USER': 'cn=illysedev,ou=services,o=ILLYSE,l=Villeurbanne,st=RHA,c=FR',
  34. 'PASSWORD': 'gfj83-E8ECgGh23JK_Ol12'
  35. }
  36. }
  37. DATABASE_ROUTERS = ['ldapdb.router.Router']
  38. # Hosts/domain names that are valid for this site; required if DEBUG is False
  39. # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
  40. ALLOWED_HOSTS = []
  41. # Local time zone for this installation. Choices can be found here:
  42. # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
  43. # although not all choices may be available on all operating systems.
  44. # In a Windows environment this must be set to your system time zone.
  45. TIME_ZONE = 'Europe/Paris'
  46. # Language code for this installation. All choices can be found here:
  47. # http://www.i18nguy.com/unicode/language-identifiers.html
  48. LANGUAGE_CODE = 'fr-fr'
  49. SITE_ID = 1
  50. # If you set this to False, Django will make some optimizations so as not
  51. # to load the internationalization machinery.
  52. USE_I18N = True
  53. # If you set this to False, Django will not format dates, numbers and
  54. # calendars according to the current locale.
  55. USE_L10N = True
  56. # If you set this to False, Django will not use timezone-aware datetimes.
  57. USE_TZ = True
  58. # Default URL for login and logout
  59. LOGIN_URL = '/members/login'
  60. LOGIN_REDIRECT_URL = '/members'
  61. LOGOUT_URL = '/members/logout'
  62. # Absolute filesystem path to the directory that will hold user-uploaded files.
  63. # Example: "/var/www/example.com/media/"
  64. MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
  65. # URL that handles the media served from MEDIA_ROOT. Make sure to use a
  66. # trailing slash.
  67. # Examples: "http://example.com/media/", "http://media.example.com/"
  68. MEDIA_URL = '/media/'
  69. # Absolute path to the directory static files should be collected to.
  70. # Don't put anything in this directory yourself; store your static files
  71. # in apps' "static/" subdirectories and in STATICFILES_DIRS.
  72. # Example: "/var/www/example.com/static/"
  73. STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
  74. # URL prefix for static files.
  75. # Example: "http://example.com/static/", "http://static.example.com/"
  76. STATIC_URL = '/static/'
  77. # Additional locations of static files
  78. STATICFILES_DIRS = (
  79. # Put strings here, like "/home/html/static" or "C:/www/django/static".
  80. # Always use forward slashes, even on Windows.
  81. # Don't forget to use absolute paths, not relative paths.
  82. )
  83. # List of finder classes that know how to find static files in
  84. # various locations.
  85. STATICFILES_FINDERS = (
  86. 'django.contrib.staticfiles.finders.FileSystemFinder',
  87. 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  88. #'django.contrib.staticfiles.finders.DefaultStorageFinder',
  89. )
  90. # Make this unique, and don't share it with anybody.
  91. SECRET_KEY = '!qy_)gao6q)57#mz1s-d$5^+dp1nt=lk1d19&9bb3co37vn)!3'
  92. # List of callables that know how to import templates from various sources.
  93. TEMPLATE_LOADERS = (
  94. 'django.template.loaders.filesystem.Loader',
  95. 'django.template.loaders.app_directories.Loader',
  96. #'django.template.loaders.eggs.Loader',
  97. )
  98. MIDDLEWARE_CLASSES = (
  99. 'django.middleware.common.CommonMiddleware',
  100. 'django.contrib.sessions.middleware.SessionMiddleware',
  101. 'django.middleware.csrf.CsrfViewMiddleware',
  102. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  103. 'django.contrib.messages.middleware.MessageMiddleware',
  104. # Uncomment the next line for simple clickjacking protection:
  105. # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  106. )
  107. ROOT_URLCONF = 'coin.urls'
  108. # Python dotted path to the WSGI application used by Django's runserver.
  109. WSGI_APPLICATION = 'coin.wsgi.application'
  110. TEMPLATE_DIRS = (
  111. # Only absolute paths, always forward slashes
  112. os.path.join(PROJECT_PATH, 'templates/'),
  113. )
  114. INSTALLED_APPS = (
  115. 'django.contrib.auth',
  116. 'django.contrib.contenttypes',
  117. 'django.contrib.sessions',
  118. #'django.contrib.sites',
  119. 'ldapdb', # LDAP as database backend
  120. 'django.contrib.messages',
  121. 'django.contrib.staticfiles',
  122. # Uncomment the next line to enable the admin:
  123. 'django.contrib.admin',
  124. # Uncomment the next line to enable admin documentation:
  125. #'django.contrib.admindocs',
  126. 'polymorphic',
  127. # 'south',
  128. 'autocomplete_light', #Automagic autocomplete foreingkey form component
  129. 'activelink', #Detect if a link match actual page
  130. 'coin',
  131. 'coin.members',
  132. 'coin.offers',
  133. 'coin.billing',
  134. 'coin.resources',
  135. 'coin.reverse_dns',
  136. 'coin.configuration',
  137. 'coin.vpn'
  138. )
  139. # A sample logging configuration. The only tangible logging
  140. # performed by this configuration is to send an email to
  141. # the site admins on every HTTP 500 error when DEBUG=False.
  142. # See http://docs.djangoproject.com/en/dev/topics/logging for
  143. # more details on how to customize your logging configuration.
  144. LOGGING = {
  145. 'version': 1,
  146. 'disable_existing_loggers': False,
  147. 'filters': {
  148. 'require_debug_false': {
  149. '()': 'django.utils.log.RequireDebugFalse'
  150. }
  151. },
  152. 'handlers': {
  153. 'mail_admins': {
  154. 'level': 'ERROR',
  155. 'filters': ['require_debug_false'],
  156. 'class': 'django.utils.log.AdminEmailHandler'
  157. }
  158. },
  159. 'loggers': {
  160. 'django.request': {
  161. 'handlers': ['mail_admins'],
  162. 'level': 'ERROR',
  163. 'propagate': True,
  164. },
  165. }
  166. }
  167. TEMPLATE_CONTEXT_PROCESSORS = (
  168. "django.contrib.auth.context_processors.auth",
  169. "django.core.context_processors.debug",
  170. "django.core.context_processors.i18n",
  171. "django.core.context_processors.media",
  172. "django.core.context_processors.static",
  173. "django.core.context_processors.tz",
  174. "django.core.context_processors.request",
  175. "django.contrib.messages.context_processors.messages")
  176. AUTH_USER_MODEL = 'members.Member'
  177. AUTHENTICATION_BACKENDS = (
  178. 'django.contrib.auth.backends.ModelBackend',
  179. )
  180. TEST_RUNNER = 'django.test.runner.DiscoverRunner'
  181. GRAPHITE_SERVER = "http://graphite-dev.illyse.org"
  182. # LDAP Base DNs
  183. LDAP_USER_BASE_DN = "ou=users,ou=unix,o=ILLYSE,l=Villeurbanne,st=RHA,c=FR"
  184. LDAP_GROUP_BASE_DN = "ou=groups,ou=unix,o=ILLYSE,l=Villeurbanne,st=RHA,c=FR"
  185. VPN_CONF_BASE_DN = "ou=vpn,o=ILLYSE,l=Villeurbanne,st=RHA,c=FR"
  186. # Configuration for outgoing emails
  187. DEFAULT_FROM_EMAIL = "adminsys@illyse.org"
  188. #EMAIL_USE_TLS = True
  189. #EMAIL_HOST = "smtp.chezmoi.tld"
  190. # Reset session if cookie older than 2h.
  191. SESSION_COOKIE_AGE = 7200
  192. # Surcharge les paramètres en utilisant le fichier settings_local.py
  193. try:
  194. from settings_local import *
  195. except ImportError:
  196. pass