[ckan-changes] [okfn/ckan] dc8c4e: [2204] Cleanup and api doc

GitHub noreply at github.com
Thu Apr 19 13:59:08 UTC 2012


  Branch: refs/heads/feature-2204-related
  Home:   https://github.com/okfn/ckan
  Commit: dc8c4e967c8db67893b729c4d0e1afc544ab28c8
      https://github.com/okfn/ckan/commit/dc8c4e967c8db67893b729c4d0e1afc544ab28c8
  Author: Ross Jones <rossdjones at gmail.com>
  Date:   2012-04-19 (Thu, 19 Apr 2012)

  Changed paths:
    M ckan/controllers/related.py
    M ckan/lib/dictization/model_dictize.py
    M ckan/logic/action/get.py
    M ckan/templates/_util.html
    M doc/apiv3.rst

  Log Message:
  -----------
  [2204] Cleanup and api doc


diff --git a/ckan/controllers/related.py b/ckan/controllers/related.py
index 2d4c9dc..85042aa 100644
--- a/ckan/controllers/related.py
+++ b/ckan/controllers/related.py
@@ -34,13 +34,3 @@ def list(self, id):
 
         return base.render( "package/related_list.html")
 
-
-
-    def edit(self, id):
-        print 'edit'
-        pass
-
-    def read(self,id,related_id):
-        print 'read'
-        pass
-
diff --git a/ckan/lib/dictization/model_dictize.py b/ckan/lib/dictization/model_dictize.py
index 1367a79..6fc4a34 100644
--- a/ckan/lib/dictization/model_dictize.py
+++ b/ckan/lib/dictization/model_dictize.py
@@ -53,7 +53,7 @@ def related_list_dictize(related_list, context):
         related_dict = related_dictize(res, context)
         result_list.append(related_dict)
 
-    return sorted(result_list, key=lambda x: x["created"])
+    return sorted(result_list, key=lambda x: x["created"], reverse=True)
 
 
 def extras_dict_dictize(extras_dict, context):
diff --git a/ckan/logic/action/get.py b/ckan/logic/action/get.py
index 38614ec..13bd354 100644
--- a/ckan/logic/action/get.py
+++ b/ckan/logic/action/get.py
@@ -163,12 +163,11 @@ def related_list(context, data_dict=None):
     check_access('related_show',context, data_dict)
 
     relateds = model.Related.get_for_dataset(dataset, status='active')
-    related_list = model_dictize.related_list_dictize((r.related for r in relateds), context)
+    related_items = (r.related for r in relateds)
+    related_list = model_dictize.related_list_dictize( related_items, context)
     return related_list
 
 
