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

Bitbucket commits-noreply at bitbucket.org
Thu Aug 4 14:29:59 UTC 2011


5 new changesets in ckan:

http://bitbucket.org/okfn/ckan/changeset/44aeb292a08e/
changeset:   44aeb292a08e
branch:      release-v1.4.2
user:        dread
date:        2011-08-04 12:10:54
summary:     [release]: Add changelog for fix 1239.
affected #:  1 file (108 bytes)

--- a/CHANGELOG.txt	Sat Jul 23 18:16:15 2011 +0100
+++ b/CHANGELOG.txt	Thu Aug 04 11:10:54 2011 +0100
@@ -14,6 +14,7 @@
 
 Bug fixes:
   * When you removed last row of resource table, you could't add it again - since 1.0 (#1215)
+  * Adding a tag to package that had it previously didn't work - since 1.4.1 in UI and 1.4.0 in API (#1239)
   * Exception if you had any Groups and migrated between CKAN v1.0.2 to v1.2 (migration 29) - since v1.0.2 (#1205)
   * API Package edit requests returned the Package in a different format to usual - since 1.4 (#1214)
   * API error responses were not all JSON format and didn't have correct Content-Type (#1214)


http://bitbucket.org/okfn/ckan/changeset/5453aa58ffdf/
changeset:   5453aa58ffdf
branch:      release-v1.4.3
user:        rgrp
date:        2011-07-23 19:16:15
summary:     [bugfix,dictixation][s]: fixed bug (#1239) whereby deletion and re-adding or a tag to package was not working (tag would not be re-added).

* Bug details: when saving tags nothing was happening where the 'new' tag already had a corresponding PackageTag but it was deleted state. Comments in code and code changes (see diff) are more eloquent than i can be here.
* Added failing test to api/model/test_package.py (would have preferred to add to tests/lib/test_dictization, however the test methods there seem very interpendent (and large) and it was hard to add changes without breaking other things ...)
* NB: looking at rest of dictize code suspicious that this bug exists for other stateful relations (e.g. Package to Group)
affected #:  2 files (1.7 KB)

--- a/ckan/lib/dictization/model_save.py	Mon Aug 01 17:26:37 2011 +0100
+++ b/ckan/lib/dictization/model_save.py	Sat Jul 23 18:16:15 2011 +0100
@@ -139,12 +139,19 @@
     tag_package_tag = dict((package_tag.tag, package_tag) 
                             for package_tag in
                             package.package_tag_all)
+    
+    tag_package_tag_inactive = dict(
+        [ (tag,pt) for tag,pt in tag_package_tag.items() if
+            pt.state in ['deleted', 'pending-deleted'] ]
+        )
 
     tags = set()
     for tag_dict in tag_dicts:
         obj = table_dict_save(tag_dict, model.Tag, context)
         tags.add(obj)
 
+    # 3 cases
+    # case 1: currently active but not in new list
     for tag in set(tag_package_tag.keys()) - tags:
         package_tag = tag_package_tag[tag]
         if pending and package_tag.state <> 'deleted':
@@ -152,12 +159,19 @@
         else:
             package_tag.state = 'deleted'
 
+    # in new list but never used before
     for tag in tags - set(tag_package_tag.keys()):
         state = 'pending' if pending else 'active'
         package_tag_obj = model.PackageTag(package, tag, state)
         session.add(package_tag_obj)
         tag_package_tag[tag] = package_tag_obj
 
+    # in new list and already used but in deleted state
+    for tag in tags.intersection(set(tag_package_tag_inactive.keys())):
+        state = 'pending' if pending else 'active'
+        package_tag = tag_package_tag[tag]
+        package_tag.state = state
+
     package.package_tag_all[:] = tag_package_tag.values()
 
 def package_group_list_save(group_dicts, package, context):


--- a/ckan/tests/functional/api/model/test_package.py	Mon Aug 01 17:26:37 2011 +0100
+++ b/ckan/tests/functional/api/model/test_package.py	Sat Jul 23 18:16:15 2011 +0100
@@ -419,6 +419,37 @@
         # - title
         assert len(package.extras) == 1, package.extras
 
+    def test_entity_update_readd_tag(self):
+        name = self.package_fixture_data['name']
+        old_fixture_data = {
+            'name': name,
+            'tags': ['tag1', 'tag2']
+        }
+        new_fixture_data = {
+            'name': name,
+            'tags': ['tag1']
+        }
+        self.create_package_roles_revision(old_fixture_data)
+        offset = self.package_offset(name)
+        params = '%s=1' % self.dumps(new_fixture_data)
+        res = self.app.post(offset, params=params, status=self.STATUS_200_OK,
+                            extra_environ=self.extra_environ)
+
+        # Check the returned package is as expected
+        pkg = self.loads(res.body)
+        assert_equal(pkg['name'], new_fixture_data['name'])
+        assert_equal(pkg['tags'], ['tag1'])
+
+        package = self.get_package_by_name(new_fixture_data['name'])
+        assert len(package.tags) == 1, package.tags
+
+        # now reinstate the tag
+        params = '%s=1' % self.dumps(old_fixture_data)
+        res = self.app.post(offset, params=params, status=self.STATUS_200_OK,
+                            extra_environ=self.extra_environ)
+        pkg = self.loads(res.body)
+        assert_equal(pkg['tags'], ['tag1', 'tag2'])
+
     def test_entity_update_conflict(self):
         package1_name = self.package_fixture_data['name']
         package1_data = {'name': package1_name}


http://bitbucket.org/okfn/ckan/changeset/cdfbf67b5853/
changeset:   cdfbf67b5853
branch:      release-v1.4.2
user:        dread
date:        2011-08-04 12:31:46
summary:     [dictization][xs]: Fix for deleting a PackageExtra. This is from cset:ba14d090fc68. Changing the state to "delete" was a harmless problem, apparently behaving the same as if it was "deleted", but good to be consistent.
affected #:  1 file (1 byte)

--- a/ckan/lib/dictization/model_save.py	Thu Aug 04 11:10:54 2011 +0100
+++ b/ckan/lib/dictization/model_save.py	Thu Aug 04 11:31:46 2011 +0100
@@ -105,7 +105,7 @@
         extra = old_extras[key]
         if extra.state == 'deleted':
             continue
-        state = 'pending-deleted' if context.get('pending') else 'delete'
+        state = 'pending-deleted' if context.get('pending') else 'deleted'
         extra.state = state
 
 def group_extras_save(extras_dicts, context):


http://bitbucket.org/okfn/ckan/changeset/af31a7682f71/
changeset:   af31a7682f71
user:        dread
date:        2011-08-04 16:28:34
summary:     [merge] from release-v1.4.2.
affected #:  3 files (1.8 KB)

--- a/CHANGELOG.txt	Wed Aug 03 23:05:53 2011 +0100
+++ b/CHANGELOG.txt	Thu Aug 04 15:28:34 2011 +0100
@@ -14,6 +14,7 @@
 
 Bug fixes:
   * When you removed last row of resource table, you could't add it again - since 1.0 (#1215)
+  * Adding a tag to package that had it previously didn't work - since 1.4.1 in UI and 1.4.0 in API (#1239)
   * Exception if you had any Groups and migrated between CKAN v1.0.2 to v1.2 (migration 29) - since v1.0.2 (#1205)
   * API Package edit requests returned the Package in a different format to usual - since 1.4 (#1214)
   * API error responses were not all JSON format and didn't have correct Content-Type (#1214)


--- a/ckan/lib/dictization/model_save.py	Wed Aug 03 23:05:53 2011 +0100
+++ b/ckan/lib/dictization/model_save.py	Thu Aug 04 15:28:34 2011 +0100
@@ -139,12 +139,19 @@
     tag_package_tag = dict((package_tag.tag, package_tag) 
                             for package_tag in
                             package.package_tag_all)
+    
+    tag_package_tag_inactive = dict(
+        [ (tag,pt) for tag,pt in tag_package_tag.items() if
+            pt.state in ['deleted', 'pending-deleted'] ]
+        )
 
     tags = set()
     for tag_dict in tag_dicts:
         obj = table_dict_save(tag_dict, model.Tag, context)
         tags.add(obj)
 
+    # 3 cases
+    # case 1: currently active but not in new list
     for tag in set(tag_package_tag.keys()) - tags:
         package_tag = tag_package_tag[tag]
         if pending and package_tag.state <> 'deleted':
@@ -152,12 +159,19 @@
         else:
             package_tag.state = 'deleted'
 
+    # in new list but never used before
     for tag in tags - set(tag_package_tag.keys()):
         state = 'pending' if pending else 'active'
         package_tag_obj = model.PackageTag(package, tag, state)
         session.add(package_tag_obj)
         tag_package_tag[tag] = package_tag_obj
 
+    # in new list and already used but in deleted state
+    for tag in tags.intersection(set(tag_package_tag_inactive.keys())):
+        state = 'pending' if pending else 'active'
+        package_tag = tag_package_tag[tag]
+        package_tag.state = state
+
     package.package_tag_all[:] = tag_package_tag.values()
 
 def package_group_list_save(group_dicts, package, context):


--- a/ckan/tests/functional/api/model/test_package.py	Wed Aug 03 23:05:53 2011 +0100
+++ b/ckan/tests/functional/api/model/test_package.py	Thu Aug 04 15:28:34 2011 +0100
@@ -419,6 +419,37 @@
         # - title
         assert len(package.extras) == 1, package.extras
 
+    def test_entity_update_readd_tag(self):
+        name = self.package_fixture_data['name']
+        old_fixture_data = {
+            'name': name,
+            'tags': ['tag1', 'tag2']
+        }
+        new_fixture_data = {
+            'name': name,
+            'tags': ['tag1']
+        }
+        self.create_package_roles_revision(old_fixture_data)
+        offset = self.package_offset(name)
+        params = '%s=1' % self.dumps(new_fixture_data)
+        res = self.app.post(offset, params=params, status=self.STATUS_200_OK,
+                            extra_environ=self.extra_environ)
+
+        # Check the returned package is as expected
+        pkg = self.loads(res.body)
+        assert_equal(pkg['name'], new_fixture_data['name'])
+        assert_equal(pkg['tags'], ['tag1'])
+
+        package = self.get_package_by_name(new_fixture_data['name'])
+        assert len(package.tags) == 1, package.tags
+
+        # now reinstate the tag
+        params = '%s=1' % self.dumps(old_fixture_data)
+        res = self.app.post(offset, params=params, status=self.STATUS_200_OK,
+                            extra_environ=self.extra_environ)
+        pkg = self.loads(res.body)
+        assert_equal(pkg['tags'], ['tag1', 'tag2'])
+
     def test_entity_update_conflict(self):
         package1_name = self.package_fixture_data['name']
         package1_data = {'name': package1_name}


http://bitbucket.org/okfn/ckan/changeset/724c333400fd/
changeset:   724c333400fd
user:        dread
date:        2011-08-04 16:29:41
summary:     [merge] from release-v1.4.3.
affected #:  9 files (1.6 MB)

Binary file doc/images/virtualbox4-newvm.png has changed


Binary file doc/images/virtualbox5-vmtype.png has changed


Binary file doc/images/virtualbox6-vmloc.png has changed


Binary file doc/images/virtualbox7-startvm.png has changed


Binary file doc/images/virtualbox8-firstrun.png has changed


Binary file doc/images/virtualbox9-iso.png has changed


--- a/doc/install-from-package.rst	Thu Aug 04 15:28:34 2011 +0100
+++ b/doc/install-from-package.rst	Thu Aug 04 15:29:41 2011 +0100
@@ -6,7 +6,7 @@
 
 Package install requires you to use Ubuntu 10.04: either locally, through a virtual machine or Amazon EC2. Your options are as follows:
 
-* Using Ubuntu 10.04 directly. 
+* Using Ubuntu 10.04 directly.
 * :ref:`using-virtualbox`. This is suitable if you want to host your CKAN instance on a machine running any other OS. 
 * :ref:`using-amazon`. This is suitable if you want to host your CKAN instance in the cloud, on a ready-made Ubuntu OS.
 
@@ -59,19 +59,16 @@
 Go to Applications and open VirtualBox, then click New:
 
 .. image:: images/virtualbox4-newvm.png
-   :width: 807px
    :alt: The VirtualBox installer - the New Virtual Machine Wizard
 
 Give your VM a name - we'll call ours ``ubuntu_ckan``. Under **OS Type**, choose **Linux** and **Ubuntu (32 or 64-bit)**.
 
 .. image:: images/virtualbox5-vmtype.png
-   :width: 807px
    :alt: The VirtualBox installer - choosing your operating system
 
 Leave the memory size as 512MB, and choose **Create new hard disk**. This will open a new wizard:
 
 .. image:: images/virtualbox6-vmloc.png
-   :width: 807px
    :alt: The VirtualBox installer - creating a new hard disk
 
 You can leave the defaults unchanged here too - click **Continue**, and then **Done**, and **Done** again, to create a new VM. 
@@ -79,19 +76,16 @@
 Next, choose your VM from the left-hand menu, and click **Start**:
 
 .. image:: images/virtualbox7-startvm.png
-   :width: 807px
    :alt: Starting your new VM
 
 This will open the First Run Wizard:
 
 .. image:: images/virtualbox8-firstrun.png
-   :width: 807px
    :alt: The VirtualBox First Run Wizard
 
 After clicking **Continue**, you'll see **Select Installation Media**. This is where we need to tell our VM to boot from Ubuntu. Click on the file icon, and find your Ubuntu ``.iso`` file: 
 
 .. image:: images/virtualbox9-iso.png
-   :width: 807px
    :alt: When you get to Select Installation Media, choose your Ubuntu .iso file
 
 Click **Done**, wait for a few seconds, and you will see your Ubuntu VM booting.

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