Oscar 2.1 release notes¶
- release:
2020-07-10
Welcome to Oscar 2.1! This is a significant release which includes a number of new features and performance improvements.
Compatibility¶
Oscar 2.1 is compatible with Django versions 2.2 and 3.0, and Python versions 3.5, 3.6, 3.7 and 3.8.
Support for Django versions 1.11 and 2.0 has been dropped.
What’s new in Oscar 2.1?¶
The ability to add arbitrary surcharges to orders (e.g., a processing fee for a particular payment method) was introduced. See How to configure surcharges for details on how to configure this. This change requires a database migration.
The database performance of
offer.Range.all_products()was substantially improved. The internals of that method have changed and specificallyRange.invalidate_cached_ids()has been removed and replaced withRange.invalidate_cached_queryset().The
upload_toargument of image fields in Oscar’sProductImageandProductAttributeValuemodels was changed to use a callable, so that Django doesn’t generate migrations if a project modifies theOSCAR_IMAGE_FOLDERto specify a custom directory structure for uploaded images. This change requires a database migration.catalogue.Categorynow has anis_publicboolean field that serves a similar purpose tocatalogue.Product.is_public- i.e., to hide categories public views. TheCategorymodel also now has a custom manager that provides abrowsable()queryset method that excludes non-public categories. This change requires a database migration.Category hierarchy implies that the children of any non-public category are also non-public. This is enforced through an
ancestors_are_publicfield on theCategorymodel.A
date_updatedfield was added to thebasket.Linemodel, which is updated every time a line is saved. This change requires a database migration.
Communications app¶
A new communication app was introduced to provide a single point of entry
for all communications sent by Oscar. This is a significant change with implications
as follows:
Projects will need to add
oscar.apps.communication.apps.CommunicationConfigtoINSTALLED_APPS.The
CommunicationEventType,EmailandNotificationmodels have moved from thecustomerapp to thecommunicationapp. In order to preserve existing data, the table names for these models are unchanged.This change requires a database migration.
The
Dispatcherclass moved fromcustomer.utilstocommunication.utils.Dispatcheris now responsible for sending all notifications, and not just emails.A
CustomerDispatcherutility class that wraps the coreDispatcherhas been introduced to thecustomerapp for sending communications to customers.An
AlertsDispatcherutility class that wraps the coreDispatcherhas been introduced to thecustomer.alertsmodule for sending product alerts.An
OrderDispatcherutility class that wraps the coreDispatcherhas been introduced to theorderapp for sending order related communications.A new setting,
OSCAR_SAVE_SENT_EMAILS_TO_DBcontrols whether emails sent through theDispatcherare saved to the database. This defaults toTrue.The ability to send multipart emails with attachments was added to the new dispatcher.
All communication email templates (
commtype_*) have moved from moved fromcustomer/emailstocommunication/emails.Templates in
customer/email/andcustomer/notification/have moved tocommunication/email/andcommunication/notification/.An
absolute_urltemplate tag was introduced to facilitate generating absolute URLs in templates for a given domain and path. The schema for generated URLs is configured via theOSCAR_URL_SCHEMAsetting, which defaults tohttp.
Backwards incompatible changes in Oscar 2.1¶
The
categoryfield has been removed from thecommunication.Notificationmodel. This change requires database migration.The
checkout.mixins.OrderPlacementMixin.send_confirmation_messagemethod has been replaced with a newsend_order_placed_emailmethod.customer.notifications.context_processors.notificationshas moved tocommunication.notifications.context_processors.notifications.
Bug fixes¶
Fixed a bug in the handling of requests to save an item in the basket for later(#3215).
Fixed an error when deleting an offer whose related conditions/benefits have been deleted.
Fixed handling of count conditions in
MultibuyDiscountBenefit. Previously, when a count condition was used with this benefit it would result in a discount being applied for all items in the basket rather than the cheapest one.Fixed a bug where a line could not be deleted from the basket, if the basket had another line with a validation error - i.e. its product was out of stock (see #2791 and #1654).
Fixed a bug where non-public child products were not excluded from parent product forms and detail views.
Removal of deprecated features¶
Support for verifying order hashes using an insecure MD5 algorithm generated by Oscar 1.5 and below has been dropped. The
OSCAR_DEPRECATED_ORDER_VERIFY_KEYsetting is no longer used. Order verification hashes generated by Oscar 1.5 and lower will no longer validate.offer.Range.contains()has been removed. Usecontains_product()instead.catalogue.managers.ProductManagerhas been removed. Usecatalogue.managers.ProductQuerySet.as_manager()instead.catalogue.managers.BrowsableProductManagerhas been removed. UseProduct.objects.browsable()instead.catalogue.Product.browsablehas been removed. UseProduct.objects.browsable()instead.Invalid URLs supplied to
OSCAR_DASHBOARD_NAVIGATIONare no longer ignored. URLs that cannot be resolved will now result in aNoReverseMatchexception. URLs that are not provided by a subclass ofoscar.core.application.OscarDashboardConfigwill result in aKeyError.customer.forms.PasswordResetForm.get_reset_urlhas been removed.The internal and undocumented class
oscar.core.compat.UnicodeCSVReaderhas been removed. Usecsv.readerinstead.
Minor changes¶
OrderPlacementMixin.place_ordernow ignores inactive vouchers when placing an order (instead of raising an exception), for consistency with how the basket flows handle inactive vouchers.Fixed the logic of
StockRequired.parent_availability_policyto use child products to determine availability of children, rather than the parent.customer.forms.PasswordResetFormnow uses the parent class’get_users()method to determine the list of users to send an email to.get_users()filters out users who do not currently have a usable password - which did not happen previously.This change was made in response to changes in Django to address CVE-2019-19844. Oscar’s
PasswordResetFormwas not vulnerable to the issue in Django’s form, but it was possible to send a password reset email to unintended recipients because of unicode character collision.catalogue.Product.is_publicis now an indexed field. This change requires a database migration.When a voucher that was created through the Oscar dashboard is deleted, the auto-generated offer that was created with the voucher is also deleted.
Fixed the
brand_titleblock inpartials/brand.htmlso that it doesn’t span unclosed HTML tags.customer.views.ProfileUpdateView.form_validwas modified to use a newsend_email_changed_emailmethod.customer.views.ChangePasswordView.form_validwas modified to use a newsend_password_changed_emailmethod.A
publicmethod was added to theProductQuerySet, which filters on products withis_public=True.
Dependency changes¶
Python package dependencies:
Upgraded
pillowto version 6.0.0 or higher.Upgraded
django-extra-viewsto version 0.13.Upgraded
django-haystackto version 3.0 or higher.Upgraded
django-phonenumber-fieldto version 3.0.Upgraded
django-tables2to version 2.2.Upgraded
sorl-thumbnail(optional requirement) to version 12.6.Upgraded
easy-thumbnails(optional requirement) to version 2.7.
Javascript dependencies:
Upgraded
jqueryto version 3.5.Upgraded
inputmaskto version 5.0.Upgraded
select2to version 4.0.Upgraded
tinymceto version 5.3.
Deprecated features¶
customer.alerts.utils.send_alertsis deprecated. UseAlertsDispatcher.send_alertsinstead.customer.alerts.utils.send_alert_confirmationis deprecated. UseAlertsDispatcher.send_product_alert_confirmation_email_for_userinstead.customer.alerts.utils.send_product_alertsis deprecated. UseAlertsDispatcher.send_product_alert_email_for_userinstead.customer.notifications.services.notify_useris deprecated. Use Dispatcher.notify_user``.customer.notifications.services.notify_usersis deprecated. UseDispatcher.notify_usersinstead.