Skip to content

Commit

Permalink
Add documentation for skip conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
maiksprenger committed Jun 2, 2014
1 parent f086672 commit db62806
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
10 changes: 9 additions & 1 deletion docs/source/releases/v0.8.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ known.

See :ref:`us_site` for more information.

Checkout improvements
---------------------

The checkout process now skips payment if the order total is zero (e.g. when
ordering free products or using a voucher). As part of that, checkout views
now evaluate *pre-conditions* (as before) and newly introduced
*skip conditions*. This should make customising the checkout flow easier.

Cleanup around shipping methods
-------------------------------

Expand Down Expand Up @@ -129,7 +137,7 @@ Backwards incompatible changes in 0.8
``Product.recommended_products`` to model products that are loosely related
(e.g. used for upselling). ``Product.related_products`` was a
third option that sat somewhere in between, and which was not well supported.
We fear it adds confusion, and in the spirit of keeping Oscare core lean,
We fear it adds confusion, and in the spirit of keeping Oscar core lean,
has been removed. If you're using it, switch to
``Product.recommended_products`` or just add the field back to your
custom Product instance and ``ProductForm`` when migrating.
Expand Down
21 changes: 15 additions & 6 deletions oscar/apps/checkout/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,23 @@ class CheckoutSessionMixin(object):
All checkout views subclass this mixin. It ensures that all relevant
checkout information is available in the template context.
"""
# This should be list of method names that get executed before the normal
# flow of the view. Each method should check some condition has been met.
# If not, then an exception is raised that indicates the URL the customer
# should be redirect to.

# A pre-condition is a condition that MUST be met in order for a view
# to be available. If it isn't then the customer should be redirected
# to a view *earlier* in the chain.
# pre_conditions is a list of method names that get executed before the
# normal flow of the view. Each method should check some condition has been
# met. If not, then an exception is raised that indicates the URL the
# customer will be redirected to.

pre_conditions = None

# Skip conditions check whether the view should be skipped. They work in
# the same way as pre-conditions.
# A *skip* condition is a condition that MUST NOT be met in order for a
# view to be available. If the condition is met, this means the view MUST
# be skipped and the customer should be redirected to a view *later* in
# the chain.
# Skip conditions work similar to pre-conditions, and get evaluated after
# pre-conditions have been evaluated.
skip_conditions = None

def dispatch(self, request, *args, **kwargs):
Expand Down

0 comments on commit db62806

Please sign in to comment.