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

Bitbucket commits-noreply at bitbucket.org
Mon Jul 25 12:49:47 UTC 2011


3 new changesets in ckan:

http://bitbucket.org/okfn/ckan/changeset/8aab67870250/
changeset:   8aab67870250
branch:      feature-1141-moderated-edits-ajax
user:        John Glover
date:        2011-07-21 17:10:07
summary:     [moderatededits] Bug fix: use new Resource.get in resource_dict_save, checks the resource_revision table rather than resource
affected #:  1 file (15 bytes)

--- a/ckan/lib/dictization/model_save.py	Thu Jul 21 15:52:48 2011 +0100
+++ b/ckan/lib/dictization/model_save.py	Thu Jul 21 16:10:07 2011 +0100
@@ -14,7 +14,7 @@
     id = res_dict.get("id")
     
     if id:
-        obj = session.query(model.Resource).get(id)
+        obj = model.Resource.get(id)
 
     if not obj:
         obj = model.Resource()


http://bitbucket.org/okfn/ckan/changeset/7daa142110f5/
changeset:   7daa142110f5
branch:      feature-1141-moderated-edits-ajax
user:        John Glover
date:        2011-07-25 13:55:45
summary:     [moderatededits] Bug fix: make sure that active resources stay active when saving
affected #:  1 file (335 bytes)

--- a/ckan/lib/dictization/model_save.py	Thu Jul 21 16:10:07 2011 +0100
+++ b/ckan/lib/dictization/model_save.py	Mon Jul 25 12:55:45 2011 +0100
@@ -5,17 +5,15 @@
 ##package saving
 
 def resource_dict_save(res_dict, context):
-
     model = context["model"]
     session = context["session"]
 
-    obj = None
-
+    # try to get resource object directly from context, then by ID
+    # if not found, create a new resource object
     id = res_dict.get("id")
-    
-    if id:
-        obj = model.Resource.get(id)
-
+    obj = context.get("resource")
+    if (not obj) and id:
+        obj = session.query(model.Resource).get(id)
     if not obj:
         obj = model.Resource()
 
@@ -30,14 +28,17 @@
         if key in fields:
             setattr(obj, key, value)
         else:
+            # resources save extras directly onto the object, instead
+            # of in a separate extras field like packages and groups
             obj.extras[key] = value
 
     if context.get('pending'):
         if session.is_modified(obj, include_collections=False):
-            obj.state = 'pending'
+            obj.state = u'pending'
+    else:
+        obj.state = u'active'
 
     session.add(obj)
-
     return obj
 
 def package_resource_list_save(res_dicts, package, context):


http://bitbucket.org/okfn/ckan/changeset/49d3a5a2818f/
changeset:   49d3a5a2818f
branch:      feature-1141-moderated-edits-ajax
user:        John Glover
date:        2011-07-25 13:57:25
summary:     [moderatededits] Change state to a unicode value
affected #:  1 file (1 byte)

--- a/ckan/model/resource.py	Mon Jul 25 12:55:45 2011 +0100
+++ b/ckan/model/resource.py	Mon Jul 25 12:57:25 2011 +0100
@@ -87,7 +87,7 @@
         '''Returns a resource object referenced by its id.'''
         query = Session.query(ResourceRevision).filter(ResourceRevision.id==reference)
         query = query.filter(and_(
-            ResourceRevision.state == 'active', ResourceRevision.current == True
+            ResourceRevision.state == u'active', ResourceRevision.current == True
         ))
         return query.first()

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