Przeglądaj źródła

Document sandbox settings file

Thought it might be useful to comment on the Oscar-specific settings.
master
David Winterbottom 13 lat temu
rodzic
commit
997e317e00
1 zmienionych plików z 39 dodań i 25 usunięć
  1. 39
    25
      sites/sandbox/settings.py

+ 39
- 25
sites/sandbox/settings.py Wyświetl plik

1
 import os
1
 import os
2
 
2
 
3
-# Django settings for oscar project.
3
+# Path helper
4
 PROJECT_DIR = os.path.dirname(__file__)
4
 PROJECT_DIR = os.path.dirname(__file__)
5
 location = lambda x: os.path.join(
5
 location = lambda x: os.path.join(
6
     os.path.dirname(os.path.realpath(__file__)), x)
6
     os.path.dirname(os.path.realpath(__file__)), x)
11
 TEMPLATE_DEBUG = True
11
 TEMPLATE_DEBUG = True
12
 SQL_DEBUG = True
12
 SQL_DEBUG = True
13
 SEND_BROKEN_LINK_EMAILS = True
13
 SEND_BROKEN_LINK_EMAILS = True
14
+THUMBNAIL_DEBUG = True
14
 
15
 
15
 ADMINS = (
16
 ADMINS = (
16
     ('David Winterbottom', 'david.winterbottom@tangentlabs.co.uk'),
17
     ('David Winterbottom', 'david.winterbottom@tangentlabs.co.uk'),
20
 
21
 
21
 MANAGERS = ADMINS
22
 MANAGERS = ADMINS
22
 
23
 
24
+# Use a Sqlite database by default
23
 DATABASES = {
25
 DATABASES = {
24
     'default': {
26
     'default': {
25
         'ENGINE': 'django.db.backends.sqlite3',
27
         'ENGINE': 'django.db.backends.sqlite3',
79
 
81
 
80
 # Absolute path to the directory that holds media.
82
 # Absolute path to the directory that holds media.
81
 # Example: "/home/media/media.lawrence.com/"
83
 # Example: "/home/media/media.lawrence.com/"
82
-MEDIA_ROOT = location("assets/media")
84
+MEDIA_ROOT = location("public/media")
83
 
85
 
84
 # URL that handles the media served from MEDIA_ROOT. Make sure to use a
86
 # URL that handles the media served from MEDIA_ROOT. Make sure to use a
85
 # trailing slash if there is a path component (optional in other cases).
87
 # trailing slash if there is a path component (optional in other cases).
135
     'django.middleware.transaction.TransactionMiddleware',
137
     'django.middleware.transaction.TransactionMiddleware',
136
     'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
138
     'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
137
     'debug_toolbar.middleware.DebugToolbarMiddleware',
139
     'debug_toolbar.middleware.DebugToolbarMiddleware',
138
-    # Oscar middleware
140
+    # Ensure a valid basket is added to the request instance for every request
139
     'oscar.apps.basket.middleware.BasketMiddleware',
141
     'oscar.apps.basket.middleware.BasketMiddleware',
142
+    # Enable the ProfileMiddleware, then add ?cprofile to any
143
+    # URL path to print out profile details
140
     #'oscar.middleware.profiling.ProfileMiddleware',
144
     #'oscar.middleware.profiling.ProfileMiddleware',
141
 )
145
 )
142
 
146
 
144
 
148
 
145
 ROOT_URLCONF = 'urls'
149
 ROOT_URLCONF = 'urls'
146
 
150
 
151
+# Add another path to Oscar's templates.  This allows templates to be
152
+# customised easily.
147
 from oscar import OSCAR_MAIN_TEMPLATE_DIR
153
 from oscar import OSCAR_MAIN_TEMPLATE_DIR
148
 TEMPLATE_DIRS = (
154
 TEMPLATE_DIRS = (
149
     location('templates'),
155
     location('templates'),
177
             'formatter': 'verbose'
183
             'formatter': 'verbose'
178
         },
184
         },
179
         'checkout_file': {
185
         'checkout_file': {
180
-             'level': 'INFO',
181
-             'class': 'oscar.core.logging.handlers.EnvFileHandler',
182
-             'filename': 'checkout.log',
183
-             'formatter': 'verbose'
186
+            'level': 'INFO',
187
+            'class': 'oscar.core.logging.handlers.EnvFileHandler',
188
+            'filename': 'checkout.log',
189
+            'formatter': 'verbose'
184
         },
190
         },
185
         'gateway_file': {
191
         'gateway_file': {
186
-             'level': 'INFO',
187
-             'class': 'oscar.core.logging.handlers.EnvFileHandler',
188
-             'filename': 'gateway.log',
189
-             'formatter': 'simple'
192
+            'level': 'INFO',
193
+            'class': 'oscar.core.logging.handlers.EnvFileHandler',
194
+            'filename': 'gateway.log',
195
+            'formatter': 'simple'
190
         },
196
         },
191
         'error_file': {
197
         'error_file': {
192
-             'level': 'INFO',
193
-             'class': 'oscar.core.logging.handlers.EnvFileHandler',
194
-             'filename': 'errors.log',
195
-             'formatter': 'verbose'
198
+            'level': 'INFO',
199
+            'class': 'oscar.core.logging.handlers.EnvFileHandler',
200
+            'filename': 'errors.log',
201
+            'formatter': 'verbose'
196
         },
202
         },
197
         'sorl_file': {
203
         'sorl_file': {
198
-             'level': 'INFO',
199
-             'class': 'oscar.core.logging.handlers.EnvFileHandler',
200
-             'filename': 'sorl.log',
201
-             'formatter': 'verbose'
204
+            'level': 'INFO',
205
+            'class': 'oscar.core.logging.handlers.EnvFileHandler',
206
+            'filename': 'sorl.log',
207
+            'formatter': 'verbose'
202
         },
208
         },
203
         'mail_admins': {
209
         'mail_admins': {
204
             'level': 'ERROR',
210
             'level': 'ERROR',
252
     'django_extensions',
258
     'django_extensions',
253
     'debug_toolbar',
259
     'debug_toolbar',
254
     'south',
260
     'south',
255
-    'rosetta',  # For i18n testing
261
+    'rosetta',          # For i18n testing
256
     'compressor',
262
     'compressor',
257
-    'apps.user',  # For profile testing
258
-    'apps.gateway',  # For allowing dashboard access
263
+    'apps.user',        # For profile testing
264
+    'apps.gateway',     # For allowing dashboard access
259
 ]
265
 ]
260
 from oscar import get_core_apps
266
 from oscar import get_core_apps
261
 INSTALLED_APPS = INSTALLED_APPS + get_core_apps()
267
 INSTALLED_APPS = INSTALLED_APPS + get_core_apps()
262
 
268
 
269
+# Add Oscar's custom auth backend so users can sign in using their email
270
+# address.
263
 AUTHENTICATION_BACKENDS = (
271
 AUTHENTICATION_BACKENDS = (
264
     'oscar.apps.customer.auth_backends.Emailbackend',
272
     'oscar.apps.customer.auth_backends.Emailbackend',
265
     'django.contrib.auth.backends.ModelBackend',
273
     'django.contrib.auth.backends.ModelBackend',
276
     },
284
     },
277
 }
285
 }
278
 
286
 
287
+
279
 # Allow internal IPs to see the debug toolbar.  This is just for Tangent's QA
288
 # Allow internal IPs to see the debug toolbar.  This is just for Tangent's QA
280
 # department to be able to create better issues when something goes wrong.
289
 # department to be able to create better issues when something goes wrong.
281
 def is_internal(request):
290
 def is_internal(request):
294
 
303
 
295
 OSCAR_RECENTLY_VIEWED_PRODUCTS = 20
304
 OSCAR_RECENTLY_VIEWED_PRODUCTS = 20
296
 OSCAR_ALLOW_ANON_CHECKOUT = True
305
 OSCAR_ALLOW_ANON_CHECKOUT = True
306
+
307
+# Some sample order/line status settings
297
 OSCAR_INITIAL_ORDER_STATUS = 'Pending'
308
 OSCAR_INITIAL_ORDER_STATUS = 'Pending'
298
 OSCAR_INITIAL_LINE_STATUS = 'Pending'
309
 OSCAR_INITIAL_LINE_STATUS = 'Pending'
299
 OSCAR_ORDER_STATUS_PIPELINE = {
310
 OSCAR_ORDER_STATUS_PIPELINE = {
308
 # Enter Google Analytics ID for the tracking to be included in the templates
319
 # Enter Google Analytics ID for the tracking to be included in the templates
309
 #GOOGLE_ANALYTICS_ID = 'UA-XXXXX-Y'
320
 #GOOGLE_ANALYTICS_ID = 'UA-XXXXX-Y'
310
 
321
 
322
+# Use Less to compile CSS
311
 COMPRESS_ENABLED = True
323
 COMPRESS_ENABLED = True
312
 COMPRESS_PRECOMPILERS = (
324
 COMPRESS_PRECOMPILERS = (
313
     ('text/less', 'lessc {infile} {outfile}'),
325
     ('text/less', 'lessc {infile} {outfile}'),
318
 if not os.path.exists(LOG_ROOT):
330
 if not os.path.exists(LOG_ROOT):
319
     os.mkdir(LOG_ROOT)
331
     os.mkdir(LOG_ROOT)
320
 
332
 
333
+# This is added to each template context by the core context processor.  It is
334
+# useful for test/stage/qa sites where you want to show the version of the site
335
+# in the page title.
321
 DISPLAY_VERSION = False
336
 DISPLAY_VERSION = False
322
 
337
 
323
-THUMBNAIL_DEBUG = True
324
-
325
-# Must be within MEDIA_ROOT for sorl to work
338
+# Must be within MEDIA_ROOT for sorl to work which is a bit annoying.
326
 OSCAR_MISSING_IMAGE_URL = 'image_not_found.jpg'
339
 OSCAR_MISSING_IMAGE_URL = 'image_not_found.jpg'
327
 
340
 
341
+# Try and import local settings which can be used to override any of the above.
328
 try:
342
 try:
329
     from settings_local import *
343
     from settings_local import *
330
 except ImportError:
344
 except ImportError:

Ładowanie…
Anuluj
Zapisz