From 5540a66ffd0ac3d912e841e030a405f032ac7570 Mon Sep 17 00:00:00 2001 From: Sean Hammond Date: Wed, 29 Feb 2012 17:21:57 +0100 Subject: [PATCH 1/7] Add `paster create-test-data vocabs` --- ckan/lib/create_test_data.py | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/ckan/lib/create_test_data.py b/ckan/lib/create_test_data.py index b90fbc3bd3e..32fb68d564c 100644 --- a/ckan/lib/create_test_data.py +++ b/ckan/lib/create_test_data.py @@ -11,6 +11,8 @@ class CreateTestData(cli.CkanCommand): create-test-data gov - government style data create-test-data family - package relationships data create-test-data user - create a user 'tester' with api key 'tester' + create-test-data vocabs - annakerenina, warandpeace, and some test + vocabularies ''' summary = __doc__.split('\n')[0] usage = __doc__ @@ -51,6 +53,8 @@ def command(self): self.create_gov_test_data() elif cmd == 'family': self.create_family_test_data() + elif cmd == 'vocabs': + self.create_vocabs_test_data() else: print 'Command %s not recognized' % cmd raise NotImplementedError @@ -87,6 +91,43 @@ def create_test_user(cls): model.Session.remove() cls.user_refs.append(u'tester') + @classmethod + def create_vocabs_test_data(cls): + import ckan.model + CreateTestData.create() + sysadmin_user = ckan.model.User.get('testsysadmin') + annakarenina = ckan.model.Package.get('annakarenina') + warandpeace = ckan.model.Package.get('warandpeace') + + # Create a couple of vocabularies. + context = { + 'model': ckan.model, + 'session': ckan.model.Session, + 'user': sysadmin_user.name + } + data_dict = { + 'name': 'Genre', + 'tags': [{'name': 'Drama'}, {'name': 'Sci-Fi'}, + {'name': 'Mystery'}], + } + ckan.logic.action.create.vocabulary_create(context, data_dict) + + data_dict = { + 'name': 'Actors', + 'tags': [{'name': 'keira-knightley'}, {'name': 'jude-law'}, + {'name': 'alessio-boni'}], + } + ckan.logic.action.create.vocabulary_create(context, data_dict) + + # Add some vocab tags to some packages. + genre_vocab = ckan.model.Vocabulary.get('Genre') + actors_vocab = ckan.model.Vocabulary.get('Actors') + annakarenina.add_tag_by_name('Drama', vocab=genre_vocab) + annakarenina.add_tag_by_name('keira-knightley', vocab=actors_vocab) + annakarenina.add_tag_by_name('jude-law', vocab=actors_vocab) + warandpeace.add_tag_by_name('Drama', vocab=genre_vocab) + warandpeace.add_tag_by_name('alessio-boni', vocab=actors_vocab) + @classmethod def create_arbitrary(cls, package_dicts, relationships=[], extra_user_names=[], extra_group_names=[], From 1468e93a7bbe980e67094f0b4534261de092967d Mon Sep 17 00:00:00 2001 From: Sean Hammond Date: Sat, 3 Mar 2012 20:29:05 +0100 Subject: [PATCH 2/7] [#1825] Update Action API docs for vocabularies New vocabulary_id option for tag_list, tag_autocomplete, tag_search. New API calls vocabulary_list, vocabulary_show, vocabulary_create, vocabulary_update, vocabulary_delete, tag_create, tag_delete. Add vocabulary_id to tag keys section, add vocabulary keys section. --- doc/apiv3.rst | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/doc/apiv3.rst b/doc/apiv3.rst index 99b1b816f47..e2b3e35d7cb 100644 --- a/doc/apiv3.rst +++ b/doc/apiv3.rst @@ -63,9 +63,10 @@ group_list_authz (none) group_list_available (none) group_revision_list id licence_list (none) -tag_list q, all_fields, limit, offset, return_objects +tag_list q, all_fields, limit, offset, return_objects, vocabulary_id user_list q, order_by package_relationships_list id, id2, rel +vocabulary_list (none) package_show id revision_show id group_show id @@ -74,12 +75,15 @@ user_show id package_show_rest id group_show_rest id tag_show_rest id +vocabulary_show id package_autocomplete q -tag_autocomplete q, limit +tag_autocomplete q, fields, offset, limit, vocabulary_id format_autocomplete q, limit user_autocomplete q, limit package_search q, fields, facet_by, limit, offset +tag_search q, fields, offset, limit, vocabulary_id roles_show domain_object, (user), (authorization_group) + ====================================== =========================== new.py: @@ -96,6 +100,8 @@ rating_create package, rating user_create (user keys) package_create_rest (package keys) group_create_rest (group keys) +vocabulary_create (vocabulary keys) +tag_create (tag keys) ====================================== =========================== update.py: @@ -114,6 +120,7 @@ package_update_rest (package keys) group_update_rest (group keys) user_role_update user OR authorization_group, domain_object, roles user_role_bulk_update user_roles, domain_object +vocabulary_update (vocabulary keys) ====================================== =========================== delete.py: @@ -124,6 +131,8 @@ Logic Action Parameter keys package_delete id package_relationship_delete id, id2, rel group_delete id +vocabulary_delete id +tag_delete id, vocabulary_id ====================================== =========================== In case of doubt, refer to the code of the logic actions, which is found in the CKAN source in the ckan/logic/action directory. @@ -197,6 +206,7 @@ id "b10871ea-b4ae-4e2e-bec9-a8d8ff357754" (Read-only) name "country-uk" (Read-only) Add/remove tags from a package or group using update_package or update_group state "active" (Read-only) Add/remove tags from a package or group using update_package or update_group revision_timestamp "2009-08-08T12:46:40.920443" (Read-only) +vocabulary_id "Genre" (Read-only) Vocabulary name or id. Optional. ======================== ====================================== ============= user_roles: @@ -209,6 +219,16 @@ authorization_group "16f8f7ba-1a97-4d27-95ce-5e8827a0d75f" roles ['editor', 'admin'] ======================== ====================================== ============= +Vocabulary: + +======================== ===================================================== ============= +key example value notes +======================== ===================================================== ============= +id "b10871ea-b4ae-4e2e-bec9-a8d8ff357754" (Read-only) +name "Genre" +tags [{"name":"government-spending"}, {"name": "climate"}] List of tags belonging to this vocabulary. +======================== ===================================================== ============= + Parameters ========== From d05a61e841c7c6c2801e7155cbb5e04e2da92e04 Mon Sep 17 00:00:00 2001 From: Sean Hammond Date: Sat, 3 Mar 2012 21:02:20 +0100 Subject: [PATCH 3/7] Fix an example in the Action API docs Tags have to be a list of tag dicts, not a list of strings --- doc/apiv3.rst | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/doc/apiv3.rst b/doc/apiv3.rst index e2b3e35d7cb..6c52918403e 100644 --- a/doc/apiv3.rst +++ b/doc/apiv3.rst @@ -142,28 +142,28 @@ Object dictionaries Package: -======================== ====================================== ============= -key example value notes -======================== ====================================== ============= -id "fd788e57-dce4-481c-832d-497235bf9f78" (Read-only) unique identifier -name "uk-spending" Unique identifier. Should be human readable -title "UK Spending" Human readable title of the dataset -url "http://gov.uk/spend-downloads.html" Home page for the data -version "1.0" Version associated with the data. String format. -author "UK Treasury" Name of person responsible for the data -author_email "contact@treasury.gov.uk" Email address for the person in the 'author' field -maintainer null Name of another person responsible for the data -maintainer_email null Email address for the person in the 'maintainer' field -notes "### About\\r\\n\\r\\nUpdated 1997." Other human readable info about the dataset. Markdown format. -license_id "cc-by" ID of the license this dataset is released under. You can then look up the license ID to get the title. +======================== ====================================================== ============= +key example value notes +======================== ====================================================== ============= +id "fd788e57-dce4-481c-832d-497235bf9f78" (Read-only) unique identifier +name "uk-spending" Unique identifier. Should be human readable +title "UK Spending" Human readable title of the dataset +url "http://gov.uk/spend-downloads.html" Home page for the data +version "1.0" Version associated with the data. String format. +author "UK Treasury" Name of person responsible for the data +author_email "contact@treasury.gov.uk" Email address for the person in the 'author' field +maintainer null Name of another person responsible for the data +maintainer_email null Email address for the person in the 'maintainer' field +notes "### About\\r\\n\\r\\nUpdated 1997." Other human readable info about the dataset. Markdown format. +license_id "cc-by" ID of the license this dataset is released under. You can then look up the license ID to get the title. extras [] -tags ["government-spending"] List of tags associated with this dataset. -groups ["spending", "country-uk"] List of groups this dataset is a member of. -relationships_as_subject [] List of relationships. The 'type' of the relationship is described in terms of this package being the subject and the related package being the object. -state active May be ``deleted`` or other custom states like ``pending``. -revision_id "f645243a-7334-44e2-b87c-64231700a9a6" (Read-only) ID of the last revision for the core package object was (doesn't include tags, groups, extra fields, relationships). -revision_timestamp "2010-12-21T15:26:17.345502" (Read-only) Time and date when the last revision for the core package object was (doesn't include tags, groups, extra fields, relationships). ISO format. UTC timezone assumed. -======================== ====================================== ============= +tags [{"name": "government-spending"}, {"name": "climate"}] List of tags associated with this dataset. +groups ["spending", "country-uk"] List of groups this dataset is a member of. +relationships_as_subject [] List of relationships. The 'type' of the relationship is described in terms of this package being the subject and the related package being the object. +state active May be ``deleted`` or other custom states like ``pending``. +revision_id "f645243a-7334-44e2-b87c-64231700a9a6" (Read-only) ID of the last revision for the core package object was (doesn't include tags, groups, extra fields, relationships). +revision_timestamp "2010-12-21T15:26:17.345502" (Read-only) Time and date when the last revision for the core package object was (doesn't include tags, groups, extra fields, relationships). ISO format. UTC timezone assumed. +======================== ====================================================== ============= Package Extra: From a75a230b15260522f8c04610450d7438affebf84 Mon Sep 17 00:00:00 2001 From: Sean Hammond Date: Sat, 3 Mar 2012 21:07:30 +0100 Subject: [PATCH 4/7] Fix another example in the Action API docs Groups have to be a list of group dicts, not a list of strings --- doc/apiv3.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/apiv3.rst b/doc/apiv3.rst index 6c52918403e..eb58abb4512 100644 --- a/doc/apiv3.rst +++ b/doc/apiv3.rst @@ -158,7 +158,7 @@ notes "### About\\r\\n\\r\\nUpdated 1997." license_id "cc-by" ID of the license this dataset is released under. You can then look up the license ID to get the title. extras [] tags [{"name": "government-spending"}, {"name": "climate"}] List of tags associated with this dataset. -groups ["spending", "country-uk"] List of groups this dataset is a member of. +groups [{"name": "spending"}, {"name": "country-uk"}] List of groups this dataset is a member of. relationships_as_subject [] List of relationships. The 'type' of the relationship is described in terms of this package being the subject and the related package being the object. state active May be ``deleted`` or other custom states like ``pending``. revision_id "f645243a-7334-44e2-b87c-64231700a9a6" (Read-only) ID of the last revision for the core package object was (doesn't include tags, groups, extra fields, relationships). From 897f01282f92e05f0a03a33f716e41928096a91f Mon Sep 17 00:00:00 2001 From: Rufus Pollock Date: Tue, 13 Mar 2012 15:28:33 +0000 Subject: [PATCH 5/7] [master,resource/read][xs]: put open data button after license again as o/w css is wrong. --- ckan/templates/package/resource_read.html | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/ckan/templates/package/resource_read.html b/ckan/templates/package/resource_read.html index 685e9eecb59..c1a498be8aa 100644 --- a/ckan/templates/package/resource_read.html +++ b/ckan/templates/package/resource_read.html @@ -105,6 +105,13 @@
Licence
+ + ${c.pkg.license.title.split('::')[-1]} + ${c.pkg.license.title} + ${c.pkg.license_id} + License unknown + [Open Data] @@ -115,14 +122,6 @@ ${h.icon('lock')} - - - ${c.pkg.license.title.split('::')[-1]} - ${c.pkg.license.title} - ${c.pkg.license_id} - License unknown -
From d56b76a7f22f98363ba8489908bf693668bd2e34 Mon Sep 17 00:00:00 2001 From: Rufus Pollock Date: Wed, 14 Mar 2012 11:29:45 +0000 Subject: [PATCH 6/7] [master,README][xs]: tiny tweak to rst formatting. --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 8cc867f4844..4178fe69291 100644 --- a/README.rst +++ b/README.rst @@ -16,8 +16,8 @@ Building Documentation 2. Initialize the theme submodule:: - git submodule init - git submodule update + git submodule init + git submodule update 3. Run the command to build the docs:: From b9755e98187c537e829746de1f125fbb66ee31cd Mon Sep 17 00:00:00 2001 From: Rufus Pollock Date: Wed, 14 Mar 2012 11:42:58 +0000 Subject: [PATCH 7/7] [master,doc][s]: remove dependency on python-sphinx in core requirements as only needed for docs and updated README with correct sphinx version (>= 1.1). --- README.rst | 2 +- doc/install-from-source.rst | 2 +- pip-requirements-prerelease.txt | 11 ----------- requires/lucid_present.txt | 3 +-- 4 files changed, 3 insertions(+), 15 deletions(-) delete mode 100644 pip-requirements-prerelease.txt diff --git a/README.rst b/README.rst index 4178fe69291..2235d807868 100644 --- a/README.rst +++ b/README.rst @@ -12,7 +12,7 @@ http://ckan.org/. Building Documentation ====================== -1. Install python-sphinx +1. Install python-sphinx (>= 1.1) 2. Initialize the theme submodule:: diff --git a/doc/install-from-source.rst b/doc/install-from-source.rst index 767a9e597cd..5e9f621ca24 100644 --- a/doc/install-from-source.rst +++ b/doc/install-from-source.rst @@ -126,7 +126,7 @@ WebOb has to be installed explicitly afterwards because by installing pylons wit Now to install the remaining dependencies in requires/lucid_present.txt and you are using Ubuntu Lucid 10.04 you can install the system versions:: sudo apt-get install python-pybabel python-psycopg2 python-lxml - sudo apt-get install python-sphinx python-pylons python-repoze.who + sudo apt-get install python-pylons python-repoze.who sudo apt-get install python-repoze.who-plugins python-tempita python-zope.interface Alternatively, if you are not using Ubuntu Lucid 10.04 you'll need to install them like this: diff --git a/pip-requirements-prerelease.txt b/pip-requirements-prerelease.txt deleted file mode 100644 index aa7af689547..00000000000 --- a/pip-requirements-prerelease.txt +++ /dev/null @@ -1,11 +0,0 @@ -# To use this requirements file: (assumes virtualenv at ./pyenv) -# pip -E pyenv install -r pip-requirements.txt - -sphinx<0.9 -psycopg2 --e hg+https://solrpy.googlecode.com/hg#egg=solrpy --e hg+https://bitbucket.org/okfn/vdm#egg=vdm --e hg+https://bitbucket.org/okfn/licenses#egg=licenses --e hg+https://bitbucket.org/okfn/ckanclient@ckanclient-v0.6#egg=ckanclient --e hg+https://bitbucket.org/okfn/ckan@ckan-1.3#egg=ckan - diff --git a/requires/lucid_present.txt b/requires/lucid_present.txt index f2d0bc18312..aabdb0cedad 100644 --- a/requires/lucid_present.txt +++ b/requires/lucid_present.txt @@ -3,13 +3,12 @@ # you can install these dependencies via pip instead. # # sudo apt-get install python-pybabel python-psycopg2 python-lxml -# sudo apt-get install python-sphinx python-pylons python-repoze.who +# sudo apt-get install python-pylons python-repoze.who # sudo apt-get install python-repoze.who-plugins python-tempita python-zope.interface babel==0.9.4 psycopg2==2.0.13 lxml==2.2.4 -sphinx==0.6.4 # Specifying particular version of WebOb because later version has incompatibility # with pylons 0.9.7 (change to imports of Multidict) webob==1.0.8