1.7
[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
4edf55b7 129SERVER_EMAIL = 'ne-pas-repondre@auf.org'
4be9d9da
OL
130EMAIL_SUBJECT_PREFIX = '[%(project_name)s - %%s] ' %% socket.gethostname()
131ADMINS = (
132 ('Équipe ARI-SI', 'developpeurs@ca.auf.org'),
133)
134
135MANAGERS = ADMINS
136
05129f35 137TIME_ZONE = 'America/Montreal'
4be9d9da
OL
138
139LANGUAGE_CODE = 'fr-ca'
140
75eeae4d 141PROJECT_ROOT = os.path.dirname(__file__)
8c098998 142SITE_ROOT = os.path.dirname(PROJECT_ROOT)
75eeae4d
OL
143
144MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')
4be9d9da
OL
145MEDIA_URL = '/media/'
146
8c098998 147STATIC_ROOT = os.path.join(SITE_ROOT, 'sitestatic')
05129f35 148STATIC_URL = '/static/'
4be9d9da 149
4be9d9da
OL
150ROOT_URLCONF = '%(urlconf)s'
151
4be9d9da
OL
152INSTALLED_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',
05129f35 162 'django.contrib.staticfiles',
4be9d9da
OL
163 'south',
164)
165
05129f35
OL
166TEMPLATE_CONTEXT_PROCESSORS = DEFAULT_TEMPLATE_CONTEXT_PROCESSORS + (
167 'django.core.context_processors.static',
4be9d9da
OL
168 'django.core.context_processors.request',
169 'auf.django.skin.context_processors.auf',
170)
171
172
4be9d9da
OL
173TEMPLATE_DIRS = (
174 os.path.join(os.path.dirname(__file__), "templates"),
175)
176
177SOUTH_TESTS_MIGRATE = False
178
179ADMIN_TOOLS_INDEX_DASHBOARD = 'project.dashboard.CustomIndexDashboard'
180
05129f35 181from conf import *
4be9d9da
OL
182'''
183
184################################################################################
185# DEVELOPPEMENT
186################################################################################
187auf_development_settings = '''# -*- encoding: utf-8 -*-
188
189from %(project)s.settings import *
190DEBUG=True
191TEMPLATE_DEBUG=DEBUG
192
193# Décommentez ces lignes pour activer la debugtoolbar
194#INTERNAL_IPS = ('127.0.0.1',)
195#INSTALLED_APPS += ('debug_toolbar',)
196#MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',)
197
198AUTH_PASSWORD_REQUIRED = False
199'''
200
201################################################################################
202# PRODUCTION
203################################################################################
204auf_production_settings = ''' # -*- encoding: utf-8 -*-
205
206# En production, rediriger la sortie terminal on disponible en WSGI
207# vers la sortie fichier errorlog.
208import sys
209sys.stdout = sys.stderr
210
211from %(project)s.settings import *
212'''