Views¶
-
class
plata.shop.views.Shop(contact_model, order_model, discount_model, default_currency=None, **kwargs)[source] Plata’s view and shop processing logic is contained inside this class.
Shop needs a few model classes with relations between them:
- Contact model linking to Django’s auth.user
- Order model with order items and an applied discount model
- Discount model
- Default currency for the shop (if you do not override default_currency in your own Shop subclass)
Example:
shop_instance = Shop(Contact, Order, Discount) urlpatterns = [ url(r'^shop/', include(shop_instance.urls)), ]
-
base_template= u'base.html' The base template used in all default checkout templates
-
cart(request, order)[source] Shopping cart view
-
checkout(request, order)[source] Handles the first step of the checkout process
-
checkout_form(request, order)[source] Returns the address form used in the first checkout step
-
confirmation(request, order)[source] Handles the order confirmation and payment module selection checkout step
Hands off processing to the selected payment module if confirmation was successful.
-
confirmation_form(request, order)[source] Returns the confirmation and payment module selection form
-
contact_from_user(user)[source] Return the contact object bound to the current user if the user is authenticated. Returns
Noneif no contact exists.
-
create_order_for_user(user, request=None)[source] Creates and returns a new order for the given user.
-
default_currency(request=None)[source] Return the default currency for instantiating new orders
Override this with your own implementation if you have a multi-currency shop with auto-detection of currencies.
-
discounts(request, order)[source] Handles the discount code entry page
-
discounts_form(request, order)[source] Returns the discount form
-
get_context(request, context, **kwargs)[source] Helper method returning a context dict. Override this if you need additional context variables.
-
get_payment_modules(request=None)[source] Import and return all payment modules defined in
PLATA_PAYMENT_MODULESIf request is given only applicable modules are loaded.
-
order_from_request(request, create=False)[source] Instantiate the order instance for the current session. Optionally creates a new order instance if
create=True.Returns
Noneif unable to find an offer.
-
order_new(request)[source] Forcibly create a new order and redirect user either to the frontpage or to the URL passed as
nextGET parameter
-
order_payment_failure(request)[source] Handles order payment failures
-
order_payment_pending(request)[source] Handles order successes for invoice payments where payment is still pending.
-
order_success(request)[source] Handles order successes (e.g. when an order has been successfully paid for)
-
price_includes_tax(request=None)[source] Return if the shop should show prices including tax
This returns the PLATA_PRICE_INCLUDES_TAX settings by default and is meant to be overridden by subclassing the Shop.
-
redirect(url_name, *args, **kwargs)[source] Hook for customizing the redirect function when used as application content
-
render(request, template, context)[source] Helper which just passes everything on to
django.shortcuts.render
-
render_cart(request, context)[source] Renders the shopping cart
-
render_cart_empty(request, context)[source] Renders a cart-is-empty page
-
render_checkout(request, context)[source] Renders the checkout page
-
render_confirmation(request, context)[source] Renders the confirmation page
-
render_discounts(request, context)[source] Renders the discount code entry page
-
reverse_url(url_name, *args, **kwargs)[source] Hook for customizing the reverse function
-
set_order_on_request(request, order)[source] Helper method encapsulating the process of setting the current order in the session. Pass
Noneif you want to remove any defined order from the session.
-
urls Property offering access to the Shop-managed URL patterns
-
user_is_authenticated(user)[source] Overwrite this for custom authentication check. This is needed to support lazysignup
-
plata.shop.views.cart_not_empty(order, shop, request, **kwargs)[source] Redirect to cart if later in checkout process and cart empty
-
plata.shop.views.checkout_process_decorator(*checks)[source] Calls all passed checkout process decorators in turn:
@checkout_process_decorator(order_already_confirmed, order_cart_validates)
All checkout process decorators are called with the order, the shop instance and the request as keyword arguments. In the future, additional keywords might be added, your decorators should accept
**kwargsas well for future compatibility.
-
plata.shop.views.order_already_confirmed(order, shop, request, **kwargs)[source] Redirect to confirmation or already paid view if the order is already confirmed
-
plata.shop.views.order_cart_validates(order, shop, request, **kwargs)[source] Redirect to cart if stock is insufficient and display an error message
-
plata.shop.views.order_cart_warnings(order, shop, request, **kwargs)[source] Show warnings in cart, but don’t redirect (meant as a replacement for
order_cart_validates, but usable on the cart view itself)
-
plata.shop.views.user_is_authenticated(order, shop, request, **kwargs)[source] ensure the user is authenticated and redirect to checkout if not