Przeglądaj źródła

Amend demo site to have a custom checkout app

It only creates a payment event at the moment but it will do more.  Oh
yes.
master
David Winterbottom 13 lat temu
rodzic
commit
446585df6a

+ 11
- 0
sites/demo/apps/app.py Wyświetl plik

@@ -0,0 +1,11 @@
1
+from oscar.app import Shop
2
+
3
+from apps.checkout.app import application as checkout_app
4
+
5
+
6
+class Application(Shop):
7
+    # Use local checkout app so we can mess with the view classes
8
+    checkout_app = checkout_app
9
+
10
+
11
+application = Application()

+ 0
- 0
sites/demo/apps/checkout/__init__.py Wyświetl plik


+ 11
- 0
sites/demo/apps/checkout/app.py Wyświetl plik

@@ -0,0 +1,11 @@
1
+from oscar.apps.checkout import app
2
+
3
+from apps.checkout import views
4
+
5
+
6
+class CheckoutApplication(app.CheckoutApplication):
7
+    # Replace the payment details view with our own
8
+    payment_details_view = views.PaymentDetailsView
9
+
10
+
11
+application = CheckoutApplication()

+ 8
- 0
sites/demo/apps/checkout/views.py Wyświetl plik

@@ -0,0 +1,8 @@
1
+from oscar.apps.checkout import views
2
+
3
+
4
+class PaymentDetailsView(views.PaymentDetailsView):
5
+
6
+    def handle_payment(self, order_number, total_incl_tax, **kwargs):
7
+        # Create a payment event
8
+        self.add_payment_event('Authorize', total_incl_tax)

+ 5
- 3
sites/demo/urls.py Wyświetl plik

@@ -1,18 +1,20 @@
1
-from django.conf.urls.defaults import *
1
+from django.conf.urls.defaults import patterns, url, include
2 2
 from django.conf import settings
3 3
 from django.contrib import admin
4 4
 from django.contrib.staticfiles.urls import staticfiles_urlpatterns
5 5
 from django.conf.urls.static import static
6 6
 from django.views.generic import TemplateView
7 7
 
8
-from oscar.app import shop
8
+from apps.app import application
9
+
10
+# These need to be imported into this namespace
9 11
 from oscar.views import handler500, handler404
10 12
 
11 13
 admin.autodiscover()
12 14
 
13 15
 urlpatterns = patterns('',
14 16
     (r'^admin/', include(admin.site.urls)),
15
-    (r'', include(shop.urls)),
17
+    (r'', include(application.urls)),
16 18
 )
17 19
 
18 20
 if settings.DEBUG:

Ładowanie…
Anuluj
Zapisz