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