settings_base.py 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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 = True
  10. ADMINS = (
  11. # ('Your Name', 'your_email@example.com'),
  12. )
  13. MANAGERS = ADMINS
  14. DATABASES = {
  15. # Database hosted on vagant test box
  16. 'default': {
  17. 'ENGINE': 'django.db.backends.postgresql_psycopg2',
  18. 'NAME': 'coin',
  19. 'USER': 'coin',
  20. 'PASSWORD': 'coin',
  21. 'HOST': 'localhost', # Empty for localhost through domain sockets
  22. 'PORT': '15432', # Empty for default
  23. },
  24. }
  25. # Hosts/domain names that are valid for this site; required if DEBUG is False
  26. # See https://docs.djangoproject.com/en/1.7/ref/settings/#allowed-hosts
  27. ALLOWED_HOSTS = []
  28. # Local time zone for this installation. Choices can be found here:
  29. # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
  30. # although not all choices may be available on all operating systems.
  31. # In a Windows environment this must be set to your system time zone.
  32. TIME_ZONE = 'Europe/Paris'
  33. # Language code for this installation. All choices can be found here:
  34. # http://www.i18nguy.com/unicode/language-identifiers.html
  35. LANGUAGE_CODE = 'fr-fr'
  36. SITE_ID = 1
  37. # If you set this to False, Django will make some optimizations so as not
  38. # to load the internationalization machinery.
  39. USE_I18N = True
  40. # If you set this to False, Django will not format dates, numbers and
  41. # calendars according to the current locale.
  42. USE_L10N = True
  43. # If you set this to False, Django will not use timezone-aware datetimes.
  44. USE_TZ = True
  45. # Default URL for login and logout
  46. LOGIN_URL = '/members/login'
  47. LOGIN_REDIRECT_URL = '/members'
  48. LOGOUT_URL = '/members/logout'
  49. # Absolute filesystem path to the directory that will hold user-uploaded files.
  50. # Example: "/var/www/example.com/media/"
  51. MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
  52. # URL that handles the media served from MEDIA_ROOT. Make sure to use a
  53. # trailing slash.
  54. # Examples: "http://example.com/media/", "http://media.example.com/"
  55. MEDIA_URL = '/media/'
  56. # Absolute path to the directory static files should be collected to.
  57. # Don't put anything in this directory yourself; store your static files
  58. # in apps' "static/" subdirectories and in STATICFILES_DIRS.
  59. # Example: "/var/www/example.com/static/"
  60. STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
  61. # URL prefix for static files.
  62. # Example: "http://example.com/static/", "http://static.example.com/"
  63. STATIC_URL = '/static/'
  64. # Additional locations of static files
  65. STATICFILES_DIRS = (
  66. # Put strings here, like "/home/html/static" or "C:/www/django/static".
  67. # Always use forward slashes, even on Windows.
  68. # Don't forget to use absolute paths, not relative paths.
  69. )
  70. # List of finder classes that know how to find static files in
  71. # various locations.
  72. STATICFILES_FINDERS = (
  73. 'django.contrib.staticfiles.finders.FileSystemFinder',
  74. 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  75. #'django.contrib.staticfiles.finders.DefaultStorageFinder',
  76. )
  77. # Location of private files. (Like invoices)
  78. # In production, this location should not be publicly accessible through
  79. # the web server
  80. PRIVATE_FILES_ROOT = os.path.join(BASE_DIR, 'smedia/')
  81. # Backend to use when sending private files to client
  82. # In production, must be sendfile.backends.xsendfile with Apache xsend file mod
  83. # Or failing xsendfile, use : sendfile.backends.simple
  84. # https://github.com/johnsensible/django-sendfile
  85. SENDFILE_BACKEND = 'sendfile.backends.development'
  86. # Make this unique, and don't share it with anybody.
  87. SECRET_KEY = '!qy_)gao6q)57#mz1s-d$5^+dp1nt=lk1d19&9bb3co37vn)!3'
  88. # List of callables that know how to import templates from various sources.
  89. TEMPLATE_LOADERS = (
  90. 'django.template.loaders.filesystem.Loader',
  91. 'django.template.loaders.app_directories.Loader',
  92. #'django.template.loaders.eggs.Loader',
  93. )
  94. MIDDLEWARE_CLASSES = (
  95. 'debug_toolbar.middleware.DebugToolbarMiddleware',
  96. 'django.middleware.common.CommonMiddleware',
  97. 'django.contrib.sessions.middleware.SessionMiddleware',
  98. 'django.middleware.csrf.CsrfViewMiddleware',
  99. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  100. 'django.contrib.messages.middleware.MessageMiddleware',
  101. # Uncomment the next line for simple clickjacking protection:
  102. # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  103. )
  104. # Do not load jQuery from crappy CDN
  105. DEBUG_TOOLBAR_CONFIG = {
  106. 'JQUERY_URL': '/static/js/vendor/jquery.js'
  107. }
  108. # Used for debug toolbar
  109. INTERNAL_IPS = ['127.0.0.1', '::1']
  110. ROOT_URLCONF = 'coin.urls'
  111. # Python dotted path to the WSGI application used by Django's runserver.
  112. WSGI_APPLICATION = 'coin.wsgi.application'
  113. TEMPLATE_DIRS = (
  114. # Only absolute paths, always forward slashes
  115. os.path.join(PROJECT_PATH, 'templates/'),
  116. )
  117. EXTRA_TEMPLATE_DIRS = tuple()
  118. INSTALLED_APPS = (
  119. 'debug_toolbar', # always installed, but enabled only if DEBUG=True
  120. 'django.contrib.auth',
  121. 'django.contrib.contenttypes',
  122. 'django.contrib.sessions',
  123. 'django.contrib.sites',
  124. 'ldapdb', # LDAP as database backend
  125. 'django.contrib.messages',
  126. 'django.contrib.staticfiles',
  127. # Uncomment the next line to enable the admin:
  128. 'django.contrib.admin',
  129. 'netfields',
  130. # Uncomment the next line to enable admin documentation:
  131. #'django.contrib.admindocs',
  132. 'polymorphic',
  133. # 'south',
  134. 'autocomplete_light', #Automagic autocomplete foreingkey form component
  135. 'activelink', #Detect if a link match actual page
  136. 'compat',
  137. 'hijack',
  138. 'coin',
  139. 'coin.members',
  140. 'coin.offers',
  141. 'coin.billing',
  142. 'coin.resources',
  143. 'coin.reverse_dns',
  144. 'coin.configuration',
  145. 'coin.isp_database',
  146. )
  147. EXTRA_INSTALLED_APPS = tuple()
  148. # A sample logging configuration. The only tangible logging
  149. # performed by this configuration is to send an email to
  150. # the site admins on every HTTP 500 error when DEBUG=False.
  151. # See http://docs.djangoproject.com/en/dev/topics/logging for
  152. # more details on how to customize your logging configuration.
  153. LOGGING = {
  154. 'version': 1,
  155. 'disable_existing_loggers': False,
  156. 'formatters': {
  157. },
  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. 'console': {
  170. 'class': 'logging.StreamHandler',
  171. },
  172. },
  173. 'loggers': {
  174. 'django.request': {
  175. 'handlers': ['mail_admins'],
  176. 'level': 'ERROR',
  177. 'propagate': True,
  178. },
  179. 'django': {
  180. 'handlers': ['console'],
  181. 'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'),
  182. },
  183. "coin.billing": {
  184. 'handlers': ['console'],
  185. 'level': 'INFO',
  186. }
  187. }
  188. }
  189. TEMPLATE_CONTEXT_PROCESSORS = (
  190. "django.contrib.auth.context_processors.auth",
  191. "django.core.context_processors.debug",
  192. "django.core.context_processors.i18n",
  193. "django.core.context_processors.media",
  194. "django.core.context_processors.static",
  195. "django.core.context_processors.tz",
  196. "django.core.context_processors.request",
  197. "coin.isp_database.context_processors.branding",
  198. "coin.context_processors.installed_apps",
  199. "django.contrib.messages.context_processors.messages")
  200. AUTH_USER_MODEL = 'members.Member'
  201. AUTHENTICATION_BACKENDS = (
  202. 'django.contrib.auth.backends.ModelBackend',
  203. )
  204. TEST_RUNNER = 'django.test.runner.DiscoverRunner'
  205. # Where admins are redirected to after hijacking a user
  206. HIJACK_LOGIN_REDIRECT_URL = '/'
  207. # Where admins are redirected to after releasing a user
  208. HIJACK_LOGOUT_REDIRECT_URL = '/admin/members/member/'
  209. # Needed for link in admin
  210. HIJACK_ALLOW_GET_REQUESTS = True
  211. GRAPHITE_SERVER = "http://localhost"
  212. # Configuration for outgoing emails
  213. #DEFAULT_FROM_EMAIL = "coin@example.com"
  214. #EMAIL_USE_TLS = True
  215. #EMAIL_HOST = "smtp.chezmoi.tld"
  216. # Do we use LDAP or not
  217. LDAP_ACTIVATE = False
  218. # Not setting them results in NameError
  219. LDAP_USER_BASE_DN = None
  220. VPN_CONF_BASE_DN = None
  221. # Allow member to edit their vpn
  222. MEMBER_CAN_EDIT_VPN_CONF = True
  223. # Membership configuration
  224. # Default cotisation in €, per year
  225. DEFAULT_MEMBERSHIP_FEE = 20
  226. # Link to a page with information on how to become a member or pay the
  227. # membership fee
  228. MEMBER_MEMBERSHIP_INFO_URL = ''
  229. # When should we remind a member about its membership ? List of deltas from
  230. # the anniversary date, can be a combination of positive (after anniversary)
  231. # and negative (before aniversary) af months, days and weeks.
  232. MEMBERSHIP_FEE_REMINDER_DATES = [
  233. {'months': -3}, # 3 months before
  234. {'months': -2}, # 2 months before
  235. {'months': -1}, # 1 month before
  236. {'days': 0}, # the day of anniversary
  237. {'months': +1}, # 1 month after
  238. ]
  239. # Pattern used to display a unique reference for any subscription
  240. # Helpful for bank wire transfer identification
  241. SUBSCRIPTION_REFERENCE = 'REF-{subscription.offer.reference}-{subscription.pk}'
  242. # Template string to display the label the member should indicates for the bank
  243. # transfer
  244. MEMBERSHIP_REFERENCE = "ADH-{user.pk}"
  245. # Payment delay in days
  246. PAYMENT_DELAY = 30
  247. # Reset session if cookie older than 2h.
  248. SESSION_COOKIE_AGE = 7200
  249. # RSS/Atom feeds to display on dashboard
  250. # feed name (used in template), url, max entries to display
  251. # "isp" entry gets picked automatically in default index template
  252. FEEDS = (
  253. ('ffdn', 'http://www.ffdn.org/fr/rss.xml', 3),
  254. # ('isp', 'http://isp.example.com/feed/', 3),
  255. )
  256. # Allow user to edit their VPS Info
  257. MEMBER_CAN_EDIT_VPS_CONF = True
  258. # Allow user to edit their VPN Info
  259. MEMBER_CAN_EDIT_VPN_CONF = True
  260. # Account registration
  261. # Allow visitor to join the association by register on COIN
  262. REGISTRATION_OPEN = False
  263. # All account with unvalidated email will be deleted after X days
  264. ACCOUNT_ACTIVATION_DAYS = 7
  265. # Member can edit their own data
  266. MEMBER_CAN_EDIT_PROFILE = False
  267. # Allows to deactivate displays and calculations of balances.
  268. HANDLE_BALANCE = False
  269. # Add subscription comments in invoice items
  270. INVOICES_INCLUDE_CONFIG_COMMENTS = True