Skip to content

Commit

Permalink
reg: override not good idea
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Nov 25, 2024
1 parent 5682efb commit 40900e3
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions ckanext/dcor_schemas/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,19 @@ def admin_context():

def get_base_metadata(resource):
res_dict_base = {}
if not resource.get("mimetype"):
suffix = "." + resource["name"].rsplit(".", 1)[-1]
for mt in DC_MIME_TYPES:
if suffix in DC_MIME_TYPES[mt]:
res_dict_base["mimetype"] = mt
break
suffix = "." + resource["name"].rsplit(".", 1)[-1]
for mt in DC_MIME_TYPES:
if suffix in DC_MIME_TYPES[mt]:
res_dict_base["mimetype"] = mt
break

# Also make sure the resource has "url" defined.
if not resource.get("url"):
site_url = get_ckan_config_option("ckan.site_url")
meta_url = (f"{site_url}"
f"/dataset/{resource['package_id']}"
f"/resource/{resource['id']}"
f"/download/{resource['name'].lower()}")
res_dict_base["url"] = meta_url
site_url = get_ckan_config_option("ckan.site_url")
meta_url = (f"{site_url}"
f"/dataset/{resource['package_id']}"
f"/resource/{resource['id']}"
f"/download/{resource['name'].lower()}")
res_dict_base["url"] = meta_url
return res_dict_base


Expand Down

0 comments on commit 40900e3

Please sign in to comment.