[ckan-changes] commit/ckanext-dgu: 2 new changesets
Bitbucket
commits-noreply at bitbucket.org
Mon Nov 14 15:51:39 UTC 2011
2 new commits in ckanext-dgu:
https://bitbucket.org/okfn/ckanext-dgu/changeset/f7f40e3a5da9/
changeset: f7f40e3a5da9
user: amercader
date: 2011-11-14 16:35:39
summary: [gemini,api] Change the GEMINI links on the dataset page
The API now uses the harvest_object_id extra from the dataset to
link to the source GEMINI document.
affected #: 2 files
diff -r 81e0d18153e3ec4234f4320e7c0fc0cd382249c0 -r f7f40e3a5da9c15e28337d52f6d469c27a357f32 ckanext/dgu/forms/html.py
--- a/ckanext/dgu/forms/html.py
+++ b/ckanext/dgu/forms/html.py
@@ -1,14 +1,14 @@
GEMINI_CODE="""
<tr><td>
- <a href="/api/2/rest/harvestobject/%(guid)s/xml" target="_blank">Source GEMINI2 document</a>
+ <a href="/api/2/rest/harvestobject/%(id)s/xml" target="_blank">Source GEMINI2 document</a></td><td>XML</td><td></td></tr><tr><td>
- <a href="/api/2/rest/harvestobject/%(guid)s/html" target="_blank">Formatted GEMINI2 document</a>
+ <a href="/api/2/rest/harvestobject/%(id)s/html" target="_blank">Formatted GEMINI2 document</a></td><td>HTML</td><td></td>
diff -r 81e0d18153e3ec4234f4320e7c0fc0cd382249c0 -r f7f40e3a5da9c15e28337d52f6d469c27a357f32 ckanext/dgu/stream_filters.py
--- a/ckanext/dgu/stream_filters.py
+++ b/ckanext/dgu/stream_filters.py
@@ -8,14 +8,11 @@
import ckanext.dgu.forms.html as html
def harvest_filter(stream, pkg):
- # We need the guid from the HarvestedObject!
- doc = Session.query(HarvestObject). \
- filter(HarvestObject.package_id==pkg.id). \
- order_by(HarvestObject.metadata_modified_date.desc()). \
- order_by(HarvestObject.gathered.desc()). \
- limit(1).first()
- if doc:
- data = {'guid': doc.guid}
+
+ harvest_object_id = pkg.extras.get('harvest_object_id')
+ if harvest_object_id:
+
+ data = {'id': harvest_object_id}
html_code = html.GEMINI_CODE
if len(pkg.resources) == 0:
# If no resources, the table has only two columns
@@ -23,5 +20,6 @@
stream = stream | Transformer('body//div[@class="resources subsection"]/table')\
.append(HTML(html_code % data))
+
return stream
https://bitbucket.org/okfn/ckanext-dgu/changeset/9269251e1c98/
changeset: 9269251e1c98
user: amercader
date: 2011-11-14 16:51:24
summary: [ui] Show dataset ID on the UI
affected #: 3 files
diff -r f7f40e3a5da9c15e28337d52f6d469c27a357f32 -r 9269251e1c983cc3986500ee34c950b85b7ecc03 ckanext/dgu/forms/html.py
--- a/ckanext/dgu/forms/html.py
+++ b/ckanext/dgu/forms/html.py
@@ -14,3 +14,10 @@
<td></td></tr>
"""
+
+DATASET_ID_CODE="""
+<li>
+ <h3>ID</h3>
+ %(id)s
+</li>
+"""
diff -r f7f40e3a5da9c15e28337d52f6d469c27a357f32 -r 9269251e1c983cc3986500ee34c950b85b7ecc03 ckanext/dgu/plugin.py
--- a/ckanext/dgu/plugin.py
+++ b/ckanext/dgu/plugin.py
@@ -122,4 +122,6 @@
if is_inspire and is_inspire[0] == 'True':
stream = stream_filters.harvest_filter(stream, c.pkg)
+ # Add dataset id to the UI
+ stream = stream_filters.package_id_filter(stream, c.pkg)
return stream
diff -r f7f40e3a5da9c15e28337d52f6d469c27a357f32 -r 9269251e1c983cc3986500ee34c950b85b7ecc03 ckanext/dgu/stream_filters.py
--- a/ckanext/dgu/stream_filters.py
+++ b/ckanext/dgu/stream_filters.py
@@ -23,3 +23,13 @@
return stream
+def package_id_filter(stream, pkg):
+
+ data = {'id': pkg.id}
+ html_code = html.DATASET_ID_CODE
+
+ stream = stream | Transformer('body//ul[@class="property-list"]')\
+ .append(HTML(html_code % data))
+
+ return stream
+
Repository URL: https://bitbucket.org/okfn/ckanext-dgu/
--
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