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