Plata 1.1 release notes

Welcome to Plata 1.1!

Backwards-incompatible changes

Order status addition

The order status “confirmed” was confusingly named; what it really meant all the time is that the order can be considered paid. Whether an order is confirmed or not depends on the shop owner’s definitions.

Because of this the existing Order.CONFIRMED status has been renamed to Order.PAID, Order.CONFIRMED has been added as a new order status coming after Order.PAID. Plata only knows about Order.PAID and never changes an order to COMPLETED itself.

To update your installations to Plata v1.1, you’ll have to make the following changes:

  • The method order.is_completed() has been removed. Either check for not order.balance_remaining (which only looks at the balance, not at the order status) or check for order.status >= order.PAID yourself. For consistency, the method order.is_confirmed() has been removed too.
  • order.is_paid() has been deprecated and will be removed in the next release. Use order.status >= order.PAID or not order.balance_remaining directly to clearly communicate your intentions instead.
  • The shop signal order_completed has been renamed to order_paid. Signal handlers receive the same arguments as before.
  • The email template used in the SendInvoiceHandler has been renamed to order_paid.txt.
  • If you wrote your own payment modules, the method you’ll want to call at the end is now named order_paid, not order_completed anymore. Apart from the renaming the signature of the function has not changed.

Stock tracking

  • The stock transaction app has been converted to south too now. The initial migration should be applied with --fake if you are already using stock tracking:

    ./manage.py migrate stock 0001 --fake
    
  • Stock transactions have been made more useful on their own; if possible, the name, sku and line item price fields are filled in automatically. The south schemamigration for adding all additional fields is provided.

  • Previously, stock transactions of type PAYMENT_PROCESS_RESERVATION influenced the items_in_stock field on products even after the reservation period was over. This happened because the stock is not automatically recalculated when 15 minutes have passed. Plata is smarter now and only takes the payment process reservation stock transactions into account when validating the order (respectively the cart) during the checkout process. A few stock transaction manager methods have been removed during the refactoring because their functionality does not match Plata’s own behavior anymore:

    • StockTransaction.objects.stock()
    • StockTransaction.objects.expired()
    • StockTransaction.objects._expired() (this method was meant for internal use only anyway)

    If you need their functionality, you should have a closer look at StockTransaction.objects.items_in_stock first (especially the new argument, include_reservations).

Language-aware orders

The order model has a new field language_code. When the order is created in shop.order_from_request(request, create=True) this field is filled with the current language for your convenience. The PDF generation code and the e-mail notification handlers automatically activate the language set on the order; if you provide your own signal handlers and/or PDF generation methods, you have to do this yourself.

The south schemamigration for this change is provided.

Order validation

  • The checkout process decorator plata.shop.views.order_confirmed() has been renamed to plata.shop.views.order_already_confirmed() to communicate more clearly what it is all about. You don’t have to change anything except if you customized get_shop_urls().
  • The unused order validation group VALIDATE_CHECKOUT has been removed.
  • The validator group VALIDATE_CART is run at the cart level too, but validation errors are shown as warnings instead.

Notable features

  • Ogone is now a supported payment service provider (PSP).
  • Users with a login are not asked whether they want to create a contact, this is done automatically. The checkout form is initialized with the values form the user model, too.
  • If URLs named 'order_packing_slip_pdf' and 'order_invoice_pdf' are reversible using only a keyword argument order_id (which only consists of a number, it is the primary key of the order model), a column with PDF links is automatically added to the orders list in the Django admin panel.
  • The main Shop object gained an additional argument, base_template, which can be used to specify a different base template than base.html which should be used in all checkout-related templates.
  • Payment-related information is handled in its own method inside OrderReport now, meaning that it is easier to override aspects of it in your shop.
  • All rendering is done through a new method on the main shop view, render(self, request, context)(), making it straightforward to customize the rendering for all steps.
  • The order payment failure view now actually does what the template advertizes since its inception: The order is made editable again if no authorized order payments exist already.

Bugfixes

  • Order.status cannot be edited directly through the admin interface anymore. Add a new order status model if you need to manually change the order status.
  • The PDF generation code actually checks whether an order is paid for now. Previously, it only checked whether a method named is_paid() existed on the order (which was always the case).