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