Browse Source

sandbox: use new style template settings

master
Michael van Tellingen 8 years ago
parent
commit
40e8a727a6
No account linked to committer's email address
2 changed files with 53 additions and 52 deletions
  1. 45
    45
      sites/sandbox/settings.py
  2. 8
    7
      tests/settings.py

+ 45
- 45
sites/sandbox/settings.py View File

@@ -1,21 +1,23 @@
1 1
 import os
2 2
 
3
+import oscar
4
+
3 5
 # Path helper
4 6
 location = lambda x: os.path.join(
5 7
     os.path.dirname(os.path.realpath(__file__)), x)
6 8
 
7
-USE_TZ = True
8
-
9
-DEBUG = True
10
-TEMPLATE_DEBUG = True
11
-SQL_DEBUG = True
9
+DEBUG = os.environ.get('DEBUG', 'true') != 'false'
10
+SQL_DEBUG = DEBUG
12 11
 
13
-ALLOWED_HOSTS = ['latest.oscarcommerce.com',
14
-                 'master.oscarcommerce.com']
12
+ALLOWED_HOSTS = [
13
+    'latest.oscarcommerce.com',
14
+    'master.oscarcommerce.com'
15
+]
15 16
 
16 17
 # This is needed for the hosted version of the sandbox
17 18
 ADMINS = (
18 19
     ('David Winterbottom', 'david.winterbottom@gmail.com'),
20
+    ('Michael van Tellingen', 'michaelvantellingen@gmail.com'),
19 21
 )
20 22
 EMAIL_SUBJECT_PREFIX = '[Oscar sandbox] '
21 23
 EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