-
-
 def member_list(context, data_dict=None):
     """
     Returns a list of (id,type,capacity) tuples that are members of the
diff --git a/ckan/templates/_util.html b/ckan/templates/_util.html
index 74b0a38..1b3cec8 100644
--- a/ckan/templates/_util.html
+++ b/ckan/templates/_util.html
@@ -221,9 +221,12 @@
     <table width="100%" border="0" cellpadding="4">
         <tr>
             <td rowspan="2" width="200px">
-                <a href="${related.url}">
+                <a href="${related.url}" py:if="related.image_url">
                     <img src="${related.image_url}" width="200px" border="0"/>
                 </a>
+                <a href="${related.url}" py:if="not related.image_url">
+                    DEFAULT IMAGE
+                </a>
             </td>
             <td><strong>${related.title}</strong></td>
         </tr>
diff --git a/doc/apiv3.rst b/doc/apiv3.rst
index 22624f6..87b294e 100644
--- a/doc/apiv3.rst
+++ b/doc/apiv3.rst
@@ -41,7 +41,7 @@ The basic URL for the Action API is::
  /api/action/{logic_action}
 
 Examples::
- 
+
  /api/action/package_list
  /api/action/package_show
  /api/action/user_create
@@ -54,7 +54,7 @@ get.py:
 ====================================== ===========================
 Logic Action                           Parameter keys
 ====================================== ===========================
-site_read                              (none)                      
+site_read                              (none)
 package_list                           (none)
 current_package_list_with_resources    limit, page
 revision_list                          (none)
@@ -71,6 +71,8 @@ vocabulary_list                        (none)
 package_show                           id
 revision_show                          id
 group_show                             id
+related_show                           id
+related_list                           id
 tag_show                               id
 user_show                              id
 package_show_rest                      id
@@ -87,7 +89,7 @@ roles_show                             domain_object, (user), (authorization_gro
 
 ====================================== ===========================
 
-new.py: 
+create.py:
 
 ====================================== ===========================
 Logic Action                           Parameter keys
@@ -98,6 +100,7 @@ resource_create                        (resource keys)
 package_relationship_create            id, id2, rel, comment
 group_create                           (group keys)
 rating_create                          package, rating
+related_create                         (related keys)
 user_create                            (user keys)
 package_create_rest                    (package keys)
 group_create_rest                      (group keys)
@@ -118,6 +121,7 @@ package_relationship_update            id, id2, rel, comment
 group_update                           (group keys)
 user_update                            (user keys), reset_key
 package_update_rest                    (package keys)
+related_update                         (related keys)
 group_update_rest                      (group keys)
 user_role_update                       user OR authorization_group, domain_object, roles
 user_role_bulk_update                  user_roles, domain_object
@@ -132,6 +136,7 @@ Logic Action                           Parameter keys
 package_delete                         id
 package_relationship_delete            id, id2, rel
 group_delete                           id
+related_delete                         id
 vocabulary_delete                      id
 tag_delete                             id, vocabulary_id
 ====================================== ===========================
@@ -157,7 +162,7 @@ maintainer               null
 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                   []                                      
+extras                   []
 tags                     [{"name": "government-spending"}, {"name": "climate"}] List of tags associated with this dataset.
 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.
@@ -217,9 +222,23 @@ key                      example value                          notes
 ======================== ====================================== =============
 user                     "5ba3985d-447d-4919-867e-2ffe22281c40" Provide exactly one out of "user" and "authorization_group" parameters.
 authorization_group      "16f8f7ba-1a97-4d27-95ce-5e8827a0d75f"
-roles                    ['editor', 'admin']                    
+roles                    ['editor', 'admin']
 ======================== ====================================== =============
 
+Related:
+
+======================== ====================================== =============
+key                      example value                          notes
+======================== ====================================== =============
+id                       "b10871ea-b4ae-4e2e-bec9-a8d8ff357754" (Read-only)
+title                     "A new visualization"                 (Read-only)
+type                      "Visualization"                       (Read-only)
+description               "Describing the visualization"        (Read-only)
+url                       "http://invent.ge/HKjuyc"             (Read-only) Where the item can be found
+image_url                 "http://invent.ge/IR5r7W"             (Read-only) An optional image showing the item
+======================== ====================================== =============
+
+
 Vocabulary:
 
 ======================== ===================================================== =============
@@ -310,17 +329,17 @@ Here are the methods of the Search API.
 
 +-------------------------------+--------+------------------------+--------------------------+
 | Resource                      | Method | Request                | Response                 |
-+===============================+========+========================+==========================+ 
-| Dataset Search                | POST   | Dataset-Search-Params  | Dataset-Search-Response  | 
++===============================+========+========================+==========================+
+| Dataset Search                | POST   | Dataset-Search-Params  | Dataset-Search-Response  |
 +-------------------------------+--------+------------------------+--------------------------+
-| Resource Search               | POST   | Resource-Search-Params | Resource-Search-Response | 
+| Resource Search               | POST   | Resource-Search-Params | Resource-Search-Response |
 +-------------------------------+--------+------------------------+--------------------------+
-| Revision Search               | POST   | Revision-Search-Params | Revision-List            | 
+| Revision Search               | POST   | Revision-Search-Params | Revision-List            |
 +-------------------------------+--------+------------------------+--------------------------+
-| Tag Counts                    | GET    |                        | Tag-Count-List           | 
+| Tag Counts                    | GET    |                        | Tag-Count-List           |
 +-------------------------------+--------+------------------------+--------------------------+
 
-It is also possible to supply the search parameters in the URL of a GET request, 
+It is also possible to supply the search parameters in the URL of a GET request,
 for example ``/api/search/dataset?q=geodata&allfields=1``.
 
 Search Formats
@@ -332,7 +351,7 @@ Here are the data formats for the Search API.
 | Name                    | Format                                                     |
 +=========================+============================================================+
 | Dataset-Search-Params   | { Param-Key: Param-Value, Param-Key: Param-Value, ... }    |
-| Resource-Search-Params  | See below for full details of search parameters across the | 
+| Resource-Search-Params  | See below for full details of search parameters across the |
 | Revision-Search-Params  | various domain objects.                                    |
 +-------------------------+------------------------------------------------------------+
 | Dataset-Search-Response | { count: Count-int, results: [Dataset, Dataset, ... ] }    |
@@ -423,7 +442,7 @@ These parameters are all the standard SOLR syntax (in contrast to the syntax use
 
 +-----------------------+---------------+-----------------------------------------------------+----------------------------------+
 | Param-Key             | Param-Value   | Example                                             |  Notes                           |
-+=======================+===============+=====================================================+==================================+ 
++=======================+===============+=====================================================+==================================+
 | since_time            | Date-Time     | since_time=2010-05-05T19:42:45.854533               | The time can be less precisely   |
 |                       |               |                                                     | stated (e.g 2010-05-05).         |
 +-----------------------+---------------+-----------------------------------------------------+----------------------------------+
@@ -450,7 +469,7 @@ The Search API returns standard HTTP status codes to signal method outcomes:
 ===== =====
 Code  Name
 ===== =====
-200   OK                 
+200   OK
 201   OK and new object created (referred to in the Location header)
 301   Moved Permanently (redirect)
 400   Bad Request


================================================================



More information about the ckan-changes mailing list