Project

General

Profile

Download (12.3 KB) Statistics
| Branch: | Tag: | Revision:

calebasse / calebasse / settings.py @ 48fb14d2

1
# -*- coding: utf-8 -*-
2

    
3
# Django settings for calebasse project.
4

    
5
import os
6
from django.core.exceptions import ImproperlyConfigured
7
from logging.handlers import SysLogHandler
8

    
9
PROJECT_PATH = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'calebasse')
10

    
11
DEBUG = True
12
TEMPLATE_DEBUG = True
13

    
14
ADMINS = (
15
    # ('Your Name', 'your_email@example.com'),
16
)
17

    
18
MANAGERS = ADMINS
19

    
20
DATABASES = {
21
    'default': {
22
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
23
        'NAME': os.path.join(PROJECT_PATH, 'calebasse.sqlite3'),                      # Or path to database file if using sqlite3.
24
        'USER': '',                      # Not used with sqlite3.
25
        'PASSWORD': '',                  # Not used with sqlite3.
26
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
27
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
28
    }
29
}
30

    
31
# Local time zone for this installation. Choices can be found here:
32
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
33
# although not all choices may be available on all operating systems.
34
# On Unix systems, a value of None will cause Django to use the same
35
# timezone as the operating system.
36
# If running in a Windows environment this must be set to the same as your
37
# system time zone.
38
TIME_ZONE = 'Europe/Paris'
39

    
40
# Language code for this installation. All choices can be found here:
41
# http://www.i18nguy.com/unicode/language-identifiers.html
42
LANGUAGE_CODE = 'fr-fr'
43

    
44
SITE_ID = 1
45

    
46
# If you set this to False, Django will make some optimizations so as not
47
# to load the internationalization machinery.
48
USE_I18N = True
49

    
50
# If you set this to False, Django will not format dates, numbers and
51
# calendars according to the current locale.
52
USE_L10N = True
53
FORMAT_MODULE_PATH = 'calebasse.formats'
54

    
55
# If you set this to False, Django will not use timezone-aware datetimes.
56
USE_TZ = False
57

    
58
# Absolute filesystem path to the directory that will hold user-uploaded files.
59
# Example: "/home/media/media.lawrence.com/media/"
60
MEDIA_ROOT = os.path.join(PROJECT_PATH, 'media')
61

    
62
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
63
# trailing slash.
64
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
65
MEDIA_URL = '/media/'
66

    
67
# Absolute path to the directory static files should be collected to.
68
# Don't put anything in this directory yourself; store your static files
69
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
70
# Example: "/home/media/media.lawrence.com/static/"
71
STATIC_ROOT = os.path.join(os.path.join(PROJECT_PATH, '..'), 'static')
72

    
73
# URL prefix for static files.
74
# Example: "http://media.lawrence.com/static/"
75
STATIC_URL = '/static/'
76

    
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
    os.path.join(PROJECT_PATH, 'static'),
83
)
84

    
85
# List of finder classes that know how to find static files in
86
# various locations.
87
STATICFILES_FINDERS = (
88
    'django.contrib.staticfiles.finders.FileSystemFinder',
89
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
90
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
91
)
92

    
93
# Make this unique, and don't share it with anybody.
94
SECRET_KEY = 'ct(a@ny^_)8v-^)jkdzbktqg6ajfn6y!zdjum^(f_o!h0jeotq'
95

    
96
# List of callables that know how to import templates from various sources.
97
TEMPLATE_LOADERS = (
98
    'django.template.loaders.filesystem.Loader',
99
    'django.template.loaders.app_directories.Loader',
100
#     'django.template.loaders.eggs.Loader',
101
)
102

    
103
MIDDLEWARE_CLASSES = (
104
    'django.middleware.common.CommonMiddleware',
105
    'django.contrib.sessions.middleware.SessionMiddleware',
106
    'django.middleware.csrf.CsrfViewMiddleware',
107
    'django.contrib.auth.middleware.AuthenticationMiddleware',
108
    'django.contrib.messages.middleware.MessageMiddleware',
109
    #'debug_toolbar.middleware.DebugToolbarMiddleware',
110
    'calebasse.middleware.request.GlobalRequestMiddleware',
111
    # Uncomment the next line for simple clickjacking protection:
112
    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
113
    'django.middleware.transaction.TransactionMiddleware',
114
    'reversion.middleware.RevisionMiddleware',
115
    # Entr'ouvert wsgi middleware to expose version
116
    'entrouvert.djommon.middleware.VersionMiddleware',
117
    'django_journal.middleware.JournalMiddleware',
118
)
119

    
120
ROOT_URLCONF = 'calebasse.urls'
121

    
122
# Python dotted path to the WSGI application used by Django's runserver.
123
WSGI_APPLICATION = 'calebasse.wsgi.application'
124

    
125
TEMPLATE_DIRS = (
126
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
127
    # Always use forward slashes, even on Windows.
128
    # Don't forget to use absolute paths, not relative paths.
129
    os.path.join(PROJECT_PATH, "templates"),
130
)
131

    
132
TEMPLATE_CONTEXT_PROCESSORS = ("django.contrib.auth.context_processors.auth",
133
    "django.core.context_processors.debug",
134
    "django.core.context_processors.i18n",
135
    "django.core.context_processors.media",
136
    "django.core.context_processors.static",
137
    "django.core.context_processors.tz",
138
    "django.core.context_processors.request",
139
    "django.contrib.messages.context_processors.messages")
