settings.py 8.1 KB

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