[ckan-changes] commit/ckanextiati: 2 new changesets

Bitbucket commits-noreply at bitbucket.org
Mon Oct 31 10:44:04 UTC 2011


2 new commits in ckanextiati:


https://bitbucket.org/okfn/ckanextiati/changeset/f08fcb62505b/
changeset:   f08fcb62505b
branch:      spreadsheet-support
user:        amercader
date:        2011-10-31 11:31:40
summary:     Show error if no file was provided

Needed to use 403 because 400 will load the page inside the form. This needs to
be investigated.
affected #:  1 file

diff -r 4753d8b384afaebee0de6fa64629f4f01e0280c2 -r f08fcb62505b188444dd6813f711dd26a53bc6d7 ckanext/iati/controllers/spreadsheet.py
--- a/ckanext/iati/controllers/spreadsheet.py
+++ b/ckanext/iati/controllers/spreadsheet.py
@@ -109,6 +109,10 @@
             return render('csv/upload.html')
         elif request.method == 'POST':
             csv_file = request.POST['file']
+
+            if not csv_file:
+                abort(403,'No file provided')
+
             c.file_name = csv_file.filename
 
             added, updated, errors = self.read_csv_file(csv_file)



https://bitbucket.org/okfn/ckanextiati/changeset/6737186ed426/
changeset:   6737186ed426
branch:      spreadsheet-support
user:        amercader
date:        2011-10-31 11:43:52
summary:     Add links to CSV template files
affected #:  3 files

diff -r f08fcb62505b188444dd6813f711dd26a53bc6d7 -r 6737186ed426d4ab63a652ebdffe3b882081a17f ckanext/iati/controllers/spreadsheet.py
--- a/ckanext/iati/controllers/spreadsheet.py
+++ b/ckanext/iati/controllers/spreadsheet.py
@@ -57,7 +57,7 @@
 
         context = {'model':model,'user': c.user or c.author}
 
-        if publisher and publisher != 'all':
+        if publisher and publisher not in ['all','template']:
             try:
                 group = get_action('group_show')(context, {'id':publisher})
             except NotFound:
@@ -131,6 +131,9 @@
         try:
             if publisher == 'all':
                 packages = get_action('package_list')(context, {})
+            elif publisher == 'template':
+                # Just return an empty CSV file with just the headers
+                packages = []
             else:
                 group = get_action('group_show')(context, {'id':publisher})
                 packages = [pkg['id'] for pkg in group['packages']]


diff -r f08fcb62505b188444dd6813f711dd26a53bc6d7 -r 6737186ed426d4ab63a652ebdffe3b882081a17f ckanext/iati/templates/csv/index.html
--- a/ckanext/iati/templates/csv/index.html
+++ b/ckanext/iati/templates/csv/index.html
@@ -10,6 +10,7 @@
 
     <div>Select a Publisher to download all its records in CSV format.</div><div><strong>Warning:</strong>For publishers with a large number of datasets it may take a while to generate the CSV file. Please be patient.</div>
+    <div>Alternatively, you can download an empty CSV <a href="/csv/download/template">Template</a>.</div><hr class="cleared" /><table class="groups"><tr><th>Title</th><th>Number of datasets</th><th></th></tr>


diff -r f08fcb62505b188444dd6813f711dd26a53bc6d7 -r 6737186ed426d4ab63a652ebdffe3b882081a17f ckanext/iati/templates/csv/upload.html
--- a/ckanext/iati/templates/csv/upload.html
+++ b/ckanext/iati/templates/csv/upload.html
@@ -7,8 +7,8 @@
 
         <h2 class="head">CSV Import</h2>
 
-        <div>Please provide a CSV file.</div>
-        <div>Template?</div>
+        <div>Please provide a CSV file containing IATI regitry records metadata.</div>
+        <div>Files must follow the format specified in this <a href="/csv/download/template">Template</a>.</div><hr class="cleared" /><form id="csv-upload" action="/csv/upload" method="POST" enctype="multipart/form-data"><dl>

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