[ckan-changes] commit/ckanextiati: amercader: Check if incoming file has all necessary columns
Bitbucket
commits-noreply at bitbucket.org
Mon Oct 31 11:47:36 UTC 2011
1 new commit in ckanextiati:
https://bitbucket.org/okfn/ckanextiati/changeset/8a6bb9a2a337/
changeset: 8a6bb9a2a337
branch: spreadsheet-support
user: amercader
date: 2011-10-31 12:47:25
summary: Check if incoming file has all necessary columns
affected #: 1 file
diff -r 8e771f6af7237c81bce59e78053cabbed6892a3b -r 8a6bb9a2a337b3515786cca5cce445d24d1e87e2 ckanext/iati/controllers/spreadsheet.py
--- a/ckanext/iati/controllers/spreadsheet.py
+++ b/ckanext/iati/controllers/spreadsheet.py
@@ -9,7 +9,7 @@
from ckan.logic import get_action, NotFound, ValidationError, NotAuthorized
from ckan.logic.converters import date_to_db
from ckan.logic.validators import int_validator
-from ckan.lib.navl.validators import not_empty, ignore_empty
+from ckan.lib.navl.validators import not_empty, ignore_empty, not_missing
from ckan.lib.navl.dictization_functions import validate
from ckanext.iati.authz import get_user_administered_groups
@@ -191,6 +191,11 @@
log.debug('Starting reading file %s (delimiter "%s", escapechar "%s")' %
(csv_file.filename,dialect.delimiter,dialect.escapechar))
+ # Check if all columns are present
+ if not sorted(reader.fieldnames) == sorted(fieldnames):
+ error = {'file': 'Missing columns: %s' % ' ,'.join([f for f in fieldnames if f not in reader.fieldnames])}
+ return [], [], [('1',error)]
+
context = {'model':model,'user': c.user or c.author, 'api_verion':'1'}
groups= get_action('group_list')(context, {})
Repository URL: https://bitbucket.org/okfn/ckanextiati/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the ckan-changes
mailing list