From a6069d93db9a6ff4b452ea41a93af3c26309cabf Mon Sep 17 00:00:00 2001 From: Mark Winterbottom Date: Fri, 30 Oct 2015 16:59:04 +0000 Subject: [PATCH] Fixed bug where the harvest source url validator would validate against all harvest sources that were ever created instead of just sources that were currently enabled. --- ckanext/harvest/logic/validators.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ckanext/harvest/logic/validators.py b/ckanext/harvest/logic/validators.py index a88d46b..aa5ca15 100644 --- a/ckanext/harvest/logic/validators.py +++ b/ckanext/harvest/logic/validators.py @@ -79,8 +79,8 @@ def harvest_source_url_validator(key, data, errors, context): new_url = _normalize_url(data[key]) - # q = model.Session.query(model.Package.url, model.Package.state) \ - q = model.Session.query(HarvestSource.url, HarvestSource.config) \ + q = model.Session.query( + model.Package.id, model.Package.url) \ .filter(model.Package.type == DATASET_TYPE_NAME) if package_id: @@ -89,8 +89,14 @@ def harvest_source_url_validator(key, data, errors, context): existing_sources = q.all() - for url, conf in existing_sources: + for uid, url in existing_sources: url = _normalize_url(url) + conf = model.Session.query(HarvestSource.config).filter( + HarvestSource.id == uid).first() + if conf: + conf = conf[0] + else: + conf = None if url == new_url and conf == new_config: # You can have a duplicate URL if it's pointing to a unique