Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

v0.8.rst 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. =======================
  2. Oscar 0.8 release notes
  3. =======================
  4. .. warning::
  5. Since v0.8 has not been released yet, these release notes are still a work-in-progress.
  6. Welcome to Oscar 0.8!
  7. Table of contents:
  8. .. contents::
  9. :local:
  10. :depth: 1
  11. .. _overview_of_0.8:
  12. Overview
  13. --------
  14. Oscar now has a demo site customised for the US!
  15. Things that have been heavily rewritten:
  16. - Adding product to the basket
  17. Shipping functionality got a thorough re-working.
  18. Lots of methods deprecated in the 0.6 release have now been removed.
  19. Specifically, the partner "wrapper" functionality is now gone. All price and
  20. availability logic now needs to be handled with strategies.
  21. .. _compatibility_of_0.8:
  22. Compatibility
  23. -------------
  24. Oscar 0.8 is compatible with Django 1.5-1.7.
  25. Support for Python 2.6 has been dropped; Oscar works with Python 2.7, 3.3
  26. and 3.4.
  27. .. _new_in_0.8:
  28. What's new in Oscar 0.8?
  29. ------------------------
  30. Customisation just got easier!
  31. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  32. * Oscar's views are now dynamically imported. This means that they can be
  33. overridden like most other classes in Oscar; overriding the related
  34. Application instance is not necessary any more.
  35. * A new management command, ``oscar_fork_app``, has been introduced to help
  36. with the all-to-common pattern of forking an Oscar app to override one of
  37. it's classes.
  38. * The documentation around :doc:`/topics/customisation` has been given an
  39. overhaul to incorporate the changes.
  40. Reworked shipping app
  41. ~~~~~~~~~~~~~~~~~~~~~
  42. Several parts of the shipping app have been changed. The most important is a
  43. change to the API of shipping methods to avoid a potential thread safety issue.
  44. Any existing Oscar sites with custom shipping methods will need to adjust them
  45. to confirm to the new API.
  46. Other changes to the shipping app include:
  47. * All shipping models now have abstract base classes, similar to
  48. the rest of Oscar, allowing them to be customised in the standard way.
  49. * The ``WeightBand.upper_limit`` model field is now a ``DecimalField``, just like the other
  50. weight-related fields.
  51. * The Django admin interface for the ``WeightBased`` shipping method has been
  52. made slightly more useful.
  53. See the
  54. :ref:`backwards incompatible changes <incompatible_shipping_changes_in_0.8>`
  55. for the shipping app and the
  56. :doc:`guide to configuring shipping </howto/how_to_configure_shipping>`
  57. for more information.
  58. US demo site
  59. ~~~~~~~~~~~~
  60. To help developers building sites for the US, a new example Oscar site has been
  61. included in the repo. This customises core Oscar to treat all prices as
  62. excluding tax and then calculate and apply taxes once the shipping address is
  63. known.
  64. See :ref:`us_site` for more information.
  65. Basket additions clean-up
  66. ~~~~~~~~~~~~~~~~~~~~~~~~~
  67. The forms and views around adding things to your basket has been vigorously
  68. reworked. This cleans up some very old code there and ensures variant products
  69. are handled in a consistent way.
  70. The changes do require changing the constructor signature of the
  71. ``AddToBasketForm`` - the details are documented in the
  72. :ref:`basket_app_changes`.
  73. Checkout improvements
  74. ~~~~~~~~~~~~~~~~~~~~~
  75. The checkout process now skips payment if the order total is zero (e.g. when
  76. ordering free products or using a voucher). As part of that, checkout views
  77. now evaluate *pre-conditions* (as before) and newly introduced
  78. *skip conditions*. This should make customising the checkout flow easier.
  79. Cleanup around shipping methods
  80. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  81. * The models of the shipping app now have abstract base classes, similar to
  82. the rest of Oscar.
  83. * The legacy ``ShippingMethod`` name of the interface of the shipping app has
  84. been removed. Inherit from ``shipping.base.Base`` for the class instead, and
  85. inherit from ``shipping.abstract_models.AbstractBase`` for model-based
  86. shipping methods.
  87. * ``oscar.apps.shipping.Scales`` has been renamed and moved to
  88. ``oscar.apps.shipping.scales.Scale``, and is now overridable.
  89. * ``WeightBand.upper_limit`` is now a ``DecimalField``, just like the other
  90. weight-related fields.
  91. * The Django admin interface for the ``WeightBased`` shipping method has been
  92. made slightly more useful. Contributions for a dedicated dashboard app are
  93. most welcome!
  94. .. _minor_changes_in_0.8:
  95. Minor changes
  96. ~~~~~~~~~~~~~
  97. * The ``OSCAR_CURRENCY_LOCALE`` setting has been removed. The locale is now
  98. automatically determined from the current language. This ensures prices are
  99. always shown in the correct format when switching languages.
  100. * The login and registration view now redirects staff users to the dashboard
  101. after logging in. It also employs flash messages to welcome returning and
  102. newly registered users.
  103. * The basket middleware now assigns a ``basket_hash`` attribute to the
  104. ``request`` instance. This provides a hook for basket caching.
  105. * The tracking pixel now also reports the Oscar version in use. This was
  106. forgotten when adding tracking of the Python and Django version in 0.7.
  107. Total information collected now is the versions of Django, Python and Oscar.
  108. * ``OSCAR_SLUG_FUNCTION`` now accepts both string notation and a callable.
  109. * The default templates now allow the order status to be changed on the
  110. dashboard order detail page.
  111. * The forms for the order dashboard views are now loaded dynamically so they
  112. can be overridden.
  113. .. _incompatible_changes_in_0.8:
  114. Backwards incompatible changes in 0.8
  115. -------------------------------------
  116. .. _incompatible_shipping_changes_in_0.8:
  117. Shipping
  118. ~~~~~~~~
  119. The shipping method API has been altered to avoid potential thread-safety
  120. issues. Prior to v0.8, shipping methods had a ``set_basket`` method which
  121. allowed a basket instance to be assigned. This was really a crutch to allow
  122. templates to have easy access to shipping charges. However, it was also a
  123. design problem as shipping methods could be instantiated at compile-time
  124. leading to a thread safety issue where multiple threads could assign a basket
  125. to the same shipping method instance.
  126. In Oscar 0.8, shipping methods are stateless services that have a method
  127. :func:`~oscar.apps.shipping.methods.Base.calculate` that takes a basket and
  128. returns a ``Price`` instance. New template tags are provided that allow these
  129. shipping charges to be accessed from templates.
  130. This API change does require quite a few changes as both the shipping method
  131. and shipping charge now need to be passed around separately:
  132. * Shipping methods no longer have ``charge_excl_tax``,
  133. ``charge_incl_tax`` and ``is_tax_known`` properties.
  134. * The :class:`~oscar.apps.order.utils.OrderCreator` class now requires the
  135. ``shipping_charge`` to be passed to ``place_order``.
  136. * The signature of the :class:`~oscar.apps.checkout.calculators.OrderTotalCalculator`
  137. class has changed to accept ``shipping_charge`` rather than a
  138. ``shipping_method`` instance.
  139. * The signature of the
  140. :func:`~oscar.apps.checkout.session.CheckoutSessionMixin.get_order_totals`
  141. method has changed to accept the ``shipping_charge`` rather than a
  142. ``shipping_method`` instance.
  143. Other potentially breaking changes related to shipping include:
  144. * The :class:`~oscar.apps.order.utils.OrderCreator` class no longer defaults to
  145. free shipping: a shipping method and charge have to be explicitly passed in.
  146. * The ``Base`` shipping method class now lives in ``oscar.apps.shipping.methods``.
  147. * The ``find_by_code`` method of the shipping ``Repository`` class has been
  148. removed as it is no longer used.
  149. * The parameters for
  150. :func:`oscar.apps.shipping.respository.Repository.get_shipping_methods`
  151. have been re-ordered to reflect which are the most important.
  152. * The legacy ``ShippingMethod`` name of the interface of the shipping app has
  153. been removed. Inherit from ``shipping.base.Base`` for the class instead, and
  154. inherit from ``shipping.abstract_models.AbstractBase`` for model-based
  155. shipping methods.
  156. * ``oscar.apps.shipping.Scales`` has been renamed and moved to
  157. ``oscar.apps.shipping.scales.Scale``, and is now overridable.
  158. Misc
  159. ~~~~
  160. * The ``oscar_calculate_scores`` command has been `rewritten`_ to use the ORM
  161. instead of raw SQL. That exposed a bug in the previous calculations,
  162. where purchases got weighed less than any other event. When you upgrade,
  163. your total scores will be change. If you rely on the old behaviour,
  164. just extend the ``Calculator`` class and adjust the weights.
  165. * ``Product.score`` was just duplicating ``ProductRecord.score`` and has been
  166. removed. Use ``Product.stats.score`` instead.
  167. * Oscar has child products to model tightly coupled products, and
  168. ``Product.recommended_products`` to model products that are loosely related
  169. (e.g. used for upselling). ``Product.related_products`` was a
  170. third option that sat somewhere in between, and which was not well supported.
  171. We fear it adds confusion, and in the spirit of keeping Oscar core lean,
  172. has been removed. If you're using it, switch to
  173. ``Product.recommended_products`` or just add the field back to your
  174. custom Product instance and ``ProductForm`` when migrating.
  175. .. _rewritten: https://github.com/tangentlabs/django-oscar/commit/d8b4dbfed17be90846ea4bc47b5f7b39ad944c24
  176. Basket line stockrecords
  177. ~~~~~~~~~~~~~~~~~~~~~~~~
  178. The basket line model got a reference to the stockrecord in Oscar 0.6. The
  179. basket middleware since then updated basket lines to have stockrecords if
  180. one was missing. If any lines are still missing a stockrecord, we'd expect them
  181. to be from from submitted baskets or from old, abandoned baskets.
  182. This updating of basket lines has been removed for 0.8 as it incurs additional
  183. database queries. Oscar 0.8 now also enforces the stockrecord by making it
  184. the ``stockrecord`` field of basket ``Line`` model no longer nullable.
  185. There is a migration that makes the appropriate schema change but, before that
  186. runs, you may need to clean up your ``basket_line`` table to ensure that all
  187. existing null values are replaced or removed.
  188. Here's a simple script you could run before upgrading which should ensure there
  189. are no nulls in your ``basket_line`` table:
  190. .. code-block:: python
  191. from oscar.apps.basket import models
  192. from oscar.apps.partner.strategy import Selector
  193. strategy = Selector().strategy()
  194. lines = models.Line.objects.filter(stockrecord__isnull=True):
  195. for line in lines:
  196. info = strategy.fetch_for_product(line.product)
  197. if line.stockrecord:
  198. line.stockrecord = info.stockrecord
  199. line.save()
  200. else:
  201. line.delete()
  202. * The ``reload_page_response`` method of
  203. :class:`~oscar.apps.dashboard.orders.views.OrderDetailView`
  204. has been renamed to ``reload_page``.
  205. .. _basket_app_changes:
  206. Basket app changes
  207. ~~~~~~~~~~~~~~~~~~
  208. - The ``basket:add`` URL now required the primary key of the "base" product to
  209. be included. This allows the same form to be used for both GET and POST
  210. requests for variant products.
  211. - The ``ProductSelectionForm`` is no longer used and has been removed.
  212. - The constructor of the :class:`~oscar.apps.basket.forms.AddToBasketForm` has
  213. been adjusted to take the basket and the purchase info tuple as parameters
  214. instead of the request instance (c74f57bf_ and 8ba283e8_).
  215. .. _c74f57bf: https://github.com/tangentlabs/django-oscar/commit/c74f57bf434661877f4d2d2259e7e7eb18b34951#diff-d200ac8746274e0307f512af886e1f3eR148
  216. .. _8ba283e8: https://github.com/tangentlabs/django-oscar/commit/8ba283e8c4239e4eff95da5e8097a17ecfadf5f5
  217. Migrations
  218. ~~~~~~~~~~
  219. * Catalogue:
  220. - ``0021`` - Add ``unique_together`` to ``ProductAttributeValue``,
  221. ``ProductRecommendation`` and ``ProductCategory``
  222. - ``0022`` - Remove ``Product.score`` field.
  223. * Order:
  224. - ``0029`` - Add ``unique_together`` to ``PaymentEventQuantity`` and ``ShippingEventQuantity``
  225. * Promotions:
  226. - ``0006`` - Add ``unique_together`` to ``OrderedProduct``
  227. * Shipping:
  228. - ``0007`` - Change ``WeightBand.upper_limit`` from ``FloatField`` to ``DecimalField``
  229. .. _deprecated_features_in_0.8:
  230. Removal of deprecated features
  231. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  232. These methods have been removed:
  233. * ``oscar.apps.catalogue.abstract_models.AbstractProduct.has_stockrecord``
  234. * ``oscar.apps.catalogue.abstract_models.AbstractProduct.stockrecord``
  235. * ``oscar.apps.catalogue.abstract_models.AbstractProduct.is_available_to_buy``
  236. * ``oscar.apps.catalogue.abstract_models.AbstractProduct.is_purchase_permitted``
  237. * ``oscar.apps.catalogue.views.get_product_base_queryset``
  238. * ``oscar.apps.partner.abstract_models.AbstractStockRecord.is_available_to_buy``
  239. * ``oscar.apps.partner.abstract_models.AbstractStockRecord.is_purchase_permitted``
  240. * ``oscar.apps.partner.abstract_models.AbstractStockRecord.availability_code``
  241. * ``oscar.apps.partner.abstract_models.AbstractStockRecord.availability``
  242. * ``oscar.apps.partner.abstract_models.AbstractStockRecord.max_purchase_quantity``
  243. * ``oscar.apps.partner.abstract_models.AbstractStockRecord.dispatch_date``
  244. * ``oscar.apps.partner.abstract_models.AbstractStockRecord.lead_time``
  245. * ``oscar.apps.partner.abstract_models.AbstractStockRecord.price_incl_tax``
  246. * ``oscar.apps.partner.abstract_models.AbstractStockRecord.price_tax``
  247. These classes have been removed
  248. * ``oscar.apps.partner.prices.DelegateToStockRecord``
  249. * ``oscar.apps.partner.availability.DelegateToStockRecord``