@@ -48,6 +50,7 @@ CACHES = {
48 50
 # timezone as the operating system.
49 51
 # If running in a Windows environment this must be set to the same as your
50 52
 # system time zone.
53
+USE_TZ = True
51 54
 TIME_ZONE = 'Europe/London'
52 55
 
53 56
 TEST_RUNNER = 'django.test.runner.DiscoverRunner'
@@ -102,11 +105,6 @@ MEDIA_ROOT = location("public/media")
102 105
 # Examples: "http://media.lawrence.com", "http://example.com/media/"
103 106
 MEDIA_URL = '/media/'
104 107
 
105
-# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
106
-# trailing slash.
107
-# Examples: "http://foo.com/media/", "/media/".
108
-#ADMIN_MEDIA_PREFIX = '/media/admin/'
109
-
110 108
 STATIC_URL = '/static/'
111 109
 STATIC_ROOT = location('public/static')
112 110
 STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
@@ -121,29 +119,39 @@ STATICFILES_FINDERS = (
121 119
 # Make this unique, and don't share it with anybody.
122 120
 SECRET_KEY = '$)a7n&o80u!6y5t-+jrd3)3!%vh&shg$wqpjpxc!ar&p#!)n1a'
123 121
 
124
-# List of callables that know how to import templates from various sources.
125
-TEMPLATE_LOADERS = (
126
-    'django.template.loaders.filesystem.Loader',
127
-    'django.template.loaders.app_directories.Loader',
128
-    # needed by django-treebeard for admin (and potentially other libs)
129
-    'django.template.loaders.eggs.Loader',
130
-)
131
-
132
-TEMPLATE_CONTEXT_PROCESSORS = (
133
-    "django.contrib.auth.context_processors.auth",
134
-    "django.core.context_processors.request",
135
-    "django.core.context_processors.debug",
136
-    "django.core.context_processors.i18n",
137
-    "django.core.context_processors.media",
138
-    "django.core.context_processors.static",
139
-    "django.contrib.messages.context_processors.messages",
140
-    # Oscar specific
141
-    'oscar.apps.search.context_processors.search_form',
142
-    'oscar.apps.promotions.context_processors.promotions',
143
-    'oscar.apps.checkout.context_processors.checkout',
144
-    'oscar.core.context_processors.metadata',
145
-    'oscar.apps.customer.notifications.context_processors.notifications',
146
-)
122
+TEMPLATES = [
123
+    {
124
+        'BACKEND': 'django.template.backends.django.DjangoTemplates',
125
+        'DIRS': [
126
+            location('_site/templates'),
127
+            oscar.OSCAR_MAIN_TEMPLATE_DIR,
128
+        ],
129
+        'OPTIONS': {
130
+            'loaders': [
131
+                'django.template.loaders.filesystem.Loader',
132
+                'django.template.loaders.app_directories.Loader',
133
+                'django.template.loaders.eggs.Loader',
134
+            ],
135
+            'context_processors': [
136
+                'django.contrib.auth.context_processors.auth',
137
+                'django.core.context_processors.request',
138
+                'django.core.context_processors.debug',
139
+                'django.core.context_processors.i18n',
140
+                'django.core.context_processors.media',
141
+                'django.core.context_processors.static',
142
+                'django.contrib.messages.context_processors.messages',
143
+
144
+                # Oscar specific
145
+                'oscar.apps.search.context_processors.search_form',
146
+                'oscar.apps.customer.notifications.context_processors.notifications',
147
+                'oscar.apps.promotions.context_processors.promotions',
148
+                'oscar.apps.checkout.context_processors.checkout',
149
+                'oscar.core.context_processors.metadata',
150
+            ],
151
+            'debug': DEBUG,
152
+        }
153
+    }
154
+]
147 155
 
148 156
 MIDDLEWARE_CLASSES = (
149 157
     'debug_toolbar.middleware.DebugToolbarMiddleware',
@@ -170,13 +178,6 @@ MIDDLEWARE_CLASSES = (
170 178
 
171 179
 ROOT_URLCONF = 'urls'
172 180
 
173
-# Add another path to Oscar's templates.  This allows templates to be
174
-# customised easily.
175
-from oscar import OSCAR_MAIN_TEMPLATE_DIR
176
-TEMPLATE_DIRS = (
177
-    location('templates'),
178
-    OSCAR_MAIN_TEMPLATE_DIR,
179
-)
180 181
 
181 182
 # A sample logging configuration. The only tangible logging
182 183
 # performed by this configuration is to send an email to
@@ -266,13 +267,12 @@ INSTALLED_APPS = [
266 267
     'django.contrib.staticfiles',
267 268
     'django.contrib.sitemaps',
268 269
     'django_extensions',
270
+
269 271
     # Debug toolbar + extensions
270 272
     'debug_toolbar',
271 273
     'apps.gateway',     # For allowing dashboard access
272 274
     'widget_tweaks',
273
-]
274
-from oscar import get_core_apps
275
-INSTALLED_APPS = INSTALLED_APPS + get_core_apps()
275
+] + oscar.get_core_apps()
276 276
 
277 277
 # Add Oscar's custom auth backend so users can sign in using their email
278 278
 # address.

+ 8
- 7
tests/settings.py View File

@@ -50,13 +50,14 @@ TEMPLATES = [
50 50
                 ]),
51 51
             ],
52 52
             'context_processors': [
53
-                "django.contrib.auth.context_processors.auth",
54
-                "django.template.context_processors.request",
55
-                "django.template.context_processors.debug",
56
-                "django.template.context_processors.i18n",
57
-                "django.template.context_processors.media",
58
-                "django.template.context_processors.static",
59
-                "django.contrib.messages.context_processors.messages",
53
+                'django.contrib.auth.context_processors.auth',
54
+                'django.template.context_processors.request',
55
+                'django.template.context_processors.debug',
56
+                'django.template.context_processors.i18n',
57
+                'django.template.context_processors.media',
58
+                'django.template.context_processors.static',
59
+                'django.contrib.messages.context_processors.messages',
60
+
60 61
                 'oscar.apps.search.context_processors.search_form',
61 62
                 'oscar.apps.customer.notifications.context_processors.notifications',
62 63
                 'oscar.apps.promotions.context_processors.promotions',

Loading…
Cancel
Save