diff --git a/tailbone/views/batch/vendorcatalog.py b/tailbone/views/batch/vendorcatalog.py index 01fa85ea..1bd5eed7 100644 --- a/tailbone/views/batch/vendorcatalog.py +++ b/tailbone/views/batch/vendorcatalog.py @@ -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: