sideshow.web.views.orders
¶
Views for Orders
- class sideshow.web.views.orders.ContactView(request, context=None)[source]¶
Master view for the “contact” phase of
OrderItem
; route prefix iscontact
. This is a subclass ofOrderItemView
.This class auto-filters so only order items with the following status codes are shown:
Notable URLs provided by this class:
/contact/
/contact/XXX
- process_contact_failure()[source]¶
View to process the “contact failure” step for some order item(s).
This requires a POST request with data:
- Parameters:
item_uuids – Comma-delimited list of
OrderItem
UUID keys.note – Optional note text from the user.
This invokes
process_contact_failure()
on theorder_handler
, then redirects user back to the index page.
- process_contact_success()[source]¶
View to process the “contact success” step for some order item(s).
This requires a POST request with data:
- Parameters:
item_uuids – Comma-delimited list of
OrderItem
UUID keys.note – Optional note text from the user.
This invokes
process_contact_success()
on theorder_handler
, then redirects user back to the index page.
- class sideshow.web.views.orders.DeliveryView(request, context=None)[source]¶
Master view for the “delivery” phase of
OrderItem
; route prefix isdelivery
. This is a subclass ofOrderItemView
.This class auto-filters so only order items with the following status codes are shown:
Notable URLs provided by this class:
/delivery/
/delivery/XXX
- process_delivery()[source]¶
View to process the “delivery” step for some order item(s).
This requires a POST request with data:
- Parameters:
item_uuids – Comma-delimited list of
OrderItem
UUID keys.note – Optional note text from the user.
This invokes
process_delivery()
on theorder_handler
, then redirects user back to the index page.
- process_restock()[source]¶
View to process the “restock” step for some order item(s).
This requires a POST request with data:
- Parameters:
item_uuids – Comma-delimited list of
OrderItem
UUID keys.note – Optional note text from the user.
This invokes
process_restock()
on theorder_handler
, then redirects user back to the index page.
- class sideshow.web.views.orders.OrderItemView(request, context=None)[source]¶
Master view for
OrderItem
; route prefix isorder_items
.Notable URLs provided by this class:
/order-items/
/order-items/XXX
This class serves both as a proper master view (for “all” order items) as well as a base class for other “workflow” master views, each of which auto-filters by order item status:
Note that this does not expose create, edit or delete. The user must perform various other workflow actions to modify the item.
- order_handler¶
Reference to the order handler as returned by
get_order_handler()
.
- add_note()[source]¶
View which adds a note to an order item. This is POST-only; will redirect back to the item view.
- change_status()[source]¶
View which changes status for an order item. This is POST-only; will redirect back to the item view.
- get_order_items(uuids)[source]¶
This method provides common logic to fetch a list of order items based on a list of UUID keys. It is used by various workflow action methods.
Note that if no order items are found, this will set a flash warning message and raise a redirect back to the index page.
- Parameters:
uuids – List (or comma-delimited string) of UUID keys.
- Returns:
List of
OrderItem
records.
- class sideshow.web.views.orders.OrderView(request, context=None)[source]¶
Master view for
Order
; route prefix isorders
.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.
- order_handler¶
Reference to the order handler as returned by
get_order_handler()
. This gets set in the constructor.
- batch_handler¶
Reference to the new order 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
andlabel
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_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_dept_item_discounts()[source]¶
Returns the list of per-department default item discount settings.
Each entry in the list will look like:
{ 'department_id': '42', 'department_name': 'Grocery', 'default_item_discount': 10, }
- Returns:
List of department settings as shown above.
- get_past_products(batch, data)[source]¶
Fetch past products for convenient re-ordering.
This essentially calls
get_past_products()
on thebatch_handler
and returns the result.This is a “batch action” method which may be called from
create()
.- Returns:
List of product info dicts.
- get_product_info(batch, data)[source]¶
Fetch data for a specific product.
Depending on config, this calls one of the following to get its primary data:
It then may supplement the data with additional fields.
This is a “batch action” method which may be called from
create()
.- Returns:
Dict of product info.
- 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
andlabel
keys.
- 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:
- set_store(batch, data)[source]¶
Assign the
store_id
for a batch.This is a “batch action” method which may be called from
create()
.
- 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:
- class sideshow.web.views.orders.PlacementView(request, context=None)[source]¶
Master view for the “placement” phase of
OrderItem
; route prefix isplacement
. This is a subclass ofOrderItemView
.This class auto-filters so only order items with the following status codes are shown:
Notable URLs provided by this class:
/placement/
/placement/XXX
- process_placement()[source]¶
View to process the “placement” step for some order item(s).
This requires a POST request with data:
- Parameters:
item_uuids – Comma-delimited list of
OrderItem
UUID keys.vendor_name – Optional name of vendor.
po_number – Optional PO number.
note – Optional note text from the user.
This invokes
process_placement()
on theorder_handler
, then redirects user back to the index page.
- class sideshow.web.views.orders.ReceivingView(request, context=None)[source]¶
Master view for the “receiving” phase of
OrderItem
; route prefix isreceiving
. This is a subclass ofOrderItemView
.This class auto-filters so only order items with the following status codes are shown:
Notable URLs provided by this class:
/receiving/
/receiving/XXX
- process_receiving()[source]¶
View to process the “receiving” step for some order item(s).
This requires a POST request with data:
- Parameters:
item_uuids – Comma-delimited list of
OrderItem
UUID keys.vendor_name – Optional name of vendor.
invoice_number – Optional invoice number.
po_number – Optional PO number.
note – Optional note text from the user.
This invokes
process_receiving()
on theorder_handler
, then redirects user back to the index page.
- process_reorder()[source]¶
View to process the “reorder” step for some order item(s).
This requires a POST request with data:
- Parameters:
item_uuids – Comma-delimited list of
OrderItem
UUID keys.note – Optional note text from the user.
This invokes
process_reorder()
on theorder_handler
, then redirects user back to the index page.