Skip to content

Commit

Permalink
Merge pull request #24 from datopian/dcat-form-updates
Browse files Browse the repository at this point in the history
Update dataset form for latest DCAT change requests
  • Loading branch information
luccasmmg authored Jul 19, 2024
2 parents ad86caa + 724a825 commit f791022
Show file tree
Hide file tree
Showing 12 changed files with 652 additions and 394 deletions.
32 changes: 19 additions & 13 deletions ckanext/portalopendatadk/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ def package_create(context, data_dict):
if not data_dict.get(field):
errors[field] = [_('Missing value')]

documentation = data_dict.get("documentation")
data_dict['url'] = documentation

log.debug(
'package_create validate_errs=%r user=%s package=%s data=%r',
errors,
Expand Down Expand Up @@ -274,13 +277,13 @@ def package_create(context, data_dict):

# We have to do this after save so the package id is available.
# If this fails, we have to rollback the transaction.
try:
data_dict['url'] = data_dict.get('documentation')
upload = uploader.get_resource_uploader(data_dict)
upload.upload(pkg.id, uploader.get_max_resource_size())
except Exception as e:
model.Session.rollback()
raise ValidationError({'upload': [_('Documentation upload failed: {}').format(e)]})
if documentation and 'http' not in documentation:
try:
upload = uploader.get_resource_uploader(data_dict)
upload.upload(pkg.id, uploader.get_max_resource_size())
except Exception as e:
model.Session.rollback()
raise ValidationError({'upload': [_('Documentation upload failed: {}').format(e)]})

# Needed to let extensions know the package and resources ids
model.Session.flush()
Expand Down Expand Up @@ -406,12 +409,15 @@ def package_update(context, data_dict):
if not data_dict.get(field):
errors[field] = [_('Missing value')]

try:
data_dict['url'] = data_dict.get('documentation')
upload = uploader.get_resource_uploader(data_dict)
upload.upload(data_dict['id'], uploader.get_max_resource_size())
except Exception as e:
errors['upload'] = [_('Upload failed: %s') % str(e)]
documentation = data_dict.get('documentation')
data_dict["url"] = documentation

if documentation and 'http' not in documentation:
try:
upload = uploader.get_resource_uploader(data_dict)
upload.upload(data_dict['id'], uploader.get_max_resource_size())
except Exception as e:
errors['upload'] = [_('Upload failed: %s') % str(e)]

log.debug(
'package_update validate_errs=%r user=%s package=%s data=%r',
Expand Down
168 changes: 120 additions & 48 deletions ckanext/portalopendatadk/dcat/data_themes_skos.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion ckanext/portalopendatadk/dcat/dcat_info_text.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
"url": "Distribution (mandatory): Provides a file or link to the resource (distribution) of the dataset. The property can appear once for each distribution.",
"planned_availability": "Planned Availability (recommended): Specifies availability type of the resource (distribution). It can appear once for each distribution.",
"license_id": "License (recommended): Specifies the license of the resource (distribution). It can appear once for each distribution.",
"format": "Format (mandatory if distribution exists): Specifies the file format of the resource (distribution). It can appear once for each distribution."
"format": "Format (mandatory if distribution exists): Specifies the file format of the resource (distribution). It can appear once for each distribution.",
"data_themes": "Data Themes (recommended): Specifies the Data Themes (Categories) of the dataset. Multiple Data Themes can be assigned to a dataset."
}
Loading

0 comments on commit f791022

Please sign in to comment.