You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

v0.8.rst 15KB

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