source: trunk/sara_cmt/sara_cmt/settings.py @ 14154

Last change on this file since 14154 was 14154, checked in by sil, 12 years ago

See #11

  • Narrowed down number of Django-versions as a dependency
  • Changed targets of docs, config-, data-, and executable-files to install
  • Now installable in a virtual environment
File size: 5.7 KB
Line 
1
2import os
3
4
5# Documentation of settings can be found on:
6#
7#   http://docs.djangoproject.com/en/dev/ref/settings/
8
9# Only set CLIENT_ONLY to False on the central CMT-server
10CLIENT_ONLY = True
11
12DEBUG = True
13
14ADMINS = (
15    ('Sil Westerveld', 'sil.westerveld@sara.nl'),
16    #('Your Name', 'your_email@domain.com'),
17)
18
19MANAGERS = ADMINS
20
21
22# The database settings are imported, due to confidential data which should be
23# excluded from the SVN repository.
24try:
25    from settings_db import *
26except ImportError:
27    print '''\
28Settings for database are missing. Be sure to have `settings_db.py` with:
29
30DATABASES = {
31    'default': {
32        'ENGINE': '<engine>',
33        'NAME': '<name>',
34        'USER': '<user>',
35        'PASSWORD': '<password>',
36        'HOST': '<host>'
37    }
38}
39
40See https://docs.djangoproject.com/en/1.2/ref/settings/#databases'''
41    exit(1)
42
43
44
45#####
46#
47# <AUTH AGAINST LDAP> (based on http://packages.python.org/django-auth-ldap/)
48#
49if not CLIENT_ONLY:
50    import ldap
51    from django_auth_ldap.config import LDAPSearch, PosixGroupType
52
53
54    # Baseline configuration.
55    AUTH_LDAP_SERVER_URI = "ldaps://ldap.cua.sara.nl"
56
57    # Set AUTH_LDAP_USER_DN_TEMPLATE to a template that will produce the
58    # authenticating user's DN directly. This template should have one
59    # placeholder, %(user)s.
60    AUTH_LDAP_USER_DN_TEMPLATE = 'uid=%(user)s,ou=Users,dc=hpcv,dc=sara,dc=nl'
61
62    # Set up the basic group parameters.
63    AUTH_LDAP_GROUP_SEARCH = LDAPSearch('ou=Groups,dc=hpcv,dc=sara,dc=nl',
64        ldap.SCOPE_SUBTREE, '(objectClass=posixGroup)',
65    )
66    AUTH_LDAP_GROUP_TYPE = PosixGroupType()
67
68    ## Only users in this group can log in.
69    AUTH_LDAP_REQUIRE_GROUP = 'cn=cmt,ou=Groups,dc=hpcv,dc=sara,dc=nl'
70
71    # Populate the Django user from the LDAP directory.
72    AUTH_LDAP_USER_ATTR_MAP = {
73        'first_name': 'givenName',
74        'last_name': 'sn',
75        'email': 'mail',
76    }
77
78    AUTH_LDAP_USER_FLAGS_BY_GROUP = {
79        'is_active': 'cn=cmt,ou=Groups,dc=hpcv,dc=sara,dc=nl',
80        'is_staff': 'cn=cmt,ou=Groups,dc=hpcv,dc=sara,dc=nl',
81        'is_superuser': 'cn=cmt,ou=Groups,dc=hpcv,dc=sara,dc=nl',
82    }
83
84    # This is the default, but I like to be explicit.
85    AUTH_LDAP_ALWAYS_UPDATE_USER = True
86
87    # Cache group memberships for an hour to minimize LDAP traffic
88    AUTH_LDAP_CACHE_GROUPS = True
89    AUTH_LDAP_GROUP_CACHE_TIMEOUT = 3600
90
91    # Keep ModelBackend around for per-user permissions and maybe a local
92    # superuser.
93    AUTHENTICATION_BACKENDS = (
94        'django_auth_ldap.backend.LDAPBackend',
95        'django.contrib.auth.backends.ModelBackend',
96    )
97#
98# </AUTH AGAINST LDAP>
99#
100#####
101
102
103
104
105
106# Local time zone for this installation. Choices can be found here:
107# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
108# although not all choices may be available on all operating systems.
109# If running in a Windows environment this must be set to the same as your
110# system time zone.
111TIME_ZONE = 'Europe/Amsterdam'
112
113# Language code for this installation. All choices can be found here:
114# http://www.i18nguy.com/unicode/language-identifiers.html
115LANGUAGE_CODE = 'en-us'
116
117SITE_ID = 1
118
119# If you set this to False, Django will make some optimizations so as not
120# to load the internationalization machinery.
121USE_I18N = True
122
123# Absolute path to the directory that holds media.
124# Example: "/home/media/media.lawrence.com/"
125MEDIA_ROOT = ''
126
127# URL that handles the media served from MEDIA_ROOT. Make sure to use a
128# trailing slash if there is a path component (optional in other cases).
129# Examples: "http://media.lawrence.com", "http://example.com/media/"
130MEDIA_URL = ''
131
132# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
133# trailing slash.
134# Examples: "http://foo.com/media/", "/media/".
135ADMIN_MEDIA_PREFIX = '/admin_media/'
136
137# Make this unique, and don't share it with anybody.
138SECRET_KEY = 'uygv6wrel4o2%x8s4dk2%i6=dp!2bt32$0ne-%_7&j=ez*u$1b'
139
140# List of callables that know how to import templates from various sources.
141TEMPLATE_LOADERS = (
142    'django.template.loaders.filesystem.load_template_source',
143    'django.template.loaders.app_directories.load_template_source',
144    #'django.template.loaders.eggs.load_template_source',
145)
146
147MIDDLEWARE_CLASSES = (
148    'django.middleware.common.CommonMiddleware',
149    'django.contrib.sessions.middleware.SessionMiddleware',
150    'django.contrib.auth.middleware.AuthenticationMiddleware',
151    'debug_toolbar.middleware.DebugToolbarMiddleware',
152)
153
154ROOT_URLCONF = 'sara_cmt.urls'
155
156# Templates for the CMT command line interface.
157# (thus, the templates for our configfiles, etc)
158#TODO: think about a (better) way to make this dynamic:
159#TODO: get this out of the settings.py, since it should be in the client config
160import site
161CMT_TEMPLATES_DIR = '%s/etc/templates' % site.sys.prefix
162
163# Templates for the CMT web-frontend.
164TEMPLATE_DIRS = (
165    # Put strings here, like "/home/html/django_templates"
166    # or "C:/www/django/templates".
167    # Always use forward slashes, even on Windows.
168    # Don't forget to use absolute paths, not relative paths.
169    os.path.normpath(os.path.join(os.path.dirname(__file__), 'cluster/templates')),
170    CMT_TEMPLATES_DIR,
171)
172
173FIXTURE_DIRS = (
174    # A fixture is a collection of files that contain serialized contents of
175    # the database. (can be used for testing)
176    os.path.normpath(os.path.join(os.path.dirname(__file__), 'fixtures')),
177)
178
179
180INSTALLED_APPS = (
181    'django.contrib.auth',
182    'django.contrib.contenttypes',
183    'django.contrib.sessions',
184    'django.contrib.admin',
185    'django.contrib.databrowse',
186    'django.contrib.webdesign',
187    'sara_cmt.cluster',
188    'django_extensions',
189    'tagging',
190
191    # Only serverside:
192    #'debug_toolbar',
193    #'south',
194)
195
196# Append your IP to use the debug_toolbar
197INTERNAL_IPS = (
198    #'145.100.6.163', # saralt0115
199    '127.0.0.1',
200)
Note: See TracBrowser for help on using the repository browser.