a0efe2675f0ebe39f0a1c33db51cd4b864de57d4
[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 SECRET_KEY = ''
47
48 DATABASES = {
49 'default': {
50 #'ENGINE': 'django.db.backends.mysql',
51 'ENGINE': 'django.db.backends.sqlite3',
52 'NAME': 'db.sqlite',
53 'USER': '',
54 'PASSWORD': '',
55 'HOST': '',
56 'PORT': '',
57 }
58 }
59 '''
60
61 dashboard_file = '''# -*- encoding: utf-8 -*
62
63 from django.utils.translation import ugettext_lazy as _
64 from django.core.urlresolvers import reverse
65
66 from admin_tools.dashboard import modules, Dashboard, AppIndexDashboard
67 from admin_tools.utils import get_admin_site_name
68
69
70 class CustomIndexDashboard(Dashboard):
71 """
72 Custom index dashboard
73 """
74 def init_with_context(self, context):
75 site_name = get_admin_site_name(context)
76
77 # append an app list module for "Applications"
78 self.children.append(modules.AppList(
79 _('Applications'),
80 exclude=('django.contrib.*',),
81 ))
82
83 # append an app list module for "Administration"
84 self.children.append(modules.AppList(
85 _('Administration'),
86 models=('django.contrib.*',),
87 ))
88
89 # append a recent actions module
90 self.children.append(modules.RecentActions(_('Recent Actions'), 5))
91 '''
92
93
94 auf_urls_template = '''# -*- encoding: utf-8 -*
95 from django.conf.urls.defaults import \\
96 patterns, include, handler500, handler404, url
97 from django.conf import settings
98 from django.contrib import admin
99
100 admin.autodiscover()
101
102 handler404
103 handler500 # Pyflakes
104
105 urlpatterns = patterns(
106 '',
107 ######## page d'accueil de demo ######
108 (r'^$', 'auf.django.skin.views.demo'),
109 ######################################
110 url(r'^admin_tools/', include('admin_tools.urls')),
111 (r'^admin/', include(admin.site.urls)),
112 (r'^connexion/$', 'django.contrib.auth.views.login'),
113 (r'^deconnexion/$', 'django.contrib.auth.views.logout'),
114
115 )
116
117 if settings.DEBUG:
118 urlpatterns += patterns('',
119 (r'^media/(?P<path>.*)$', 'django.views.static.serve',
120 {'document_root': settings.MEDIA_ROOT}),
121 )
122 '''
123
124 auf_settings_template = '''# -*- encoding: utf-8 -*-
125
126 import os
127 import socket
128 from django.conf.global_settings import \\
129 TEMPLATE_CONTEXT_PROCESSORS as DEFAULT_TEMPLATE_CONTEXT_PROCESSORS
130
131 # Rapports d'erreurs
132 SERVER_EMAIL = 'ne-pas-repondre@auf.org'
133 EMAIL_SUBJECT_PREFIX = '[%(project_name)s - %%s] ' %% socket.gethostname()
134 ADMINS = (
135 ('Équipe ARI-SI', 'developpeurs@ca.auf.org'),
136 )
137
138 MANAGERS = ADMINS
139
140 TIME_ZONE = 'America/Montreal'
141
142 LANGUAGE_CODE = 'fr-ca'
143
144 PROJECT_ROOT = os.path.dirname(__file__)
145 SITE_ROOT = os.path.dirname(PROJECT_ROOT)
146
147 MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')
148 MEDIA_URL = '/media/'
149
150 STATIC_ROOT = os.path.join(SITE_ROOT, 'sitestatic')
151 STATIC_URL = '/static/'
152
153 ROOT_URLCONF = '%(urlconf)s'
154
155 INSTALLED_APPS = (
156 'auf.django.skin',
157 'admin_tools',
158 'admin_tools.theming',
159 'admin_tools.menu',
160 'admin_tools.dashboard',
161 'django.contrib.auth',
162 'django.contrib.contenttypes',
163 'django.contrib.sessions',
164 'django.contrib.admin',
165 'django.contrib.staticfiles',
166 'south',
167 )
168
169 TEMPLATE_CONTEXT_PROCESSORS = DEFAULT_TEMPLATE_CONTEXT_PROCESSORS + (
170 'django.core.context_processors.static',
171 'django.core.context_processors.request',
172 'auf.django.skin.context_processors.auf',
173 )
174
175 TEMPLATE_DIRS = (
176 os.path.join(os.path.dirname(__file__), "templates"),
177 )
178
179 SOUTH_TESTS_MIGRATE = False
180
181 ADMIN_TOOLS_INDEX_DASHBOARD = 'project.dashboard.CustomIndexDashboard'
182
183 from conf import * # NOQA
184 '''
185
186 ###############################################################################
187 # DEVELOPPEMENT
188 ###############################################################################
189 auf_development_settings = '''# -*- encoding: utf-8 -*-
190
191 from %(project)s.settings import * # NOQA
192 DEBUG = True
193 TEMPLATE_DEBUG = DEBUG
194
195 # Décommentez ces lignes pour activer la debugtoolbar
196 #INTERNAL_IPS = ('127.0.0.1',)
197 #INSTALLED_APPS += ('debug_toolbar',)
198 #MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',)
199
200 AUTH_PASSWORD_REQUIRED = False
201 '''
202
203 ###############################################################################
204 # PRODUCTION
205 ###############################################################################
206 auf_production_settings = ''' # -*- encoding: utf-8 -*-
207
208 # En production, rediriger la sortie terminal on disponible en WSGI
209 # vers la sortie fichier errorlog.
210 import sys
211 sys.stdout = sys.stderr
212
213 from %(project)s.settings import * # NOQA
214 '''