settings.py 4.37 KB
Newer Older
1
# -*- coding: utf-8 -*-
2 3
# Django settings for intranet project.

4
# Imports des secrets (plus tard, mais pas en debug)
5
import sys
6
sys.path.append("/etc/crans/secrets")
7

Daniel Stan's avatar
Daniel Stan committed
8
DEBUG = True
9
DEV = False
10 11
TEMPLATE_DEBUG = DEBUG

12 13
EMAIL_SUBJECT_PREFIX = "[Intranet2 Cr@ns] "

Daniel Stan's avatar
Daniel Stan committed
14 15
# Utiliser la base ldap de test ?
LDAP_TEST = True
16

17
ADMINS = (
Daniel Stan's avatar
Daniel Stan committed
18
    'Intranet', 'root@crans.org',
19 20 21 22
)

MANAGERS = ADMINS

23 24 25 26 27 28 29 30
if DEV:
    MAIN_PATH = '/home/toto/Crans/'
    DB_PATH = MAIN_PATH + 'intranet/default_db.sqlite'
else:
    MAIN_PATH = '/localhome/django/'
    DB_PATH = MAIN_PATH + 'local_dl/default'
ROOT_PATH = MAIN_PATH + 'intranet/'

31
FIXTURE_DIRS=(ROOT_PATH + 'fixtures/',)
Daniel Stan's avatar
Daniel Stan committed
32

33 34
DATABASES = {
    'default': {
Daniel Stan's avatar
Daniel Stan committed
35
        'ENGINE': 'django.db.backends.sqlite3',
36
        'NAME': DB_PATH,
37 38 39
        },
    }

40
STATIC_URL='/static/'
41 42 43 44 45 46

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
47
TIME_ZONE = 'Europe/Paris'
48 49 50

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
51
LANGUAGE_CODE = 'fr-fr'
52 53 54 55 56

SITE_ID = 1

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

59 60 61
# Formate les dates en fonction de la localisation
USE_L10N = True

62 63
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
64
MEDIA_ROOT = ROOT_PATH
65 66 67 68

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
69
MEDIA_URL = 'http://127.0.0.1/media/'
70 71

# Make this unique, and don't share it with anybody.
Daniel Stan's avatar
Daniel Stan committed
72 73 74 75
if DEBUG:
    SECRET_KEY = "sYjlDBZUBSMnk"
else: # Ne marchera que sur o2
    from secrets import django_secret_key as SECRET_KEY
76 77 78

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
79 80
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
81 82 83 84 85
#     'django.template.loaders.eggs.load_template_source',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
86
    'django.middleware.transaction.TransactionMiddleware',
87 88
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
Daniel Stan's avatar
Daniel Stan committed
89
    'django.contrib.messages.middleware.MessageMiddleware'
90
#    'reversion.middleware.RevisionMiddleware',
91 92 93
)

TEMPLATE_CONTEXT_PROCESSORS = (
94
    "django.contrib.auth.context_processors.auth",
95 96 97 98
    "django.core.context_processors.debug",
    "django.core.context_processors.i18n",
    "django.core.context_processors.media",
    "django.contrib.messages.context_processors.messages"
99 100 101 102 103
)

ROOT_URLCONF = 'intranet.urls'

TEMPLATE_DIRS = (
104
    MEDIA_ROOT + 'templates/',
105 106 107 108 109
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)

110 111 112 113
LOGIN_URL = "/login"
LOGIN_REDIRECT_URL = "/"

AUTHENTICATION_BACKENDS = (
114
    'intranet.login.LDAPUserBackend',
115
    'django.contrib.auth.backends.ModelBackend',
116 117 118
)


119
INTRANET_APPS = (
120 121 122 123 124
    {
        'name': 'locaux',
        'category': 'Administration',
        'test': lambda u: True,
    },
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
    {
        'name':'dummy',
        'category':'Beta',
        'test': lambda u: u.groups.filter(name='crans_nounou'),
    },
    {
        'name':'prises',
        'category':'Administration',
        'test': (lambda u: u.has_perm('prises.can_view')),
    },
    {
        'name':'impression',
        'category': 'Services',
        'test': (lambda u: u.groups.filter(name='crans_nounou') or u.groups.filter(name='crans_apprenti')),
    },
140 141 142 143 144
    {
        'name':'impressions',
        'category': 'Services',
        'test': (lambda u: True),
    },
145 146 147 148
    {
        'name':'wifimap',
        'category': 'Services',
        'test': (lambda u: True)
Daniel Stan's avatar
Daniel Stan committed
149
    },
150 151
)

152 153 154 155
INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
156
    'django.contrib.messages',
157
    'django.contrib.sites',
158
    'django.contrib.admin',
159 160
    #'south',
    #'reversion',
161
) + tuple( 'intranet.apps.%s' % app['name'] for app in INTRANET_APPS )