1.6
[auf_recipe_django.git] / auf / recipe / django / boilerplate.py
CommitLineData
4be9d9da 1# -*- encoding: utf-8 -*-
dd501324 2
19d7fb26
OL
3import zc.buildout.easy_install
4
5
6env = '''
7%(relative_paths_setup)s
8import sys
19d7fb26
OL
9
10eggs_path = [
11 %(path)s,
12 ]
13
14sys.path[0:0] = eggs_path
15
c7a67069
OL
16import pkg_resources
17
19d7fb26
OL
18# correction des namespaces virtuels
19for egg_path in eggs_path:
20 pkg_resources.fixup_namespace_packages(egg_path)
21%(initialization)s
22import %(module_name)s
23'''
24
25auf_buildout_file = zc.buildout.easy_install.script_header + env + '''\
26if __name__ == '__main__':
27 %(module_name)s.%(attrs)s(%(arguments)s)
28'''
29
30auf_script_template = {
31 'wsgi': env + """
32application = %(module_name)s.%(attrs)s(%(arguments)s)
33""",
34 'fcgi': env + """
35%(module_name)s.%(attrs)s(%(arguments)s)
36""",
37}
38
4be9d9da
OL
39
40################################################################################
41# SETTINGS
42################################################################################
43
44conf_file = '''# -*- encoding: utf-8 -*
45
05129f35
OL
46DATABASES = {
47 'default': {
48 #'ENGINE': 'django.db.backends.mysql',
49 'ENGINE': 'django.db.backends.sqlite3',
50 'NAME': 'db.sqlite',
51 'USER': '',
52 'PASSWORD': '',
53 'HOST' : '',
54 'PORT' : '',
55 }
56}
57
4be9d9da
OL
58'''
59
60dashboard_file ='''# -*- encoding: utf-8 -*
61
4be9d9da
OL
62from django.utils.translation import ugettext_lazy as _
63from django.core.urlresolvers import reverse
64
65from admin_tools.dashboard import modules, Dashboard, AppIndexDashboard
66from admin_tools.utils import get_admin_site_name
67
68
69class CustomIndexDashboard(Dashboard):
70 """
05129f35 71 Custom index dashboard
4be9d9da
OL
72 """
73 def init_with_context(self, context):
74 site_name = get_admin_site_name(context)
75
76 # append an app list module for "Applications"
77 self.children.append(modules.AppList(
78 _('Applications'),
79 exclude=('django.contrib.*',),
80 ))
81
82 # append an app list module for "Administration"
83 self.children.append(modules.AppList(
84 _('Administration'),
85 models=('django.contrib.*',),
86 ))
87
88 # append a recent actions module
89 self.children.append(modules.RecentActions(_('Recent Actions'), 5))
90'''
91
92
93auf_urls_template = '''# -*- encoding: utf-8 -*
94from django.conf.urls.defaults import patterns, include, handler500, handler404, url
95from django.conf import settings
96from django.contrib import admin
97
98admin.autodiscover()
99
100handler404
101handler500 # Pyflakes
102
103urlpatterns = patterns(
104 '',
105 ######## page d'accueil de demo ######
106 (r'^$', 'auf.django.skin.views.demo'),
107 ######################################
108 url(r'^admin_tools/', include('admin_tools.urls')),
109 (r'^admin/', include(admin.site.urls)),
110 (r'^connexion/$', 'django.contrib.auth.views.login'),
111 (r'^deconnexion/$', 'django.contrib.auth.views.logout'),
112
113)
114
115if settings.DEBUG:
116 urlpatterns += patterns('',
117 (r'^media/(?P<path>.*)$', 'django.views.static.serve',
118 {'document_root': settings.MEDIA_ROOT}),
119 )
120'''
121
122auf_settings_template = '''# -*- encoding: utf-8 -*-
123
124import os
125import socket
05129f35 126from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS as DEFAULT_TEMPLATE_CONTEXT_PROCESSORS
4be9d9da
OL
127
128# Rapports d'erreurs
129EMAIL_SUBJECT_PREFIX = '[%(project_name)s - %%s] ' %% socket.gethostname()
130ADMINS = (
131 ('Équipe ARI-SI', 'developpeurs@ca.auf.org'),
132)
133
134MANAGERS = ADMINS
135
05129f35 136TIME_ZONE = 'America/Montreal'
4be9d9da
OL
137
138LANGUAGE_CODE = 'fr-ca'
139
75eeae4d 140PROJECT_ROOT = os.path.dirname(__file__)
8c098998 141SITE_ROOT = os.path.dirname(PROJECT_ROOT)
75eeae4d
OL
142
143MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')
4be9d9da
OL
144MEDIA_URL = '/media/'
145
8c098998 146STATIC_ROOT = os.path.join(SITE_ROOT, 'sitestatic')
05129f35 147STATIC_URL = '/static/'
4be9d9da 148
4be9d9da
OL
149ROOT_URLCONF = '%(urlconf)s'
150
4be9d9da
OL
151INSTALLED_APPS = (
152 'auf.django.skin',
153 'admin_tools',
154 'admin_tools.theming',
155 'admin_tools.menu',
156 'admin_tools.dashboard',
157 'django.contrib.auth',
158 'django.contrib.contenttypes',
159 'django.contrib.sessions',
160 'django.contrib.admin',
05129f35 161 'django.contrib.staticfiles',
4be9d9da
OL
162 'south',
163)
164
05129f35
OL
165TEMPLATE_CONTEXT_PROCESSORS = DEFAULT_TEMPLATE_CONTEXT_PROCESSORS + (
166 'django.core.context_processors.static',
4be9d9da
OL
167 'django.core.context_processors.request',
168 'auf.django.skin.context_processors.auf',
169)
170
171
4be9d9da
OL
172TEMPLATE_DIRS = (
173 os.path.join(os.path.dirname(__file__), "templates"),
174)
175
176SOUTH_TESTS_MIGRATE = False
177
178ADMIN_TOOLS_INDEX_DASHBOARD = 'project.dashboard.CustomIndexDashboard'
179
05129f35 180from conf import *
4be9d9da
OL
181'''
182
183################################################################################
184# DEVELOPPEMENT
185################################################################################
186auf_development_settings = '''# -*- encoding: utf-8 -*-
187
188from %(project)s.settings import *
189DEBUG=True
190TEMPLATE_DEBUG=DEBUG
191
192# Décommentez ces lignes pour activer la debugtoolbar
193#INTERNAL_IPS = ('127.0.0.1',)
194#INSTALLED_APPS += ('debug_toolbar',)
195#MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',)
196
197AUTH_PASSWORD_REQUIRED = False
198'''
199
200################################################################################
201# PRODUCTION
202################################################################################
203auf_production_settings = ''' # -*- encoding: utf-8 -*-
204
205# En production, rediriger la sortie terminal on disponible en WSGI
206# vers la sortie fichier errorlog.
207import sys
208sys.stdout = sys.stderr
209
210from %(project)s.settings import *
211'''