Sfoglia il codice sorgente

Update 0.8 release notes re shipping method changes

master
David Winterbottom 11 anni fa
parent
commit
365a92c94c

+ 2
- 2
docs/source/howto/how_to_configure_shipping.rst Vedi File

@@ -109,10 +109,10 @@ The repository class is responsible for return shipping method instances.  Oscar
109 109
 defines several of these but it is easy to write your own, their interface is
110 110
 simple.
111 111
 
112
-The base shipping method class ``oscar.apps.shipping.base.Base`` (that
112
+The base shipping method class ``oscar.apps.shipping.methods.Base`` (that
113 113
 all shipping methods should subclass has API:
114 114
 
115
-.. autoclass:: oscar.apps.shipping.base.Base
115
+.. autoclass:: oscar.apps.shipping.methods.Base
116 116
     :members:
117 117
     :noindex:
118 118
 

+ 0
- 3
docs/source/ref/apps/shipping.rst Vedi File

@@ -85,9 +85,6 @@ Simple really - follow these steps:
85 85
 Methods
86 86
 -------
87 87
 
88
-.. automodule:: oscar.apps.shipping.base
89
-    :members:
90
-
91 88
 .. automodule:: oscar.apps.shipping.methods
92 89
     :members:
93 90
 

+ 74
- 0
docs/source/ref/templatetags.rst Vedi File

@@ -0,0 +1,74 @@
1
+=============
2
+Template tags
3
+=============
4
+
5
+Shipping tags
6
+-------------
7
+
8
+Load these tags using ``{% load shipping_tags %}``.
9
+
10
+``shipping_charge``
11
+~~~~~~~~~~~~~~~~~~~
12
+
13
+Injects the shipping charge into the template context:
14
+
15
+Usage:
16
+
17
+.. code-block:: html+django
18
+
19
+   {% shipping_charge shipping_method basket as name %}
20
+   Shipping charge is {{ name }}.
21
+
22
+The arguments are:
23
+
24
+===================  =====================================================
25
+Argument             Description
26
+===================  =====================================================
27
+``shipping_method``  The shipping method instance
28
+``basket``           The basket instance to calculate shipping charges for
29
+``name``             The variable name to assign the charge to
30
+===================  =====================================================
31
+
32
+``shipping_charge_discount``
33
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
34
+
35
+Injects the shipping discount into the template context:
36
+
37
+Usage:
38
+
39
+.. code-block:: html+django
40
+
41
+   {% shipping_discount shipping_method basket as name %}
42
+   Shipping discount is {{ charge }}.
43
+
44
+The arguments are:
45
+
46
+===================  =====================================================
47
+Argument             Description
48
+===================  =====================================================
49
+``shipping_method``  The shipping method instance
50
+``basket``           The basket instance to calculate shipping charges for
51
+``name``             The variable name to assign the charge to
52
+===================  =====================================================
53
+
54
+``shipping_charge_excl_discount``
55
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
56
+
57
+Injects the shipping charges with no discounts applied into the template context:
58
+
59
+Usage:
60
+
61
+.. code-block:: html+django
62
+
63
+   {% shipping_charge_excl_discount shipping_method basket as name %}
64
+   Shipping discount is {{ name }}.
65
+
66
+The arguments are:
67
+
68
+===================  =====================================================
69
+Argument             Description
70
+===================  =====================================================
71
+``shipping_method``  The shipping method instance
72
+``basket``           The basket instance to calculate shipping charges for
73
+``name``             The variable name to assign the charge to
74
+===================  =====================================================

+ 86
- 19
docs/source/releases/v0.8.rst Vedi File

@@ -17,6 +17,8 @@ Overview
17 17
 
18 18
 Oscar now has a demo site customised for the US!
19 19
 
20
+Shipping methods got a thorough re-working.
21
+
20 22
 Lots of methods deprecated in the 0.6 release have now been removed.
21 23
 Specifically, the partner "wrapper" functionality is now gone. All price and
22 24
 availability logic now needs to be handled with strategies.
@@ -50,30 +52,17 @@ Customisation just got easier!
50 52
 * The documentation around :doc:`/topics/customisation` has been given an
51 53
   overhaul to incorporate the changes.
52 54
 
53
-US demo site
54
-------------
55
+Reworked shipping app
56
+---------------------
55 57
 
56
-To help developers building sites for the US, a new example Oscar site has been
57
-included in the repo. This customises core Oscar to treat all prices as
58
-excluding tax and then calculate and apply taxes once the shipping address is
59
-known.
58
+Several parts of the shipping app have been changed. The most important is a
59
+change to the API of shipping methods to avoid a potential thread safety issue.
60 60
 
61
-See :ref:`us_site` for more information.
62
-
63
-Cleanup around shipping methods
64
--------------------------------
61
+Other changes to the shipping app include:
65 62
 
66
-* The models of the shipping app now have abstract base classes, similar to
63
+* All shipping models now have abstract base classes, similar to
67 64
   the rest of Oscar.
68 65
 
69
-* The legacy ``ShippingMethod`` name of the interface of the shipping app has
70
-  been removed. Inherit from ``shipping.base.Base`` for the class instead, and
71
-  inherit from ``shipping.abstract_models.AbstractBase`` for model-based
72
-  shipping methods.
73
-
74
-* ``oscar.apps.shipping.Scales`` has been renamed and moved to
75
-  ``oscar.apps.shipping.scales.Scale``, and is now overridable.
76
-
77 66
 * ``WeightBand.upper_limit`` is now a ``DecimalField``, just like the other
78 67
   weight-related fields.
79 68
 
@@ -81,6 +70,22 @@ Cleanup around shipping methods
81 70
   made slightly more useful. Contributions for a dedicated dashboard app are
82 71
   most welcome!
83 72
 
73
+See the 
74
+:ref:`backwards incompatible changes <incompatible_shipping_changes_in_0.8>` 
75
+for the shipping app and the 
76
+:doc:`guide to configuring shipping </howto/how_to_configure_shipping>` 
77
+for more information.
78
+
79
+US demo site
80
+------------
81
+
82
+To help developers building sites for the US, a new example Oscar site has been
83
+included in the repo. This customises core Oscar to treat all prices as
84
+excluding tax and then calculate and apply taxes once the shipping address is
85
+known.
86
+
87
+See :ref:`us_site` for more information.
88
+
84 89
 .. _minor_changes_in_0.8:
85 90
 
86 91
 Minor changes
@@ -117,6 +122,68 @@ Bugfixes
117 122
 Backwards incompatible changes in 0.8
118 123
 =====================================
119 124
 
125
+.. _incompatible_shipping_changes_in_0.8:
126
+
127
+Shipping app
128
+------------
129
+
130
+The shipping method API has been altered to avoid potential thread-safety
131
+issues. Prior to v0.8, shipping methods had a ``set_basket`` method which
132
+allowed a basket instance to be assigned to the method. This was really a
133
+crutch to allow templates to have easy access to shipping charges. However, it
134
+was also a design problem as shipping methods could be instantiated at
135
+compile-time leading to a thread safety issue where multiple threads could
136
+assign a basket to the same shipping method instance.
137
+
138
+In Oscar 0.8, shipping methods are stateless services that have a method
139
+:func:`~oscar.apps.shipping.methods.Base.calculate` that takes a basket and
140
+returns a ``Price`` instance.  New template tags are provided that allow these
141
+shipping charges to be accessed from templates.
142
+
143
+This API change does require quite a few changes as both the shipping method
144
+and shipping charge now need to be passed around separately:
145
+
146
+* The :class:`~oscar.apps.order.utils.OrderCreator` class now requires the
147
+  ``shipping_charge`` to be passed to ``place_order``.
148
+
149
+* The :class:`~oscar.apps.order.utils.OrderCreator` class no longer defaults to
150
+  free shipping: a shipping method and charge has to be explicitly passed in.
151
+
152
+* The signature of the :class:`~oscar.apps.checkout.calculators.OrderTotalCalculator` 
153
+  class has changed to accept the shipping charge rather than a shipping
154
+  method instance.
155
+
156
+* The signature of the
157
+  :func:`~oscar.apps.checkout.session.CheckoutSessionMixin.get_order_totals` 
158
+  method has changed to accept the shipping charge rather than a shipping
159
+  method instance.
160
+
161
+Other potentially breaking changes to the shipping app:
162
+
163
+* Shipping methods no longer have ``charge_excl_tax``,
164
+  ``charge_incl_tax`` and ``is_tax_known`` properties.
165
+
166
+* The ``Base`` shipping method class now lives in
167
+  ``oscar.apps.shipping.methods``.
168
+
169
+* The ``find_by_code`` method of the shipping ``Repository`` class has been
170
+  removed as it is no longer used. 
171
+
172
+* The parameters for
173
+  :func:`oscar.apps.shipping.respository.Repository.get_shipping_methods`
174
+  have been re-ordered to reflect which are the most important.
175
+
176
+* The legacy ``ShippingMethod`` name of the interface of the shipping app has
177
+  been removed. Inherit from ``shipping.base.Base`` for the class instead, and
178
+  inherit from ``shipping.abstract_models.AbstractBase`` for model-based
179
+  shipping methods.
180
+
181
+* ``oscar.apps.shipping.Scales`` has been renamed and moved to
182
+  ``oscar.apps.shipping.scales.Scale``, and is now overridable.
183
+
184
+Misc
185
+----
186
+
120 187
 * The ``shipping`` app saw a few renames; please see the section above.
121 188
 * The ``oscar_calculate_scores`` command has been `rewritten`_ to use the ORM
122 189
   instead of raw SQL. That exposed a bug in the previous calculations,

Loading…
Annulla
Salva