[ckan-changes] commit/ckan: 3 new changesets

Bitbucket commits-noreply at bitbucket.org
Tue Sep 13 20:51:34 UTC 2011


3 new changesets in ckan:

http://bitbucket.org/okfn/ckan/changeset/58acdcfe6d4e/
changeset:   58acdcfe6d4e
branch:      feature-1294-ux-improvements-dataset
user:        rgrp
date:        2011-09-13 21:28:21
summary:     [logic/schema,bugfix][s]: fix for fact that trying to set resource size attribute with empty value in form resulted in exception.

* introduced new converter int_converter which returns None when no value from form (empty string) rather than throwing exceptoin.
* TODO: test!
affected #:  1 file (241 bytes)

--- a/ckan/logic/schema.py	Tue Sep 13 12:14:50 2011 +0100
+++ b/ckan/logic/schema.py	Tue Sep 13 20:28:21 2011 +0100
@@ -31,6 +31,15 @@
 from formencode.validators import OneOf
 import ckan.model
 
+def int_converter(indata):
+    if isinstance(indata, basestring):
+        cleaned = indata.strip()
+        if cleaned != '':
+            return int(indata)
+        else:
+            return None
+    else:
+        return int(indata)
     
 def default_resource_schema():
 
@@ -52,7 +61,7 @@
         'mimetype_inner': [ignore_missing, unicode],
         'webstore_url': [ignore_missing, unicode],
         'cache_url': [ignore_missing, unicode],
-        'size': [ignore_missing, int],
+        'size': [ignore_missing, int_converter],
         'last_modified': [ignore_missing, isodate],
         'cache_last_updated': [ignore_missing, isodate],
         'webstore_last_updated': [ignore_missing, isodate],


http://bitbucket.org/okfn/ckan/changeset/f83387298259/
changeset:   f83387298259
branch:      feature-1294-ux-improvements-dataset
user:        rgrp
date:        2011-09-13 22:19:31
summary:     [js,refactor][xs]: move ResourceAddLink view to bottom of file.
affected #:  1 file (9 bytes)

--- a/ckan/public/scripts/application.js	Tue Sep 13 20:28:21 2011 +0100
+++ b/ckan/public/scripts/application.js	Tue Sep 13 21:19:31 2011 +0100
@@ -369,35 +369,6 @@
 }(jQuery, CKAN.Utils || {});
 
 
-CKAN.View.ResourceAddLink = Backbone.View.extend({
-  initialize: function(options) {
-    _.bindAll(this, 'render');
-    this.mode = options.mode;
-  },
-
-  render: function() {
-    if (this.mode=='file') {
-      var tmpl = $.tmpl(CKAN.Templates.resourceAddLinkFile);
-    }
-    else if (this.mode=='api') {
-      var tmpl = $.tmpl(CKAN.Templates.resourceAddLinkApi);
-    }
-    $(this.el).html(tmpl);
-    return this;
-  },
-
-  events: {
-    'submit form': 'setResourceInfo',
-  },
-
-  setResourceInfo: function(e) {
-    e.preventDefault();
-    var urlVal=this.el.find('input[name=url]').val();
-    this.model.set({url: urlVal, type: this.mode})
-  }
-});
-
-
 CKAN.View.DatasetEdit = Backbone.View.extend({
   initialize: function() {
     _.bindAll(this, 'render');
@@ -629,3 +600,32 @@
   }
 });
 
+CKAN.View.ResourceAddLink = Backbone.View.extend({
+  initialize: function(options) {
+    _.bindAll(this, 'render');
+    this.mode = options.mode;
+  },
+
+  render: function() {
+    if (this.mode=='file') {
+      var tmpl = $.tmpl(CKAN.Templates.resourceAddLinkFile);
+    }
+    else if (this.mode=='api') {
+      var tmpl = $.tmpl(CKAN.Templates.resourceAddLinkApi);
+    }
+    $(this.el).html(tmpl);
+    return this;
+  },
+
+  events: {
+    'submit form': 'setResourceInfo',
+  },
+
+  setResourceInfo: function(e) {
+    e.preventDefault();
+    var urlVal=this.el.find('input[name=url]').val();
+    this.model.set({url: urlVal, resource_type: this.mode})
+  }
+});
+
+


http://bitbucket.org/okfn/ckan/changeset/645031d07b60/
changeset:   645031d07b60
branch:      feature-1294-ux-improvements-dataset
user:        rgrp
date:        2011-09-13 22:51:18
summary:     [logic/schema,bugfix][xs]: allow last_modified, cache_updated and webstore_updated to be empty as well as missing from the resource form.
affected #:  1 file (6 bytes)

--- a/ckan/logic/schema.py	Tue Sep 13 21:19:31 2011 +0100
+++ b/ckan/logic/schema.py	Tue Sep 13 21:51:18 2011 +0100
@@ -62,9 +62,9 @@
         'webstore_url': [ignore_missing, unicode],
         'cache_url': [ignore_missing, unicode],
         'size': [ignore_missing, int_converter],
-        'last_modified': [ignore_missing, isodate],
-        'cache_last_updated': [ignore_missing, isodate],
-        'webstore_last_updated': [ignore_missing, isodate],
+        'last_modified': [ignore_empty, isodate],
+        'cache_last_updated': [ignore_empty, isodate],
+        'webstore_last_updated': [ignore_empty, isodate],
         '__extras': [ignore_missing, extras_unicode_convert, keep_extras],
     }

Repository URL: https://bitbucket.org/okfn/ckan/

--

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