Et encore un peu de PEP8
[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 39
f0e41374 40###############################################################################
4be9d9da 41# SETTINGS
f0e41374 42###############################################################################
4be9d9da
OL
43
44conf_file = '''# -*- encoding: utf-8 -*
45
ac55c31f
EMS
46SECRET_KEY = ''
47
05129f35
OL
48DATABASES = {
49 'default': {
50 #'ENGINE': 'django.db.backends.mysql',
51 'ENGINE': 'django.db.backends.sqlite3',
52 'NAME': 'db.sqlite',
53 'USER': '',
54 'PASSWORD': '',
ea85f9ba
EMS
55 'HOST': '',
56 'PORT': '',
05129f35
OL
57 }
58}
4be9d9da
OL
59'''
60
f0e41374 61dashboard_file = '''# -*- encoding: utf-8 -*
4be9d9da 62
4be9d9da
OL
63from django.utils.translation import ugettext_lazy as _
64from django.core.urlresolvers import reverse
65
66from admin_tools.dashboard import modules, Dashboard, AppIndexDashboard
67from admin_tools.utils import get_admin_site_name
68
69
70class CustomIndexDashboard(Dashboard):
71 """
05129f35 72 Custom index dashboard
4be9d9da
OL
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
94auf_urls_template = '''# -*- encoding: utf-8 -*
81c860e0
EMS
95from django.conf.urls.defaults import paterns, include, url
96from django.conf.urls.defaults import handler500, handler404 # NOQA
4be9d9da
OL
97from django.conf import settings
98from django.contrib import admin
99
100admin.autodiscover()
101
4be9d9da
OL
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
ea85f9ba
EMS
125from django.conf.global_settings import \\
126 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
4be9d9da
OL
172TEMPLATE_DIRS = (
173 os.path.join(os.path.dirname(__file__), "templates"),
174)
175
176SOUTH_TESTS_MIGRATE = False
177
178ADMIN_TOOLS_INDEX_DASHBOARD = 'project.dashboard.CustomIndexDashboard'
179
f0e41374 180from conf import * # NOQA
4be9d9da
OL
181'''
182
f0e41374 183###############################################################################
4be9d9da 184# DEVELOPPEMENT
f0e41374 185###############################################################################
4be9d9da
OL
186auf_development_settings = '''# -*- encoding: utf-8 -*-
187
f0e41374
EMS
188from %(project)s.settings import * # NOQA
189DEBUG = True
190TEMPLATE_DEBUG = DEBUG
4be9d9da
OL
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
197AUTH_PASSWORD_REQUIRED = False
198'''
199
f0e41374 200###############################################################################
4be9d9da 201# PRODUCTION
f0e41374 202###############################################################################
4be9d9da
OL
203auf_production_settings = ''' # -*- encoding: utf-8 -*-
204
205# En production, rediriger la sortie terminal on disponible en WSGI
206# vers la sortie fichier errorlog.
207import sys
208sys.stdout = sys.stderr
209
f0e41374 210from %(project)s.settings import * # NOQA
4be9d9da 211'''