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.6.rst 32KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825
  1. =======================
  2. Oscar 0.6 release notes
  3. =======================
  4. :release: 2014-01-15
  5. It took a while but it's finally here: welcome to Oscar 0.6!
  6. These release notes cover the `new features`_ as well as `backwards incompatible changes`_
  7. that you'll want to be aware of when upgrading from Oscar 0.5 or
  8. earlier. This release contains some major changes to core APIs which means
  9. many old APIs are scheduled to be dropped - see the `deprecation plan`_ to avoid any
  10. nasty surprises.
  11. To upgrade your Oscar site, make sure you study both the `backwards incompatible changes`_
  12. and the `deprecated features`_. If you have any undocumented issues, please
  13. let us know on the `mailing list`_.
  14. .. _`new features`: `What's new in Oscar 0.6?`_
  15. .. _`upgrading advice`: `Upgrading notes`_
  16. .. _`deprecation plan`: `Features deprecated in 0.6`_
  17. .. _`deprecated features`: `Features deprecated in 0.6`_
  18. .. _`backwards incompatible changes`: `Backwards incompatible changes in 0.6`_
  19. .. _`mailing list`: https://groups.google.com/forum/?fromgroups#!forum/django-oscar
  20. Table of contents:
  21. * `Overview`_
  22. * `What's new in Oscar 0.6?`_
  23. * `Backwards incompatible changes in 0.6`_
  24. * `Features deprecated in 0.6`_
  25. Overview
  26. ========
  27. The biggest change in Oscar 0.6 is the reworking of `pricing and availability`_, which
  28. builds on top of the change to allow `multiple stockrecords per product`_. The
  29. change is largely backwards compatible with the old system of "partner
  30. wrappers" but it is recommended to upgrade to the new system. Support for
  31. partner wrappers will be removed for Oscar 0.7.
  32. Oscar 0.6 also introduces better support for marketplace-like functionality
  33. with the so-called permission-based dashboard. It is now possible to give
  34. non-staff users access to a subset of the dashboard's views (products and
  35. orders) by setting the new ``dashboard_access`` permission.
  36. `Oscar now supports Django 1.5`_ and its custom user model. This has been only
  37. tested in the context of starting a new Oscar project with a custom model.
  38. Switching from a separate "profile" model to the new system is not recommended
  39. at this point.
  40. Oscar also supports Django 1.6 although this is considered experimental at this
  41. stage. It's possible there are still some incompatibilities that haven't been
  42. teased out just yet.
  43. Other notable new features include:
  44. * A feature-rich `demo site`_ that illustrates how Oscar can be customised. It
  45. uses several of Oscar's many extensions such as django-oscar-paypal_,
  46. django-oscar-datacash_ and django-oscar-stores_. It is intended as a
  47. reference site for Oscar.
  48. * `Partners can now have addresses`_.
  49. * `Customer wishlists`_
  50. * `New helper methods`_ in the ``EventHandler`` class for order processing.
  51. * `Reworked search app`_ with support for easy faceting.
  52. Also, to help justify Tangent's sponsorship of Oscar,
  53. a simple `tracking mechanism`_ has been introduced.
  54. .. _`Oscar now supports Django 1.5`: `django_support`_
  55. .. _`Partners can now have addresses`: `Partner addresses`_
  56. .. _`Customer wishlists`: `Wishlists`_
  57. .. _`New helper methods`: `Order processing changes`_
  58. .. _`tracking mechanism`: `Tracking Oscar sites`_
  59. What's new in Oscar 0.6?
  60. ========================
  61. Multiple stockrecords per product
  62. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  63. Products can now have multiple stockrecords rather than just one. This allows a
  64. product to be fulfilled by one of several partners. This is a key requirement
  65. for large-scale e-commerce sites selling millions of products that use many
  66. different fulfillment partners. It also allows products to be sold in
  67. different currencies.
  68. This changes means several APIs are `deprecated`_ as they assume there is only
  69. one stockrecord per product.
  70. .. _`deprecated`: `Features deprecated in 0.6`_
  71. Pricing and availability
  72. ~~~~~~~~~~~~~~~~~~~~~~~~
  73. When products can have many stockrecords, a process needs to be in place to
  74. choose which one is selected for a given customer and product. To handle this,
  75. a new "strategy" class has been introduced responsible for selecting the appropriate
  76. stockrecord for a given customer and product.
  77. This change also paved the way for reworking how prices, taxes and availability
  78. are handled. Instead of using `"partner wrappers"`_, the strategy class is
  79. responsible for returning availability details and prices for a particular
  80. product. New classes known as pricing and availability policies are used to
  81. encapsulate this information.
  82. These changes allows Oscar to dynamically determine prices, partner and availability
  83. given customer and product. This enables several advanced features such as:
  84. * Fulfilling a product from the partner that offers the best margin.
  85. * Fulfilling a product from the partner geographically closest to the customer.
  86. * Supporting transactions in multiple currencies on the same site.
  87. * Supporting different tax treatments on the same site (eg UK VAT and US sales
  88. tax)
  89. * Having different pricing and availability policies for different customers.
  90. It also provides a customisation layer for custom price and availability logic.
  91. There's a great deal of flexibility. See the guide to
  92. :doc:`prices and availability </topics/prices_and_availability>`
  93. for more information.
  94. Note that the :func:`oscar.templatetags.currency_filters.currency` now
  95. accepts an optional currency parameter.
  96. Permission-based dashboard
  97. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  98. Three changes were necessary to better support marketplace scenarios within
  99. Oscar:
  100. * Oscar's core :class:`oscar.core.application.Application` class now supports
  101. specifying permissions on a per-view basis. This is done via a new default
  102. decorator. Legacy behaviour is unchanged.
  103. * The dashboard's menu's are now built dynamically. If the current user does
  104. not have access to some views in :ref:`OSCAR_DASHBOARD_NAVIGATION`, they will
  105. be omitted in the menu returned by
  106. :meth:`oscar.apps.dashboard.nav.create_menu`.
  107. * The index, catalogue and order dashboard views have been modified to allow
  108. access to non-staff users. See :doc:`/ref/apps/dashboard` for details.
  109. * :attr:`oscar.apps.partner.abstract_models.AbstractPartner.users` was not
  110. used by core Oscar prior 0.6. It is now used to model access for the
  111. permission-based dashboard.
  112. Payment models have abstract versions
  113. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  114. The :doc:`payment models </ref/apps/payment>` have been split into abstract and
  115. concrete versions. This brings them inline with other Oscar apps and allows
  116. them to be customised.
  117. Wishlists
  118. ~~~~~~~~~
  119. Wishlist functionality has finally landed. Signed in customers are now able to
  120. create multiple named wishlists and add products to them. There is a new
  121. section in the customer's account where wishlists can be managed.
  122. Partner dashboard & addresses
  123. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  124. Partners can now have addresses. These are useful for US sales tax where tax
  125. calculations need to know the origin of a product being shipped.
  126. A dashboard to handle partners, their users and addresses has been added.
  127. Checkout
  128. ~~~~~~~~
  129. The :class:`~oscar.apps.checkout.views.PaymentDetailsView` checkout view has
  130. been restructured slightly to be more flexible. There is a new
  131. ``build_submission`` method which is responsible for building a dict of all data
  132. for passing to the ``submit`` method. This includes the shipping address and
  133. shipping method which were previously loaded indirectly within the ``submit``
  134. method. The ``submit`` method has also been extended to take additional parameters.
  135. Demo site
  136. ~~~~~~~~~
  137. Oscar now ships with a demo site along side the sandbox site. While the sandbox
  138. is a minimal Django project that uses Oscar with all its defaults, the demo site
  139. is a more realistic example of an Oscar project. It has a custom skin and makes
  140. many alterations to the default Oscar behaviour.
  141. It's features include:
  142. * A range of different product types: books, downloads, clothing
  143. * PayPal Express integration using django-oscar-paypal_
  144. * Datacash integration using django-oscar-datacash_
  145. .. _django-oscar-paypal: https://github.com/tangentlabs/django-oscar-paypal
  146. .. _django-oscar-datacash: https://github.com/tangentlabs/django-oscar-datacash
  147. .. _django-oscar-stores: https://github.com/tangentlabs/django-oscar-stores
  148. Further reading:
  149. * :doc:`The demo site </internals/sandbox>`.
  150. .. _django_support:
  151. Django 1.5, 1.6 and custom user model support
  152. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  153. Oscar now supports Django 1.5 and 1.6.
  154. Specifically, Oscar supports `custom user models`_, the headline new feature in Django
  155. 1.5. These can be used standalone or with a one-to-one profile model: Oscar's
  156. account forms inspect the model fields to dynamically pick up the fields for
  157. editing and display.
  158. There are some restrictions on what fields a custom user model must have. For
  159. instance, Oscar's default auth backend requires the user model to have an email
  160. and password field. New Oscar projects are encouraged to use the provided
  161. abstract user model as the base for their users.
  162. Further reading:
  163. * :doc:`How to use a custom user model </howto/use_a_custom_user_model>`.
  164. .. _`custom user models`: https://docs.djangoproject.com/en/dev/topics/auth/customizing/#specifying-a-custom-user-model
  165. .. _`documentation on user models`: https://docs.djangoproject.com/en/dev/topics/auth/customizing/#specifying-a-custom-user-model
  166. Accounts
  167. ~~~~~~~~
  168. The views and templates of the accounts section have been reworked to be clearer
  169. and easier to extend.
  170. Bootstrap-WYSIHTML5 replaced by TinyMCE
  171. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  172. TinyMCE 4.0 is now used in the dashboard for all textareas with class
  173. ``wysiwyg``. This has better browser support and is easier to customise than
  174. bootstrap-wysihtml5.
  175. It is easy to configure or replace with the HTML editor of your choice.
  176. Better bankcard handling
  177. ~~~~~~~~~~~~~~~~~~~~~~~~
  178. The bankcard model in the payment app has been greatly improved.
  179. Customer-facing range pages
  180. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  181. Ranges can now be flagged as public which means they can be browsed by
  182. customers. They can be used to created curated collections of products.
  183. Products can be manually reordered to display products in the specific
  184. order to customers.
  185. The core :class:`~oscar.apps.offer.models.Range` model has been extended with a
  186. HTML description field also.
  187. Reworked search app
  188. ~~~~~~~~~~~~~~~~~~~
  189. Oscar's search app has been reviewed and simplified. The main view class has
  190. been reworked to provide better support for faceting, which can be easily
  191. specified using the ``OSCAR_SEARCH_FACETS`` setting.
  192. The ``SuggestionsView`` has been removed as it wasn't being used. A later
  193. version of Oscar will include a replacement.
  194. Order processing changes
  195. ~~~~~~~~~~~~~~~~~~~~~~~~
  196. There are changes to order processing methods
  197. Tracking Oscar sites
  198. ~~~~~~~~~~~~~~~~~~~~
  199. Oscar's dashboard now serves a single pixel image from one of Tangent's
  200. servers. This is included to gather information on which sites use Oscar,
  201. which is an important metric for Tangent, who sponsor Oscar's development.
  202. It can easily be disabled by setting ``OSCAR_TRACKING=False``. If you do opt
  203. out, please email the mailing list with any production Oscar sites you are
  204. running. This will help to ensure investment in Oscar's future.
  205. Minor changes
  206. ~~~~~~~~~~~~~
  207. * detox_ is a new dependency, which allows running `tox` tests in parallel.
  208. .. _detox: https://pypi.python.org/pypi/detox
  209. * ``OSCAR_ALLOW_ANON_REVIEWS`` has been a documented setting since Oscar 0.4.
  210. But there's never been any code to support this, which has been rectified with
  211. this release. Things should now work as expected.
  212. * Oscar uses a cookie to display recently displayed products. This cookie never
  213. expired and wasn't a HttpOnly cookie. It is now a HttpOnly cookie and expires
  214. after 7 days. Additionally, two settings have been introduced to configure
  215. it analogues to the basket cookies:
  216. ``OSCAR_RECENTLY_VIEWED_COOKIE_LIFETIME`` and
  217. ``OSCAR_RECENTLY_VIEWED_COOKIE_NAME``.
  218. Backwards incompatible changes in 0.6
  219. =====================================
  220. Checkout
  221. ~~~~~~~~
  222. Several changes have been made to the checkout in the name of simplification
  223. and making things easier to customise.
  224. The ``PaymentDetailsView`` has been adjusted to explicitly pass variables
  225. around rather than relying on methods that load them on demand. This makes
  226. customisation easier.
  227. * The ``submit`` method in
  228. :class:`~oscar.apps.checkout.views.PaymentDetailsView` has a new signature.
  229. It now accepts the user, shipping address, shipping method and order total as
  230. required parameters The intention is that the ``build_submission`` methods
  231. returns a dict of kwargs for ``submit`` so that it can be called like::
  232. submission = self.build_submission()
  233. return self.submit(**submission)
  234. If your payment or order submission process requires additional parameters (eg
  235. a bankcard), override the ``build_submission`` method to provide them. The
  236. dict returns from the new ``build_submission`` method is also passed to the
  237. template.
  238. * The ``handle_payment`` method in
  239. :class:`~oscar.apps.checkout.views.PaymentDetailsView` now accepts a
  240. :class:`~oscar.core.prices.Price` instance instead of a Decimal for the order
  241. total.
  242. * The ``handle_order_placement`` method in
  243. :class:`~oscar.apps.checkout.mixins.OrderPlacementMixin`
  244. now accepts the user, shipping address and shipping method in a
  245. different order consistent with the ``submit`` method from
  246. ``PaymentDetailsView``.
  247. * The ``place_order`` method in
  248. :class:`~oscar.apps.checkout.mixins.OrderPlacementMixin`
  249. has a new signature. The parameters have been reordered and the shipping
  250. address, shipping method and billing address must be passed in explicitly (as
  251. unsaved instances).
  252. * The ``create_shipping_address`` method in
  253. :class:`~oscar.apps.checkout.mixins.OrderPlacementMixin` has changed
  254. signature. Instead of being passed a basket, it is now passed the user and
  255. an unsaved shipping address instance.
  256. * The ``create_billing_address`` method in
  257. :class:`~oscar.apps.checkout.mixins.OrderPlacementMixin` has changed
  258. signature. It is now passed an unsaved billing address instance as well as
  259. a shipping address instance.
  260. * The ``get_shipping_method`` (from
  261. :class:`~oscar.apps.checkout.session.CheckoutSessionMixin`) no longer
  262. defaults to returning free shipping if no shipping method can be looked up.
  263. * The :class:`~oscar.apps.checkout.calculators.OrderTotalCalculator` now
  264. returns a :class:`~oscar.core.prices.Price` instance from a new ``calculate``
  265. method. The old methods ``order_total_incl_tax`` and
  266. ``order_total_excl_tax`` have been removed.
  267. Signature changes
  268. ~~~~~~~~~~~~~~~~~
  269. Several classes and functions have had signature changes:
  270. * The ``basket_form`` templatetag has been altered to take the ``request`` as the
  271. first parameter, not ``request.basket``.
  272. * The :class:`oscar.apps.customer.forms.EmailAuthenticationForm` form needs to
  273. be instantated with a host name so prevent redirects to external sites.
  274. * The two product review forms, ``SignedInUserProductReviewForm`` and
  275. ``AnonymousUserProductReviewForm``, have been replaced by a new
  276. :class:`oscar.apps.catalogue.reviews.forms.ProductReviewForm`.
  277. * 3 properties have been removed from
  278. :class:`oscar.apps.catalogue.abstract_models.AbstractProductImage` as they
  279. were unused: ``resized_image_url``, ``fullsize_url`` and ``thumbnail_url``.
  280. Thumbnailing is instead achieved in templates with Sorl.
  281. Loading shipping methods
  282. ~~~~~~~~~~~~~~~~~~~~~~~~
  283. The default implementation of the shipping method repository has been adjusted
  284. to avoid thread-safety issues. If you define your own shipping ``Repository``
  285. class, ensure that your shipping methods are instantiated per-request and not
  286. at compile time.
  287. For example, avoid this:
  288. .. code-block:: python
  289. from oscar.apps.shipping import repository
  290. class Repository(repository.Repository)
  291. methods = [SomeMethod(), AnotherMethod()]
  292. Instead, instantiate the methods within ``get_shipping_methods``:
  293. .. code-block:: python
  294. from oscar.apps.shipping import repository
  295. class Repository(repository.Repository)
  296. # Note, methods are not instantiated
  297. methods = [SomeMethod, AnotherMethod]
  298. Beware of shipping methods that are configured via constructor parameters, like
  299. :class:`~oscar.apps.shipping.methods.FixedPrice`. Shipping methods will be
  300. reworked for Oscar 0.7.
  301. Basket model changes
  302. ~~~~~~~~~~~~~~~~~~~~~
  303. Several properties of the basket ``Line`` model have been renamed:
  304. * ``Line.line_price_excl_tax_and_discounts`` has been renamed to
  305. ``Line.line_price_excl_tax_incl_discounts``.
  306. * ``Line.line_price_incl_tax_and_discounts`` has been renamed to
  307. ``Line.line_price_incl_tax_incl_discounts``.
  308. Address model changes
  309. ~~~~~~~~~~~~~~~~~~~~~
  310. * The ``UserAddress.salutation`` and ``UserAddress.name`` methods are now
  311. properties.
  312. * The ``Country`` model's `is_highlighted` column is now an integer field to allow
  313. fine-grained country selection.
  314. Search app changes
  315. ~~~~~~~~~~~~~~~~~~
  316. Some of the names have been simplified.
  317. * The ``MultiFacetedSearchView`` and ``SuggestionsView`` view classes have been
  318. removed. The ``MultiFacetedSeachView`` class is replaced by ``FacetedSearchView``.
  319. * The ``MultiFacetedSearchForm`` has been removed in favour of
  320. ``SearchForm``.
  321. Range model changes
  322. ~~~~~~~~~~~~~~~~~~~
  323. ManyToManyField ``included_product`` of ``Range`` model was changed to use
  324. ``through`` relationship:
  325. * Use ``Range.add_product(product)`` instead of
  326. ``Range.included_product.add(product)``.
  327. * Use ``Range.remove_product(product)`` instead of
  328. ``Range.included_product.remove(product)``.
  329. When adding a product into a range, position in the range can be specified
  330. with ``display_order`` parameter:
  331. ``Range.add_product(product, display_order=3)``
  332. Renamed templates
  333. ~~~~~~~~~~~~~~~~~
  334. Some templates have been renamed for greater consistency. If you are overriding
  335. these templates, ensure you rename your corresponding project templates.
  336. Many of the profile templates have been reorganised:
  337. * ``customer/address_list.html`` is renamed to
  338. ``customer/address/address_list.html``
  339. * ``customer/address_form.html`` is renamed to
  340. ``customer/address/address_form.html``
  341. * ``customer/address_delete.html`` is renamed to
  342. ``customer/address/address_delete.html``
  343. * ``customer/email.html`` is renamed to
  344. ``customer/email/email_detail.html``
  345. * ``customer/email_list.html`` is renamed to
  346. ``customer/email/email_list.html``
  347. * ``customer/order.html`` is renamed to
  348. ``customer/order/order_detail.html``
  349. * ``customer/order_list.html`` is renamed to
  350. ``customer/order/order_list.html``
  351. * ``customer/profile.html`` is renamed to
  352. ``customer/profile/profile.html``
  353. * ``customer/profile_form.html`` is renamed to
  354. ``customer/profile/profile_form.html``
  355. * ``customer/change_password_form.html`` is renamed to
  356. ``customer/profile/change_password_form.html``
  357. * ``partials/nav_profile.html`` has been removed.
  358. Template block changes
  359. ~~~~~~~~~~~~~~~~~~~~~~
  360. * The template ``dashboard/orders/order_detail.html`` has been reorganised. The
  361. ``tab_transactions`` block has been renamed to ``payment_transactions``.
  362. * In ``checkout/checkout.html``, the ``checkout-nav`` block has been renamed
  363. ``checkout_nav``.
  364. Product model changes
  365. ~~~~~~~~~~~~~~~~~~~~~
  366. * The function ``add_category_from_breadcrumbs`` was not used and has been
  367. removed.
  368. Account templates
  369. ~~~~~~~~~~~~~~~~~
  370. The templates for the customer account section have been reworked so that the
  371. profile page is much simpler. Content is no longer loaded into tabs on a single
  372. page; instead, separate pages are used to each section.
  373. Additional apps
  374. ~~~~~~~~~~~~~~~
  375. Four new apps are required in your ``INSTALLED_APPS``:
  376. .. code-block:: python
  377. INSTALLED_APPS = (
  378. ...
  379. 'oscar.apps.wishlists',
  380. 'oscar.apps.dashboard.pages',
  381. 'oscar.apps.dashboard.partners',
  382. 'oscar.apps.dashboard.reviews',
  383. ...
  384. )
  385. If you are using the ``get_core_apps`` helper function, then these new apps
  386. will be added automatically. The new wishlists app contains database migrations,
  387. so you will need to run the ``migrate`` management command.
  388. Changes to Partner permissions
  389. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  390. The following permissions on the
  391. :class:`~oscar.apps.partner.abstract_models.AbstractPartner` model were not
  392. used in Oscar and have been removed to avoid confusion with the newly
  393. introduced permission-based dashboard:
  394. * ``can_edit_stock_records``
  395. * ``can_view_stock_records``
  396. * ``can_edit_product_range``
  397. * ``can_view_product_range``
  398. * ``can_edit_order_lines``
  399. * ``can_view_order_lines``
  400. The permission-based dashboard introduced a new permission:
  401. * ``dashboard_access``
  402. Upgrading notes
  403. ===============
  404. * Alternative product class templates now use ``slug`` field instead of
  405. ``name.lower()`` to determine their filename. If you have templates for
  406. specific product classes, please update your filenames accordingly
  407. Checkout app:
  408. * Checkout has a new option "Register and continue". Option value `new` in
  409. `GatewayForm` has changed to `guest` as `new` option is used for this feature.
  410. * Payment details - create_billing_address accepts kwargs so data can be passed
  411. to it from the final page of checkout.
  412. * The session methods for loading shipping addresses and methods have been made
  413. explicit. The relevant basket *has* to be passed in now.
  414. Payment app:
  415. * The `balance` method on the source object is now a property not a method.
  416. URLs
  417. ~~~~
  418. Migrations
  419. ~~~~~~~~~~
  420. There are rather a lot of new migrations in Oscar 0.6. They are all detailed
  421. below.
  422. If you are upgrading and your project overrides one of these apps with
  423. new migrations, then ensure you pick up the schema changes in a new migration
  424. within your app. You can generally do this using ``manage.py schemamigration
  425. $APP --auto`` but check the corresponding core migration to ensure there aren't
  426. any subtleties that are being overlooked.
  427. Some of these migrations rename fields for consistency, while others ensure
  428. ``CharField`` fields are not nullable.
  429. * Address:
  430. - ``0003``: A new field ``display_order`` is added to the ``Country``
  431. model. This is the first of 3 migrations that replace the
  432. boolean ``is_highlighted`` field with an integer field that allows
  433. fine-grained control of the order of countries in dropdowns.
  434. - ``0004``: A data migration to ensure highlighted countries have a display
  435. order of 1.
  436. - ``0005``: Remove the ``is_highlighted`` field from the ``Country`` model
  437. as it is no longer necessary.
  438. - ``0006``: Add a uniqueness constraint across ``user_id`` and ``hash`` for
  439. the ``UserAddress`` model to prevent duplicate addresses.
  440. - ``0007``: Use a custom field for address postcodes.
  441. * Basket:
  442. - ``0004``: Add ``stockrecord`` field to the ``Line`` model to track which
  443. stockrecord has been selected to fulfill a particular line.
  444. - ``0005``: Add ``price_currency`` field to the ``Line`` model.
  445. * Catalogue:
  446. - ``0011``: Larger ``max_length`` on FileFields and ImageFields
  447. - ``0012``: Use ``NullBooleanField`` for the ``value_boolean`` field of
  448. the ``ProductAttributeValue`` model.
  449. - ``0013``: Add ``value_file`` and ``value_image`` fields to the
  450. ``ProductAttributeValue`` model to support file and image attributes.
  451. * Customer:
  452. - ``0005``: Don't allow ``sms_template`` field of
  453. ``CommunicationEventType`` model to be nullable.
  454. * Dashboard:
  455. - ``0002``: Don't allow ``error_message`` field of
  456. ``RangeProductFileUpload`` model to be nullable.
  457. * Offer app:
  458. - ``0020``: Data migration to set null offer descriptions to empty string.
  459. - ``0021``: Don't allow null offer descriptions or benefit types.
  460. - ``0022``: Add a ``slug`` field to the :class:`~oscar.apps.offer.models.Range` model.
  461. - ``0023``: A data migration to populate the new range slug field.
  462. - ``0024``: Add a ``is_public`` field to the :class:`~oscar.apps.offer.models.Range` model.
  463. - ``0025``: Add a ``description`` field to the :class:`~oscar.apps.offer.models.Range` model.
  464. - ``0026``: Add a ``applies_to_tax_exclusive_price`` field to
  465. ``ConditionalOffer`` model to try and handle offers that apply in bothe
  466. the US and UK (this field is later removed).
  467. - ``0027``: Create a joining table for the new M2M relationship between
  468. ranges and products.
  469. - ``0028``: Remove ``applies_to_tax_exclusive_price`` field.
  470. * Order app:
  471. - ``0010``: Allow postcodes for shipping- and billing addresses to be
  472. nullable.
  473. - ``0011``: Rename ``date`` field on ``CommunicationEvent``,
  474. ``ShippingEvent`` and ``PaymentEvent`` models to be ``date_created``.
  475. - ``0012``: Add ``reference`` field to ``PaymentEvent`` model.
  476. - ``0013``: Add a foreign key to ``ShippingEvent`` from ``PaymentEvent``
  477. model.
  478. - ``0014``: Change ``postcode`` field on ``ShippingAddress`` and
  479. ``BillingAddress`` models to use ``UppercaseCharField`` field.
  480. - ``0015``: Remove ``is_required`` and ``sequence_number`` fields from
  481. ``ShippingEventType`` and ``PaymentEventType`` models.
  482. - ``0016``: Add ``currency`` field to ``Order model``. Add a foreign key
  483. to the ``StockRecord`` model from the ``Line`` model.
  484. - ``0017``: Add a ``shipping_code`` field to the ``Order`` model.
  485. - ``0018``: ``ShippingAddress``'s ``phone_number`` is now a ``PhoneNumberField``
  486. to allow better validation.
  487. * Partner app:
  488. - ``0008``: Remove unnecessary ``partner_abstractstockalert`` table.
  489. - ``0009``: Create table for new ``PartnerAddress`` model.
  490. - ``0010``: Remove uniqueness constraint on ``product_id`` for the
  491. ``StockRecord`` model. This allows a product to have more than one
  492. stockrecord.
  493. * Payment app:
  494. - ``0002``: Ensure all ``CharField`` fields are not nullable. This
  495. migration handles both the data- and schema-migration in one.
  496. * Promotions app:
  497. - ``0002``: Ensure all ``CharField`` fields are not nullable.
  498. - ``0003``: Extend the ``max_length`` of the ``image`` field.
  499. * Wishlist app:
  500. - ``0001``: Initial table creation
  501. Features deprecated in 0.6
  502. ==========================
  503. Accessing a product's stockrecords
  504. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  505. Several properties and methods of the core
  506. :class:`~oscar.apps.catalogue.abstract_models.AbstractProduct` class have been
  507. deprecated following the change to allow multiple stockrecords per product.
  508. * :attr:`~oscar.apps.catalogue.abstract_models.AbstractProduct.has_stockrecord`
  509. no longer makes sense when there can be more than one stockrecord. It is
  510. replaced by
  511. :attr:`~oscar.apps.catalogue.abstract_models.AbstractProduct.has_stockrecords`
  512. * :attr:`~oscar.apps.catalogue.abstract_models.AbstractProduct.stockrecord` is
  513. deprecated since it presumes there is only one stockrecord per product.
  514. Choosing the appropriate stockrecord is now the responsiblity of the
  515. :ref:`strategy class <strategy_class>`. A backward compatible version has
  516. been kept in place that selects the first stockrecord for a product. This
  517. will continue to work for sites that only have one stockrecord per product.
  518. All availability logic has been moved to :ref:`availability policies<availability_policies>`
  519. which are determined by the :ref:`strategy class <strategy_class>`.
  520. * :attr:`~oscar.apps.catalogue.abstract_models.AbstractProduct.is_available_to_buy`
  521. is deprecated. The functionality is now part of availability policies.
  522. * :meth:`~oscar.apps.catalogue.abstract_models.AbstractProduct.is_purchase_permitted`
  523. is deprecated. The functionality is now part of availability policies.
  524. Checkout session manager
  525. ~~~~~~~~~~~~~~~~~~~~~~~~
  526. The ``shipping_method`` method of the
  527. :class:`~oscar.apps.checkout.utils.CheckoutSessionData` is now deprecated in
  528. favour of using ``shipping_method_code``. It is being removed as the
  529. ``CheckoutSessionData`` class should only be responsible for retriving data
  530. from the session, not loading shipping method instances.
  531. Checkout order placement mixin
  532. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  533. The following methods within
  534. :class:`~oscar.apps.checkout.mixins.OrderPlacementMixin` are deprecated:
  535. * :meth:`~oscar.apps.checkout.mixins.OrderPlacementMixin.create_shipping_address_from_form_fields`
  536. * :meth:`~oscar.apps.checkout.mixins.OrderPlacementMixin.create_shipping_address_from_user_address`
  537. * :meth:`~oscar.apps.checkout.mixins.OrderPlacementMixin.create_user_address`
  538. "Partner wrappers"
  539. ~~~~~~~~~~~~~~~~~~
  540. Before Oscar 0.6, availability and pricing logic was encapsulated in "partner
  541. wrappers". A partner wrapper was a class that provided availability and price
  542. information for a particular partner, as specified by the
  543. ``OSCAR_PARTNER_WRAPPERS`` setting. The stockrecord model had several
  544. properties and methods
  545. which delegated to the appropriate wrapper for the record's partner.
  546. This functionailty is now deprecated in favour of using :ref:`strategy classes <strategy_class>`.
  547. How prices and taxes are determined is not generally a function of the partner,
  548. and so this system was not a good model. Strategy classes are much more
  549. flexible and allow better modelling of taxes and availability.
  550. The following attributes and methods from :class:`~oscar.apps.partner.abstract_models.StockRecord`
  551. are deprecated and will be removed for Oscar 0.7.
  552. * :attr:`AbstractStockRecord.is_available_to_buy <oscar.apps.partner.abstract_models.AbstractStockRecord.is_available_to_buy>`
  553. * :meth:`AbstractStockRecord.is_purchase_permitted <oscar.apps.partner.abstract_models.AbstractStockRecord.is_purchase_permitted>`
  554. * :attr:`AbstractStockRecord.availability_code <oscar.apps.partner.abstract_models.AbstractStockRecord.availability_code>`
  555. * :attr:`AbstractStockRecord.availability <oscar.apps.partner.abstract_models.AbstractStockRecord.availability>`
  556. * :attr:`AbstractStockRecord.max_purchase_quantity <oscar.apps.partner.abstract_models.AbstractStockRecord.max_purchase_quantity>`
  557. * :attr:`AbstractStockRecord.dispatch_date <oscar.apps.partner.abstract_models.AbstractStockRecord.dispatch_date>`
  558. * :attr:`AbstractStockRecord.lead_time <oscar.apps.partner.abstract_models.AbstractStockRecord.lead_time>`
  559. * :attr:`AbstractStockRecord.price_incl_tax <oscar.apps.partner.abstract_models.AbstractStockRecord.price_incl_tax>`
  560. * :attr:`AbstractStockRecord.price_tax <oscar.apps.partner.abstract_models.AbstractStockRecord.price_tax>`
  561. All the above properties and methods have effectively been moved to the availability and pricing
  562. policies that a strategy class is responsible for loading. To upgrade your
  563. codebase, replace your partner wrapper classes with equivalent
  564. :doc:`availability and pricing policies </topics/prices_and_availability>`.
  565. Basket
  566. ~~~~~~~
  567. Now that products can have multiple stockrecords, several changes have been made
  568. to baskets to allow the appropriate stockrecord to be tracked for each basket
  569. line. The basket line model has a new field that links to the selected
  570. stockrecord and the basket itself requires an instance of the strategy class so
  571. that prices can be calculated for each line. Hence, if you are manipulating
  572. baskets directly, you need to assign a strategy class in order for prices to
  573. calculate correctly:
  574. .. code-block:: python
  575. from oscar.apps.basket import models
  576. basket = models.Basket.objects.get(id=1)
  577. basket.strategy = request.strategy
  578. Without an assigned strategy class, a basket will raise a ``RuntimeError`` when
  579. attempting to calculate totals.
  580. The way a product is added to a basket has also been changed as a ``StockInfo``
  581. instance is also required.
  582. .. code-block:: python
  583. from oscar.apps.basket import models
  584. from oscar.apps.catalogue import models as product_models
  585. basket = models.Basket.objects.get(id=1)
  586. basket.strategy = request.strategy
  587. product = product_models.Product.objects.get(id=1)
  588. stockinfo = request.strategy.fetch(product)
  589. basket.
  590. Test support extension brought back into core
  591. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  592. The `Oscar test support library`_ has been ported back into Oscar core. This
  593. simplifies things and avoids circular dependency issues. If your project is
  594. using this extension, you should remove it as a dependency and use the
  595. analogous functionality from ``oscar/test/``.
  596. .. _`Oscar test support library`: https://github.com/tangentlabs/django-oscar-testsupport