515786e1398dea901b40f57bf73dcd7ebf10267f
[auf_rh_dae.git] / project / settings.py
1 # -*- encoding: utf-8 -*-
2
3 import os
4 import socket
5
6 try:
7 from project.conf import * # NOQA
8 except ImportError:
9 pass
10
11 from project.groups import DRH_NIVEAU_1, DRH_NIVEAU_2
12
13 PROJET_TITRE = "Ressources humaines"
14
15 # Rapports d'erreurs
16 SERVER_EMAIL = 'ne-pas-repondre@auf.org'
17 EMAIL_SUBJECT_PREFIX = '[auf_rh_dae - %s] ' % socket.gethostname()
18 ADMINS = ()
19
20 MANAGERS = ADMINS
21
22 TIME_ZONE = 'America/Montreal'
23 LANGUAGE_CODE = 'fr'
24 FORMAT_MODULE_PATH = 'project.formats'
25 USE_L10N = True
26 USE_THOUSAND_SEPARATOR = False
27 DATE_FORMAT = 'd-m-Y'
28 DATE_INPUT_FORMATS = ('%d-%m-%Y', )
29
30 SESSION_SAVE_EVERY_REQUEST = True
31 SESSION_EXPIRE_AT_BROWSER_CLOSE = True
32
33 PROJECT_ROOT = os.path.dirname(__file__)
34 SITE_ROOT = os.path.dirname(PROJECT_ROOT)
35
36 # Absolute path to the directory that holds media.
37 # Example: "/home/media/media.lawrence.com/"
38 MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')
39 PRIVE_MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media_prive')
40
41 STATICFILES_DIRS = (
42 os.path.join(PROJECT_ROOT, 'assets'),
43 )
44 STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')
45 STATIC_URL = '/static/'
46
47 # URL that handles the media served from MEDIA_ROOT. Make sure to use a
48 # trailing slash if there is a path component (optional in other cases).
49 # Examples: "http://media.lawrence.com", "http://example.com/media/"
50 MEDIA_URL = '/media/'
51 PRIVE_MEDIA_URL = '/prive/'
52 OE_PRIVE_MEDIA_URL = '/recrutement/prive/'
53
54 # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
55 # trailing slash.
56 # Examples: "http://foo.com/media/", "/media/".
57 #ADMIN_MEDIA_PREFIX = '/media/django/'
58
59 # Don't share this with anybody.
60 SECRET_KEY = '^2w#%abp_d+e#(7f5w$leef50)c@4y38cnn#ccji@84$2^rt#l'
61
62 MIDDLEWARE_CLASSES = (
63 'django.middleware.common.CommonMiddleware',
64 'django.contrib.sessions.middleware.SessionMiddleware',
65 'django.contrib.messages.middleware.MessageMiddleware',
66 'django.contrib.auth.middleware.AuthenticationMiddleware',
67 'auf.django.saml.middleware.SPMiddleware',
68 'auf.django.piwik.middleware.TrackMiddleware',
69 'django.middleware.doc.XViewMiddleware',
70 'reversion.middleware.RevisionMiddleware',
71 )
72
73 ROOT_URLCONF = 'project.urls'
74
75 INSTALLED_APPS = (
76 'auf.django.skin',
77 'auf.django.references',
78 'auf.django.emploi',
79 'auf.django.admingroup',
80 'auf.django.workflow',
81 'auf.django.permissions',
82 'auf.django.emploi',
83 'auf.django.saml',
84 'auf.django.pong',
85 'auf.django.export',
86 'admin_tools',
87 'admin_tools.theming',
88 'admin_tools.menu',
89 'admin_tools.dashboard',
90 'django.contrib.admin',
91 'django.contrib.auth',
92 'django.contrib.contenttypes',
93 'django.contrib.humanize',
94 'django.contrib.messages',
95 'django.contrib.sessions',
96 'django.contrib.staticfiles',
97 'django_qbe',
98 'ajax_select',
99 'south',
100 'raven.contrib.django',
101 'django_extensions',
102 'reversion',
103 'alphafilter',
104 'form_utils',
105 'tinymce',
106 'captcha',
107 'project.rh',
108 'project.dae',
109 'project.recrutement',
110 )
111
112 TEMPLATE_CONTEXT_PROCESSORS = (
113 'django.contrib.auth.context_processors.auth',
114 'django.core.context_processors.debug',
115 'django.core.context_processors.i18n',
116 'django.core.context_processors.media',
117 'django.core.context_processors.static',
118 'django.contrib.messages.context_processors.messages',
119 'django.core.context_processors.request',
120 'auf.django.skin.context_processors.auf',
121 'project.dae.context_processors.user_in_dae_groupes',
122 )
123
124 AUTHENTICATION_BACKENDS = (
125 'auf.django.saml.backends.SPBackend',
126 'auf.django.permissions.backends.AuthenticationBackend',
127 )
128
129 TEMPLATE_DIRS = (
130 os.path.join(os.path.dirname(__file__), "templates"),
131 )
132
133
134 ADMIN_TOOLS_INDEX_DASHBOARD = 'project.dashboard.CustomIndexDashboard'
135 ADMIN_TOOLS_APP_INDEX_DASHBOARD = 'project.dashboard.CustomAppIndexDashboard'
136 ADMIN_TOOLS_MENU = 'project.menu.CustomMenu'
137
138 AJAX_LOOKUP_CHANNELS = {
139 'responsables': ('project.dae.catalogues', 'Responsable'),
140 'dae_dossiers': ('project.dae.catalogues', 'Dossier'),
141 'dae_postes': ('project.dae.catalogues', 'Poste'),
142 'pays': ('project.rh.catalogues', 'Pays'),
143 'implantations': ('project.rh.catalogues', 'Implantation'),
144 'typepostes': ('project.rh.catalogues', 'TypePoste'),
145 'postes': ('project.rh.catalogues', 'Poste'),
146 'valeurpoints': ('project.rh.catalogues', 'ValeurPoint'),
147 'employes': ('project.rh.catalogues', 'Employe'),
148 'dossiers': ('project.rh.catalogues', 'Dossier'),
149 }
150 AJAX_SELECT_INLINES = 'inline'
151
152
153 TINYMCE_DEFAULT_CONFIG = {
154 'theme': "advanced",
155 'plugins': "paste",
156 'theme_advanced_buttons1': (
157 "bold,italic,underline,|,formatselect,|,bullist,numlist,|,undo,redo,|,"
158 "link,unlink"
159 ),
160 'theme_advanced_buttons2': "",
161 'theme_advanced_buttons3': "",
162 'theme_advanced_statusbar_location': "bottom",
163 'theme_advanced_toolbar_align': "left",
164 'theme_advanced_styles': "Titre=titre;Sous-titre=sous-titre;Normal=normal",
165 'width': "800",
166 'height': "200",
167 'theme_advanced_resizing': "true",
168 'custom_undo_redo_levels': 10,
169 'theme_advanced_toolbar_location': 'top',
170 'inline_styles': 'false',
171 'paste_use_dialog': 'false',
172 'paste_auto_cleanup_on_paste': 'true',
173 'paste_convert_headers_to_strong': 'false',
174 'paste_strip_class_attributes': 'all',
175 'paste_remove_spans': 'true',
176 'paste_remove_styles': 'true',
177 'content_css': '/media/css/tinymce.css',
178 }
179
180 # django-sendfile
181 SENDFILE_BACKEND = 'sendfile.backends.simple'
182
183 QBE_DISPLAY_DATABASES = False
184
185 # Il est *très* important de respecter la case.
186 QBE_CUSTOM_MODELS = {'Rh': {
187 'Employe': {},
188 'Poste': {},
189 'Dossier': {},
190 'Remuneration': {},
191 'Contrat': {},
192 }}
193
194 QBE_ALLOWED_FIELDS = {'Rh': {
195 'Employe': [
196 'nom', 'prenom', 'genre', 'date_naissance', 'situation_familiale',
197 'date_entree'
198 ],
199 'Poste': ['nom', 'date_debut', 'date_fin'],
200 'Dossier': [
201 'statut_residence', 'regime_travail',
202 'regime_travail_nb_heure_semaine', 'date_debut', 'date_fin'
203 ],
204 'Remuneration': ['montant', 'date_debut', 'date_fin'],
205 'Contrat': ['date_debut', 'date_fin'],
206 }}
207
208 SOUTH_TESTS_MIGRATE = False
209
210 LOGGING = {
211 'version': 1,
212 'disable_existing_loggers': True,
213 'root': {
214 'level': 'WARNING',
215 'handlers': ['sentry'],
216 },
217 'formatters': {
218 'verbose': {
219 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
220 },
221 },
222 'handlers': {
223 'sentry': {
224 'level': 'WARNING',
225 'class': 'raven.contrib.django.handlers.SentryHandler',
226 },
227 'console': {
228 'level': 'DEBUG',
229 'class': 'logging.StreamHandler',
230 'formatter': 'verbose'
231 }
232 },
233 'loggers': {
234 'django.db.backends': {
235 'level': 'ERROR',
236 'handlers': ['console'],
237 'propagate': False,
238 },
239 'raven': {
240 'level': 'DEBUG',
241 'handlers': ['console'],
242 'propagate': False,
243 },
244 'sentry.errors': {
245 'level': 'DEBUG',
246 'handlers': ['console'],
247 'propagate': False,
248 },
249 },
250 }
251
252 CACHES = {
253 'default': {
254 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
255 }
256 }
257
258 # Pour accéder aux requêtes savegardées, il faut définir les permissions dans
259 # l'admin
260 def qbe_access(user):
261 grps_user = [g.name for g in user.groups.all()]
262 inter = [g for g in grps_user if g in (DRH_NIVEAU_1, DRH_NIVEAU_2, )]
263 return len(inter) > 0
264 QBE_ACCESS_FOR = qbe_access