140

    
141
FIXTURE_DIRS = (
142
        os.path.join(PROJECT_PATH, 'fixtures'),
143
)
144

    
145
INSTALLED_APPS = (
146
    'django.contrib.auth',
147
    'django.contrib.contenttypes',
148
    'django.contrib.sessions',
149
    'django.contrib.sites',
150
    'django.contrib.messages',
151
    'django.contrib.staticfiles',
152
    'reversion',
153
    'django.contrib.admin',
154
    'ajax_select',
155
    'django_select2',
156
    #'debug_toolbar',
157
    'widget_tweaks',
158
    # Uncomment the next line to enable admin documentation:
159
    # 'django.contrib.admindocs',
160
    'calebasse.agenda',
161
    'calebasse.dossiers',
162
    'calebasse.actes',
163
    'calebasse.facturation',
164
    'calebasse.personnes',
165
    'calebasse.ressources',
166
    'calebasse.statistics',
167
    'calebasse.common',
168
    'calebasse.middleware.request',
169
    'django_journal',
170
)
171

    
172
INTERNAL_IPS=('127.0.0.1',)
173
DEBUG_TOOLBAR_CONFIG = {
174
    'INTERCEPT_REDIRECTS': False,
175
}
176

    
177
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
178

    
179
# A sample logging configuration. The only tangible logging
180
# performed by this configuration is to send an email to
181
# the site admins on every HTTP 500 error when DEBUG=False.
182
# See http://docs.djangoproject.com/en/dev/topics/logging for
183
# more details on how to customize your logging configuration.
184
LOGGING = {
185
    'version': 1,
186
    'disable_existing_loggers': True,
187
    'filters': {
188
        'require_debug_false': {
189
            '()': 'django.utils.log.RequireDebugFalse'
190
        },
191
    },
192
    'formatters': {
193
        'verbose': {
194
            'format': '[%(asctime)s] %(levelname)-8s %(name)s.%(message)s',
195
            'datefmt': '%Y-%m-%d %a %H:%M:%S'
196
        },
197
        'syslog': {
198
            'format': 'calebasse (pid=%(process)d) %(levelname)s %(name)s: %(message)s',
199
        },
200
    },
201
    'handlers': {
202
        'mail_admins': {
203
            'level': 'ERROR',
204
            'filters': ['require_debug_false'],
205
            'class': 'django.utils.log.AdminEmailHandler'
206
        },
207
        'console': {
208
            'level':'INFO',
209
            'class':'logging.StreamHandler',
210
            'formatter': 'verbose',
211
        },
212
        'syslog': {
213
            'level': 'DEBUG',
214
            'class': 'entrouvert.logging.handlers.SysLogHandler',
215
            'formatter': 'syslog',
216
            'facility': SysLogHandler.LOG_LOCAL0,
217
            'address': '/dev/log',
218
            'max_length': 999,
219
        },
220
    },
221
    'loggers': {
222
        'django.db.backends': {
223
            'level': 'ERROR',
224
            'handlers': ['console'],
225
            'propagate': False,
226
        },
227
        '': {
228
            'handlers': ['syslog'],
229
            'level': 'DEBUG' if DEBUG else 'INFO',
230
            'propagate': True,
231
        }
232
    },
233
}
234

    
235
# AJAX Select
236
AJAX_LOOKUP_CHANNELS = {
237
    #   pass a dict with the model and the field to search against
238
    'worker' : ('calebasse.personnes.lookup', 'WorkerLookup'),
239
    'intervenant' : ('calebasse.personnes.lookup', 'IntervenantLookup'),
240
    #'patientrecord'  : {'model':'dossiers.PatientRecord', 'search_field':'display_name'}
241
    #'coordinators'  : {'model':'dossiers.PatientRecord', 'search_field':'display_name'}
242
    'patientrecord' : ('calebasse.dossiers.lookups', 'PatientRecordLookup'),
243
    #'school' : {'model':'ressources.School', 'search_field':'name'},
244
    'school' : ('calebasse.ressources.lookups', 'SchoolLookup'),
245
    'addresses' : ('calebasse.dossiers.lookups', 'PatientAddressLookup'),
246
    'worker-or-group' : ('calebasse.ressources.lookups', 'WorkerOrGroupLookup'),
247
    'all-worker-or-group' : ('calebasse.ressources.lookups', 'AllWorkerOrGroupLookup'),
248
}
249

    
250
# Default URL after login
251
LOGIN_REDIRECT_URL = '/'
252

    
253
# Sentry / raven configuration
254
# You need to overload this option in the local_settings.py
255
RAVEN_CONFIG = None
256

    
257
# Base directory for generated patient files
258
PATIENT_FILES_BASE_DIRECTORY = None
259

    
260
# Client side base directory for generated patient files
261
CLIENT_SIDE_PATIENT_FILES_BASE_DIRECTORY =  None
262

    
263
# Patient subdirectories
264
PATIENT_SUBDIRECTORIES = (
265
    u'Assistante sociale',
266
    u'Consultation',
267
    u'Courriers',
268
    u'Demande',
269
    u'Demandes prises en charge',
270
    u'Educateur spécialisé',
271
    u'Ergothérapie',
272
    u'Groupe',
273
    u'Kinésithérapie',
274
    u'Logico-mathématiques',
275
    u'Neuro-psychologie',
276
    u'Orientation',
277
    u'Orthophonie',
278
    u'Psychologie',
279
    u'Psychomotricité',
280
    u'Psychopédagogue',
281
    u'Synthèses',
282
    u'TCC',
283
)
284

    
285
# RTF templates directory
286
RTF_TEMPLATES_DIRECTORY = None
287
# Use patient home dictrory for RTF files generated
288
# PATIENT_FILES_BASE_DIRECTORY must be set to work
289
USE_PATIENT_FILE_RTF_REPOSITORY_DIRECTORY = False
290
# RTF files generated directory
291
RTF_REPOSITORY_DIRECTORY = None
292

    
293
# Invoicing file saving directory
294
INVOICING_DIRECTORY = None
295

    
296
# display events only for current service
297
CURRENT_SERVICE_EVENTS_ONLY = True
298

    
299
# dictionary to define non-default behaviours for some services
300
SERVICE_SETTINGS = {}
301
# valid keys
302
# - show_overlapping_appointments: boolean (default: False)
303
# - age_format: string, string (default: None, alternative behaviour to have
304
#   age always displayed in months: "months_only")
305

    
306
# Pdftk binary path (pdftk is used to complete CERFA)
307
PDFTK_PATH = '/usr/bin/pdftk'
308

    
309

    
310
#CSV_ENCODING = 'cp1252' #For windows : windows-1252/Winlatin1
311
#CSVPROFILE = {\
312
#    'delimiter' : ';',
313
#    'quotechar' : '"',
314
#    'doublequote' : True
315
#    'skipinitialspace' : False
316
#    'lineterminator' : '\r\n'
317
#    'quoting' : csv.QUOTE_MINIMAL
318
#}
319

    
320
# IRIS/B2 transmission
321
# B2_TRANSMISSION = {
322
#    'output_directory': '/var/lib/calebasse/B2/',
323
#    # B2 informations
324
#    'nom': 'CMPP FOOBAR',                      # mandatory
325
#    'numero_emetteur': '123456789',            # mandatory
326
#    'norme': 'CP  ',
327
#    'type_emetteur': 'TE',
328
#    'application': 'TR',
329
#    'categorie': '189',
330
#    'statut': '60',
331
#    'mode_tarif': '05',
332
#    'message': 'ENTROUVERT 0143350135 CALEBASSE 1307',
333
#    # SMTP configuration
334
#    'smtp_from': 'transmission@domain.net',    # mandatory
335
#    'smtp_host': '127.0.0.1',
336
#    'smtp_port': 25,
337
#    'smtp_login': '',
338
#    'smtp_password': '',
339
#    # delay between two mails, in seconds, or None
340
#    'smtp_delay': None,
341
# }
342

    
343
try:
344
    from local_settings import *
345
except ImportError:
346
    print """
347
    -------------------------------------------------------------------------
348
    You need to create a local_settings.py file which needs to contain at least
349
    database connection information.
350

    
351
    Copy local_settings_example.py to local_settings.py and edit it.
352
    -------------------------------------------------------------------------
353
    """
354
    import sys
355
    sys.exit(1)
356

    
357
if not os.path.exists(PDFTK_PATH):
358
    raise ImproperlyConfigured("pdftk %r binary not found" % PDFTK_PATH)
359

    
360
if RAVEN_CONFIG:
361
    INSTALLED_APPS += ('raven.contrib.django.raven_compat', )
362
    LOGGING['handlers']['sentry'] = {
363
            'level': 'ERROR',
364
            'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler',
365
            }
366
    LOGGING['loggers']['raven'] = {
367
            'level': 'DEBUG',
368
            'handlers': ['console'],
369
            'propagate': False,
370
            }
371
    LOGGING['loggers']['sentry.errors'] = {
372
            'level': 'DEBUG',
373
            'handlers': ['console'],
374
            'propagate': False,
375
            }
376
    LOGGING['loggers']['']['handlers'].append('sentry')
(12-12/17)