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