sideshow.web.views.orders

Views for Orders

class sideshow.web.views.orders.OrderItemView(request, context=None)[source]

Master view for OrderItem; route prefix is order_items.

Notable URLs provided by this class:

  • /order-items/

  • /order-items/XXX

Note that this does not expose create, edit or delete. The user must perform various other workflow actions to modify the item.

model_class

alias of OrderItem

class sideshow.web.views.orders.OrderView(request, context=None)[source]

Master view for Order; route prefix is orders.

Notable URLs provided by this class:

  • /orders/

  • /orders/new

  • /orders/XXX

  • /orders/XXX/delete

Note that the “edit” view is not exposed here; user must perform various other workflow actions to modify the order.

batch_handler

Reference to the new order batch handler, as returned by get_batch_handler(). This gets set in the constructor.

add_item(batch, data)[source]

This adds a row to the user’s current new order batch.

This is a “batch action” method which may be called from create(). See also:

assign_customer(batch, data)[source]

Assign the true customer account for a batch.

This calls set_customer() for the heavy lifting.

This is a “batch action” method which may be called from create(). See also:

cancel_order(batch)[source]

This will delete the user’s current batch, then redirect user back to “List Orders” page.

This is a “batch action” method which may be called from create(). See also:

create()[source]

Instead of the typical “create” view, this displays a “wizard” of sorts.

Under the hood a NewOrderBatch is automatically created for the user when they first visit this page. They can select a customer, add items etc.

When user is finished assembling the order (i.e. populating the batch), they submit it. This of course executes the batch, which in turn creates a true Order, and user is redirected to the “view order” page.

See also these methods which may be called from this one, based on user actions:

customer_autocomplete()[source]

AJAX view for customer autocomplete, when entering new order.

This invokes one of the following on the batch_handler:

Returns:

List of search results; each should be a dict with value and label keys.

classmethod defaults(config)[source]

Provide default Pyramid configuration for a master view.

This is generally called from within the module’s includeme() function, e.g.:

from wuttaweb.views import MasterView

class WidgetView(MasterView):
    model_name = 'Widget'

def includeme(config):
    WidgetView.defaults(config)
Parameters:

config – Reference to the app’s pyramid.config.Configurator instance.

delete_item(batch, data)[source]

This deletes a row from the user’s current new order batch.

This is a “batch action” method which may be called from create(). See also:

get_batch_handler()[source]

Returns the configured handler for new order batches.

You normally would not need to call this, and can use batch_handler instead.

Returns:

NewOrderBatchHandler instance.

get_current_batch()[source]

Returns the current batch for the current user.

This looks for a new order batch which was created by the user, but not yet executed. If none is found, a new batch is created.

Returns:

NewOrderBatch instance

get_product_info(batch, data)[source]

Fetch data for a specific product. (Nothing is modified.)

Depending on config, this will fetch a local product or external product to get the data.

This should invoke a configured handler for the query behavior, but that is not yet implemented. For now it uses built-in logic only, which queries the LocalProduct table.

This is a “batch action” method which may be called from create().

model_class

alias of Order

product_autocomplete()[source]

AJAX view for product autocomplete, when entering new order.

This invokes one of the following on the batch_handler:

Returns:

List of search results; each should be a dict with value and label keys.

row_model_class

alias of OrderItem

set_pending_customer(batch, data)[source]

This will set/update the batch pending customer info.

This calls set_customer() for the heavy lifting.

This is a “batch action” method which may be called from create(). See also:

start_over(batch)[source]

This will delete the user’s current batch, then redirect user back to “Create Order” page, which in turn will auto-create a new batch for them.

This is a “batch action” method which may be called from create(). See also:

submit_order(batch, data)[source]

This submits the user’s current new order batch, hence executing the batch and creating the true order.

This is a “batch action” method which may be called from create(). See also:

unassign_customer(batch, data)[source]

Clear the customer info for a batch.

This calls set_customer() for the heavy lifting.

This is a “batch action” method which may be called from create(). See also:

update_item(batch, data)[source]

This updates a row in the user’s current new order batch.

This is a “batch action” method which may be called from create(). See also: