Validate vendor for catalog batch upload
This commit is contained in:
parent
2fa62acbbd
commit
d1fc5d5c38
|
@ -202,6 +202,8 @@ class VendorCatalogView(FileBatchMasterView):
|
|||
if self.creating and 'vendor' in f:
|
||||
f.replace('vendor', 'vendor_uuid')
|
||||
f.set_label('vendor_uuid', "Vendor")
|
||||
f.set_required('vendor_uuid')
|
||||
f.set_validator('vendor_uuid', self.valid_vendor_uuid)
|
||||
|
||||
# should we use dropdown or autocomplete? note that if
|
||||
# autocomplete is to be used, we also must make sure we
|
||||
|
@ -258,6 +260,13 @@ class VendorCatalogView(FileBatchMasterView):
|
|||
else:
|
||||
f.remove('cache_products')
|
||||
|
||||
def valid_vendor_uuid(self, node, value):
|
||||
model = self.model
|
||||
if value:
|
||||
vendor = self.Session.get(model.Vendor, value)
|
||||
if not vendor:
|
||||
raise colander.Invalid(node, "Vendor not found")
|
||||
|
||||
def render_parser_key(self, batch, field):
|
||||
key = getattr(batch, field)
|
||||
if not key:
|
||||
|
|
Loading…
Reference in a new issue