[ckan-changes] commit/ckanextiati: amercader: Make sure groups exists when adding properties to datasets

Bitbucket commits-noreply at bitbucket.org
Wed Oct 5 17:04:25 UTC 2011


1 new changeset in ckanextiati:

http://bitbucket.org/okfn/ckanextiati/changeset/b2f461ca526d/
changeset:   b2f461ca526d
user:        amercader
date:        2011-10-05 19:00:42
summary:     Make sure groups exists when adding properties to datasets
affected #:  1 file (-1 bytes)

--- a/ckanext/iati/patch.py	Wed Oct 05 16:30:17 2011 +0100
+++ b/ckanext/iati/patch.py	Wed Oct 05 18:00:42 2011 +0100
@@ -20,7 +20,7 @@
 def as_dict_with_groups_types(self):
 #    import pdb; pdb.set_trace()
     _dict = old_as_dict(self)
-    _dict['extras']['publishertype'] = ''.join([g.extras.get('type', '') for g in self.groups])
+    _dict['extras']['publishertype'] = ''.join([g.extras.get('type', '') for g in self.groups if g])
     return _dict
 
 Package.as_dict = as_dict_with_groups_types
@@ -30,7 +30,7 @@
 
 def package_to_api1_with_groups_types(pkg,context):
     _dict = old_package_to_api1(pkg,context) 
-    _dict['extras']['publishertype'] = ''.join([g.extras.get('type', '') for g in pkg.groups])
+    _dict['extras']['publishertype'] = ''.join([g.extras.get('type', '') for g in pkg.groups if g])
     return _dict
 
 model_dictize.package_to_api1 = package_to_api1_with_groups_types

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