Przeglądaj źródła

Enhanced the messages dispatching

master
David Winterbottom 14 lat temu
rodzic
commit
b8445ec9d4

+ 9
- 5
oscar/apps/checkout/calculators.py Wyświetl plik

@@ -1,7 +1,7 @@
1
-
2
-
3 1
 class OrderTotalCalculator(object):
4
-    u"""Calculator class for calculating the order total."""
2
+    """
3
+    Calculator class for calculating the order total.
4
+    """
5 5
     
6 6
     def __init__(self, request):
7 7
         # We store a reference to the request as the total may 
@@ -11,7 +11,9 @@ class OrderTotalCalculator(object):
11 11
         self.request = request
12 12
     
13 13
     def order_total_incl_tax(self, basket, shipping_method=None, **kwargs):
14
-        u"""Return order total including tax"""
14
+        """
15
+        Return order total including tax
16
+        """
15 17
         # Default to returning the total including tax - use
16 18
         # the request.user object if you want to not charge tax
17 19
         # to particular customers.  
@@ -21,7 +23,9 @@ class OrderTotalCalculator(object):
21 23
         return total
22 24
     
23 25
     def order_total_excl_tax(self, basket, shipping_method=None, **kwargs):
24
-        u"""Return order total excluding tax"""
26
+        """
27
+        Return order total excluding tax
28
+        """
25 29
         total = basket.total_excl_tax
26 30
         if shipping_method:
27 31
             total += shipping_method.basket_charge_excl_tax()

+ 1
- 1
oscar/apps/checkout/views.py Wyświetl plik

@@ -511,7 +511,7 @@ class OrderPlacementMixin(CheckoutSessionMixin):
511 511
         if messages:      
512 512
             logger.info("Order #%s - sending %s messages", order.number, code)  
513 513
             dispatcher = Dispatcher(logger)
514
-            dispatcher.dispatch_messages(order.user, messages)
514
+            dispatcher.dispatch_order_messages(order, messages, event_type)
515 515
         else:
516 516
             logger.warning("Order #%s - no %s communication event type", order.number, code)
517 517
 

+ 7
- 2
oscar/apps/customer/utils.py Wyświetl plik

@@ -10,6 +10,11 @@ class Dispatcher(object):
10 10
     def __init__(self, logger):
11 11
         self.logger = logger
12 12
     
13
+    def dispatch_order_messages(self, order, messages, event_type):
14
+        self.dispatch_messages(order.user, messages)
15
+        # Create order comms event for audit
16
+        CommunicationEvent._default_manager.create(order=order, type=event_type)
17
+    
13 18
     def dispatch_messages(self, user, messages):
14 19
         """
15 20
         Send messages
@@ -18,7 +23,7 @@ class Dispatcher(object):
18 23
             self.send_email_messages(user, messages)
19 24
         if messages['sms']:
20 25
             self.send_text_message(user, messages['sms'])
21
-
26
+                                   
22 27
     def send_email_messages(self, user, messages):
23 28
         if not user.email:
24 29
             self.logger.warning("Unable to send email messages as user #%d has no email address", user.id)
@@ -44,6 +49,6 @@ class Dispatcher(object):
44 49
                                           body_text=email.body,
45 50
                                           body_html=messages['html'])
46 51
         
47
-    def send_order_sms(self, user, order, event_type):
52
+    def send_text_message(self, user, event_type):
48 53
         raise NotImplementedError
49 54
         

+ 2
- 1
oscar/apps/order/abstract_models.py Wyświetl plik

@@ -160,7 +160,8 @@ class AbstractOrderNote(models.Model):
160 160
 class AbstractCommunicationEvent(models.Model):
161 161
     """
162 162
     An order-level event involving a communication to the customer, such
163
-    as an confirmation email being sent."""
163
+    as an confirmation email being sent.
164
+    """
164 165
     order = models.ForeignKey('order.Order', related_name="communication_events")
165 166
     type = models.ForeignKey('customer.CommunicationEventType')
166 167
     date = models.DateTimeField(auto_now_add=True)

Ładowanie…
Anuluj
Zapisz