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