Skip to content

Commit 56f89f5

Browse files
authored
Merge pull request #213 from GSA/modify-metadata-source-links
Modify metadata source links
2 parents e840772 + 84efd63 commit 56f89f5

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

ckanext/datagovtheme/helpers.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -326,18 +326,24 @@ def format_type(format_name):
326326
}
327327

328328

329-
def get_harvest_source_link(package_dict):
329+
def get_harvest_source_link(package_dict, type='source'):
330330
harvest_source_id = get_pkg_dict_extra(package_dict, 'harvest_source_id', None)
331331
harvest_source_title = get_pkg_dict_extra(package_dict, 'harvest_source_title', None)
332+
harvest_object_id = get_pkg_dict_extra(package_dict, 'harvest_object_id', None)
333+
harvest_admin_url = config.get('ckanext.datagovtheme.harvest_admin_url')
332334

333335
if harvest_source_id and harvest_source_title:
334336
msg = p.toolkit._('Harvested from')
335337
harvest_next = asbool(config.get('ckanext.datagovtheme.harvest_next', 'false'))
336-
if harvest_next:
337-
url = h.url_for(f'/harvest/{harvest_source_id}')
338+
if type == 'metadata':
339+
url = f"{harvest_admin_url}/harvest_record/{harvest_object_id}/raw"
340+
link = '<a href="{url}">{title}</a>'.format(url=url, title='Download Metadata')
338341
else:
339-
url = h.url_for('harvest_read', id=harvest_source_id)
340-
link = '{msg} <a href="{url}">{title}</a>'.format(url=url, msg=msg, title=harvest_source_title)
342+
if harvest_next:
343+
url = f"{harvest_admin_url}/harvest_source/{harvest_source_id}"
344+
else:
345+
url = h.url_for('harvest_read', id=harvest_source_id)
346+
link = '{msg} <a href="{url}">{title}</a>'.format(url=url, msg=msg, title=harvest_source_title)
341347
return p.toolkit.literal(link)
342348

343349
return ''

ckanext/datagovtheme/templates/package/read.html

+1-3
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,7 @@ <h3>{{ _('Metadata Source') }}</h3>
247247
{{ ho_formats.object_format }} Metadata
248248
{% endif %}
249249
</strong>
250-
<p class="description">
251-
<a href="/harvest/object/{{ harvest_object_id }}">Download Metadata</a>
252-
</p>
250+
<p class="description">{{ h.get_harvest_source_link(pkg, 'metadata') }}</p>
253251
</li>
254252
{% if ho_formats.original_format %}
255253
<li class="resource-item">

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ lxml>=2.3
2121
argparse
2222
pyparsing>=2.1.10
2323
requests>=1.1.0
24-
pyproj
24+
pyproj==3.6.1
2525
Shapely==2.0.1
2626
numpy==1.26.4
2727
OWSLib==0.28.1

0 commit comments

Comments
 (0)