Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. .. spelling::
  2. Sorl
  3. =======================
  4. Oscar 2.0 release notes
  5. =======================
  6. :release: 2019-07-04
  7. Welcome to Oscar 2.0. This is a significant release which includes a number of
  8. new features and backwards incompatible changes. In particular the way Oscar
  9. configures apps has been refactored and projects that have forked apps will
  10. need to follow the section on `Migrating forked apps`_.
  11. .. contents::
  12. :local:
  13. :depth: 1
  14. .. _compatibility_of_2.0:
  15. Compatibility
  16. -------------
  17. Oscar 2.0 is compatible with Django 1.11, Django 2.1 and Django 2.2
  18. as well as Python 3.5, 3.6 and 3.7.
  19. Support for Python 2.7 and Python 3.4 has been dropped.
  20. .. _new_in_2.0:
  21. What's new in Oscar 2.0?
  22. ------------------------
  23. - Added an ``is_public`` field to the ``Product`` model that is used to exclude
  24. products from the ``browsable`` queryset. A ``browsable_dashboard`` queryset
  25. is provided for use in the dashboard, which includes non-public products. This
  26. is a model change, so you will need to run the supplied migrations.
  27. - Added an ``order.OrderStatusChange`` model that is used to log order status
  28. changes applied by ``Order.set_status()``. This is a new model, so you will
  29. need to run the supplied migrations.
  30. - Added an ``OSCAR_OFFERS_INCL_TAX`` setting which can be used to configure
  31. whether offer discounts are applied on the tax-inclusive amount. This
  32. defaults to ``False``, to preserve the original behaviour of discount
  33. application.
  34. - Added database index definitions for commonly queried fields in a range of
  35. models. See `#2875`_. This will require projects that have forked Oscar apps
  36. to generate corresponding migrations.
  37. - Added a ``filter_by_attributes`` method on the ``ProductQuerySet``, to allow
  38. database-level filtering of products by attribute.
  39. - Added support for re-ordering product images in the dashboard, and for adding
  40. an arbitrary number of additional images into the formset.
  41. - Added an ``OSCAR_THUMBNAILER`` setting can be used to customise thumbnail
  42. generation. Support is included for Sorl and Easy Thumbnails. The default is
  43. ``'oscar.core.thumbnails.SorlThumbnail'``.
  44. - Added ``oscar_thumbnail`` template tag (to ``image_tags``) to generate
  45. thumbnails in templates. All uses of Sorl's ``thumbnail`` template tag in
  46. the shipped templates have been replaced with ``oscar_thumbnail``.
  47. - ``sorl-thumbnail`` has been dropped as a dependency. Use
  48. ``pip install django-oscar[sorl-thumbnail]`` or
  49. ``pip install django-oscar[easy-thumbnails]`` to explicitly install the
  50. dependencies for either of the two supported thumbnailers.
  51. - Added the ability to manage ``catalogue.Option`` objects from the dashboard.
  52. .. _`#2875`: https://github.com/django-oscar/django-oscar/pull/2875
  53. Removal of deprecated features
  54. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  55. - Product alert emails are now sent as Communication Events and the deprecated
  56. product alert email templates have been removed. The templates for these
  57. emails have been replaced as follows:
  58. - ``customer/alerts/emails/confirmation_subject.txt`` to
  59. ``customer/emails/commtype_product_alert_confirmation_subject.txt``
  60. - ``customer/alerts/emails/confirmation_body.txt`` to
  61. ``customer/emails/commtype_product_alert_confirmation_body.txt``
  62. - ``customer/alerts/emails/alert_subject.txt`` to
  63. ``customer/emails/commtype_product_alert_subject.txt``
  64. - ``customer/alerts/emails/alert_body.txt`` to
  65. ``customer/emails/commtype_product_alert_body.txt``
  66. - Support for category URLs without a primary key has been removed.
  67. Enforcement of unique slugs for categories has also been removed, as enforcing
  68. this was inefficient and not thread safe. Since a primary key is now required
  69. for category URLs, there is no need for slugs to be unique.
  70. - ``customer.forms.SetPasswordForm`` and ``customer.forms.PasswordChangeForm``
  71. have been removed. Use ``django.contrib.auth.forms.SetPasswordForm`` and
  72. ``django.contrib.auth.forms.PasswordChangeForm`` instead.
  73. - The ``views.decorators.staff_member_required`` decorator has been removed. Use
  74. ``permissions_required(['is_staff']`` instead.
  75. - The ``UserAddress.num_orders`` property has been removed. Use
  76. ``num_orders_as_shipping_address`` and ``num_orders_as_billing_address``
  77. instead.
  78. - Support has been removed for the dynamic loading of formset classes that were
  79. moved in previous releases. Projects must update their ``get_class`` calls to
  80. use the new paths. The paths that have changed are as follows:
  81. ================================ ================================== ================
  82. Old path New path Affected classes
  83. ================================ ================================== ================
  84. ``basket.forms`` ``basket.formsets`` ``BaseBasketLineFormSet``
  85. ``BasketLineFormSet``
  86. ``BaseSavedLineFormSet``
  87. ``SavedLineFormSet``
  88. ``dashboard.catalogue.forms`` ``dashboard.catalogue.formsets`` ``BaseStockRecordFormSet``
  89. ``StockRecordFormSet``
  90. ``BaseProductCategoryFormSet``
  91. ``ProductCategoryFormSet``
  92. ``BaseProductImageFormSet``
  93. ``ProductImageFormSet``
  94. ``BaseProductRecommendationFormSet``
  95. ``ProductRecommendationFormSet``
  96. ``ProductAttributesFormSet``
  97. ``wishlists.forms`` ``wishlists.formsets`` ``LineFormset``
  98. ================================ ================================== ================
  99. Minor changes
  100. ~~~~~~~~~~~~~
  101. - Dropped ``action=""`` and ``action="."`` attributes, following the lead of
  102. Django and as per the HTML5 specification.
  103. - Replaced use of Django's procedural authentication views with the corresponding
  104. class-based views.
  105. - ``OrderPlacementMixin.get_message_context()`` is now passed a ``code``
  106. argument specifying the communication event type code for the message being
  107. sent.
  108. - We've dropped the dependency on `Unidecode <https://pypi.org/project/Unidecode/>`_ due to license incompatibilities,
  109. ``oscar.core.utils.default_slugifier`` now uses
  110. ``oscar.core.utils.cautious_slugify`` to handle Unicode characters in slugs
  111. when ``OSCAR_SLUG_ALLOW_UNICODE`` is ``False``.
  112. - Fixed input validation for ``dashboard.offers.forms.BenefitForm`` when a
  113. ``range`` was specified but other fields were empty.
  114. - Fixed calculation of weight-based shipping charges in cases where the basket
  115. weight is an exact multiple of a weight band's upper limit.
  116. - The ``sort_by`` field on ``catalogue.reviews.SortReviewsForm`` was made
  117. optional and the logic in ``ProductReviewList`` adjusted so that the form
  118. fields don't have to be rendered manually because of form errors.
  119. - Added a ``datetime_filters`` tag library that provides a ``timedelta``
  120. template filter for rendering time deltas in human readable format.
  121. - ``OSCAR_OFFER_ROUNDING_FUNCTION`` previously accepted a function as its
  122. value. It now only accepts a dotted path to a function as its value
  123. - Fixed the logic of ``offers.Range.all_products()`` to make it consistent with
  124. ``Range.contains_product()`` in excluding products specified in
  125. ``excluded_product_ids``.
  126. - Added a ``COMPARISON_FIELDS`` constant to ``catalogue.Category`` to restrict
  127. which fields are fetched from the database when performing category
  128. comparison queries.
  129. - Significantly improved the database efficiency of the ``category_tree``
  130. template tag.
  131. - Order confirmation emails now include an order status link for authenticated
  132. users, as well as guest users, and order status is displayed consistently in
  133. both logged-in and anonymous order detail views.
  134. - Fixed display of styled HTML emails in account email detail views, wrapping
  135. them in an iframe to avoid leakage of styles into the page.
  136. - Bootstrap datetime picker JS/CSS assets removed from base layout, see
  137. :issue:`2584`.
  138. - Oscar's 500 error template no longer inherits other templates and does not
  139. use any template template tags and styling to avoid potential errors caused
  140. by the template itself (see :issue:`2971`).
  141. - Line discounts are now capped to a minimum of zero - i.e., negative discounts
  142. will not be reported.
  143. .. _incompatible_in_2.0:
  144. Backwards incompatible changes in Oscar 2.0
  145. -------------------------------------------
  146. - Redirection to the parent detail view for child products is disabled by
  147. default. Child products now have their own detail view, which allows
  148. displaying their price and images independently from the parent product. To
  149. revert to the previous behaviour of redirecting to the parent product, set
  150. ``oscar.apps.catalogue.views.ProductDetailView.enforce_parent`` to ``False``.
  151. - Renamed the modules containing the Django app config classes for Oscar apps
  152. (apart from the ``oscar`` app), from ``config`` to ``apps``.
  153. - Removed the ``app`` modules of Oscar apps, moving the configuration (related to
  154. permissions, URLconfs, and feature hiding) they contained into the apps'
  155. Django app config classes. They include the following attributes: ``name``
  156. (since renamed ``namespace``), ``login_url``, ``hidable_feature_name``,
  157. ``permissions_map``, and ``default_permissions``; methods:
  158. :meth:``get_urls``, :meth:``post_process_urls``, :meth:``get_permissions``,
  159. :meth:``get_url_decorator``, and :meth:``urls``; and their respective view
  160. classes. The composite config classes for normal Oscar apps are subclasses of
  161. ``oscar.core.application.OscarConfig`` (previously
  162. ``oscar.core.application.Application``), and for Oscar Dashboard apps
  163. ``oscar.core.application.OscarDashboardConfig`` (previously
  164. ``oscar.core.application.DashboardApplication``).
  165. - Removed the ``application`` variable, which previously held an Oscar app
  166. config instance, from the Oscar app config module. A single Django/Oscar app
  167. config instance is now registered in the Django app registry, for each app
  168. label. It should be obtained by looking it up in the Django app registry.
  169. - Changed the values returned by the Oscar app config ``urls`` property. It now
  170. returns a tuple containing the list of URL patterns, the app namespace (which
  171. could previously be None, but not any more), and the instance namespace
  172. (which would previously be overridden by the app namespace, if left blank, but
  173. must now be explicitly set). To include URLs with an instance namespace, use
  174. the form ``app_config.urls``, and to include URLs without an instance
  175. namespace, use the form ``django.conf.urls.include(app_config.urls[0])``.
  176. - Removed ``oscar.get_core_apps``. Overriding apps is now done by
  177. replacing the Oscar app entry in the ``INSTALLED_APPS`` setting with that of
  178. the forked app.
  179. - Changed the calling signature for the ``oscar_fork_app`` management command.
  180. The ``app_label`` argument is the Django app label of the app to be forked.
  181. ``target_path`` is the directory into which the new app shall be copied.
  182. ``new_app_subpackage`` is the optional dotted path to the package of the
  183. new app, from which, together with the ``target_path``, the full Python path
  184. to the app will be derived. If ``new_app_subpackage`` is omitted, then the
  185. package of the app being forked will be used instead.
  186. - Removed the ``promotions`` app. The app is now available in a separate package
  187. - `django_oscar_promotions`_.
  188. - ``OSCAR_MAIN_TEMPLATE_DIR`` setting has been removed and existing templates
  189. updated with the full path. See :issue:`1378`, :issue:`2250`. Please update
  190. your templates accordingly.
  191. - ``OSCAR_SLUG_FUNCTION`` previously accepted a function as its value. It now
  192. only accepts a dotted path to a function as its value. Such functions must
  193. also now take a ``allow_unicode`` kwarg.
  194. .. _`django_oscar_promotions`: https://github.com/django-oscar/django-oscar-promotions
  195. .. _migrating_forked_apps:
  196. Migrating forked apps
  197. ~~~~~~~~~~~~~~~~~~~~~
  198. In release 2.0 the way apps are configured has been substantially refactored to
  199. merge Oscar's ``Application`` class with Django's ``AppConfig`` class. For
  200. each app that you have forked, you will need to:
  201. - Rename the ``config.py`` module to ``apps.py``.
  202. - Change the ``default_app_config`` variable in ``__.init__.py`` to point
  203. to ``apps`` instead of ``config``.
  204. - Update your ``AppConfig`` subclass in the ``apps.py`` module to either
  205. inherit from the parent app's ``AppConfig`` or use either
  206. ``oscar.core.application.OscarConfig`` or
  207. ``oscar.core.application.OscarDashboardConfig``.
  208. - Move any changes you've made to the Oscar ``Application`` subclass in the ``app.py``
  209. module, to the ``AppConfig`` subclass in the ``apps.py`` module. When moving
  210. the ``name`` attribute over, rename it to ``namespace``. Your merged app
  211. config class should end up having a ``namespace`` (for declaring the URL
  212. application namespace) as well as ``name`` (for configuring the
  213. ``django.apps.config.AppConfig.name``) attribute.
  214. - In your project URLconf and in `get_urls` methods replace the ``application``
  215. import by finding the app in the Django app registry.
  216. .. code-block:: python
  217. from django.apps import apps
  218. application = apps.get_app_config('your_app_name')
  219. - If the urls you're including don't define an instance namespace then use
  220. ``include(application.urls[0])``, which only passes in the list of URL
  221. patterns.
  222. .. note::
  223. Because of the way dynamic class loading now works, when forking dashboard
  224. apps, the ``oscar.apps.dashboard`` app also needs to be forked; and the
  225. forked dashboard app's code must live inside the forked
  226. ``oscar.apps.dashboard`` app's directory.
  227. Similarly, when forking ``oscar.apps.catalogue.reviews``,
  228. ``oscar.apps.catalogue`` needs to be forked as well; and the forked
  229. ``oscar.apps.catalogue.reviews`` app's code must live inside the forked
  230. ``oscar.apps.catalogue`` app's directory.
  231. Dependency changes
  232. ------------------
  233. - Dropped ``mock`` as a dependency in favour of ``unittests.mock``.
  234. - Upgraded ``bootstrap`` to version 3.4.1.
  235. - Upgraded ``jquery`` to 3.4.1.
  236. - Dropped ``jquery.inputmask`` in favour of ``inputmask`` and upgraded to 4.0.2.
  237. - Upgraded ``less`` to 3.8.1.
  238. - Upgraded ``tinymce`` to version 4.8.3.
  239. .. _deprecated_features_in_2.0:
  240. Deprecated features
  241. -------------------
  242. - ``offer.Range.contains()`` is deprecated. Use ``contains_product()`` instead.
  243. - ``catalogue.managers.ProductManager`` is deprecated. Use
  244. ``catalogue.managers.ProductQuerySet.as_manager()`` instead.
  245. - ``catalogue.managers.BrowsableProductManager`` is deprecated. Use
  246. ``Product.objects.browsable()`` instead.
  247. - ``catalogue.Product.browsable`` is deprecated. Use
  248. ``Product.objects.browsable()`` instead.