|
|
|
@ -1,11 +1,12 @@
@@ -1,11 +1,12 @@
|
|
|
|
|
import colander |
|
|
|
|
import deform |
|
|
|
|
|
|
|
|
|
from ordr2.models import Category |
|
|
|
|
from ordr2.models import Category, OrderStatus |
|
|
|
|
|
|
|
|
|
from . import CSRFSchema, MoneyInputSchema |
|
|
|
|
|
|
|
|
|
CATEGORIES = [(c.name, c.value.capitalize()) for c in Category] |
|
|
|
|
STATI = [(s.name, s.value.capitalize()) for s in OrderStatus] |
|
|
|
|
|
|
|
|
|
# schema for user registration |
|
|
|
|
|
|
|
|
@ -63,3 +64,123 @@ class ConsumableSchema(CSRFSchema):
@@ -63,3 +64,123 @@ class ConsumableSchema(CSRFSchema):
|
|
|
|
|
} |
|
|
|
|
settings.update(override) |
|
|
|
|
return super().as_form(request, **settings) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class OrderInformation(colander.Schema): |
|
|
|
|
|
|
|
|
|
status = colander.SchemaNode( |
|
|
|
|
colander.String(), |
|
|
|
|
widget=deform.widget.SelectWidget(values=STATI) |
|
|
|
|
) |
|
|
|
|
placed = colander.SchemaNode( |
|
|
|
|
colander.String(), |
|
|
|
|
widget=deform.widget.TextInputWidget(readonly=True), |
|
|
|
|
missing='' |
|
|
|
|
) |
|
|
|
|
approval = colander.SchemaNode( |
|
|
|
|
colander.String(), |
|
|
|
|
widget=deform.widget.TextInputWidget(readonly=True), |
|
|
|
|
missing='' |
|
|
|
|
) |
|
|
|
|
ordered = colander.SchemaNode( |
|
|
|
|
colander.String(), |
|
|
|
|
widget=deform.widget.TextInputWidget(readonly=True), |
|
|
|
|
missing='' |
|
|
|
|
) |
|
|
|
|
completed = colander.SchemaNode( |
|
|
|
|
colander.String(), |
|
|
|
|
widget=deform.widget.TextInputWidget(readonly=True), |
|
|
|
|
missing='' |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class OrderItem(colander.Schema): |
|
|
|
|
|
|
|
|
|
cas_description = colander.SchemaNode( |
|
|
|
|
colander.String() |
|
|
|
|
) |
|
|
|
|
category = colander.SchemaNode( |
|
|
|
|
colander.String(), |
|
|
|
|
widget=deform.widget.SelectWidget(values=CATEGORIES) |
|
|
|
|
) |
|
|
|
|
catalog_nr = colander.SchemaNode( |
|
|
|
|
colander.String() |
|
|
|
|
) |
|
|
|
|
vendor = colander.SchemaNode( |
|
|
|
|
colander.String() |
|
|
|
|
) |
|
|
|
|
package_size = colander.SchemaNode( |
|
|
|
|
colander.String() |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class OrderPricing(colander.Schema): |
|
|
|
|
|
|
|
|
|
unit_price = MoneyInputSchema( |
|
|
|
|
readonly=False |
|
|
|
|
) |
|
|
|
|
quantity = colander.SchemaNode( |
|
|
|
|
colander.Integer(), |
|
|
|
|
validator=colander.Range(min=1), |
|
|
|
|
default=1 |
|
|
|
|
) |
|
|
|
|
total_price = MoneyInputSchema( |
|
|
|
|
readonly=True |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class OrderOptionals(colander.Schema): |
|
|
|
|
|
|
|
|
|
account = colander.SchemaNode( |
|
|
|
|
colander.String(), |
|
|
|
|
missing='' |
|
|
|
|
) |
|
|
|
|
comment = colander.SchemaNode( |
|
|
|
|
colander.String(), |
|
|
|
|
widget=deform.widget.TextAreaWidget(rows=5), |
|
|
|
|
missing='' |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NewOrderSchema(CSRFSchema): |
|
|
|
|
''' edit or add an order ''' |
|
|
|
|
|
|
|
|
|
item_information = OrderItem() |
|
|
|
|
pricing = OrderPricing() |
|
|
|
|
optional_informatoin = OrderOptionals() |
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
def as_form(cls, request, **override): |
|
|
|
|
settings = { |
|
|
|
|
'buttons': ('Place Order', 'Cancel'), |
|
|
|
|
'css_class': 'form-horizontal' |
|
|
|
|
} |
|
|
|
|
settings.update(override) |
|
|
|
|
return super().as_form(request, **settings) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class EditOrderSchema(CSRFSchema): |
|
|
|
|
''' edit or add an order ''' |
|
|
|
|
|
|
|
|
|
order_information = OrderInformation() |
|
|
|
|
item_information = OrderItem() |
|
|
|
|
pricing = OrderPricing() |
|
|
|
|
optional_informatoin = OrderOptionals() |
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
def as_form(cls, request, **override): |
|
|
|
|
settings = { |
|
|
|
|
'buttons': ( |
|
|
|
|
deform.Button(name='save', title='Edit Order'), |
|
|
|
|
deform.Button( |
|
|
|
|
name='delete', |
|
|
|
|
title='Delete Order', |
|
|
|
|
css_class='btn-danger' |
|
|
|
|
), |
|
|
|
|
deform.Button(name='cancel', title='Cancel') |
|
|
|
|
), |
|
|
|
|
'css_class': 'form-horizontal' |
|
|
|
|
} |
|
|
|
|
settings.update(override) |
|
|
|
|
return super().as_form(request, **settings) |
|
|
|
|