Skip to content

Commit

Permalink
shopfloor: fix form mixin validators
Browse files Browse the repository at this point in the history
  • Loading branch information
simahawk committed Feb 16, 2022
1 parent c3eae83 commit 8186d43
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
17 changes: 15 additions & 2 deletions shopfloor/services/forms/form_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,23 @@ class ShopfloorFormMixinValidator(AbstractComponent):
_usage = "form_mixin.validator"

def get(self):
raise NotImplementedError()
return {
# TODO @simahawk: remove the need for this
# The black magic in base_rest
# is going to register the endpoint as `/int:id/get` (or `/update`)
# hence what is coming after as param is going to value `id`
# and `_id` as we expect in the method (to avoid using a built-in name).
# In theory we can replace this validator w/ proper restapi decorator.
"id": {"type": "integer", "rename": "_id"},
"_id": {"type": "integer"},
}

def update(self):
raise NotImplementedError()
return {
# TODO @simahawk: remove the need for this
"id": {"type": "integer", "rename": "_id"},
"_id": {"type": "integer"},
}


class ShopfloorFormMixinValidatorResponse(AbstractComponent):
Expand Down
16 changes: 7 additions & 9 deletions shopfloor/services/forms/picking_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,14 @@ class ShopfloorPickingFormValidator(Component):
_name = "shopfloor.form.stock.picking.validator"
_usage = "form_edit_stock_picking.validator"

def get(self):
return {
"id": {"type": "integer", "rename": "_id"},
"_id": {"type": "integer"},
}

def update(self):
return {
"carrier_id": {"type": "integer", "required": True},
}
schema = super().update()
schema.update(
{
"carrier_id": {"type": "integer", "required": True},
}
)
return schema


class ShopfloorPickingFormValidatorResponse(Component):
Expand Down

0 comments on commit 8186d43

Please sign in to comment.