Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[resource] Resource edit page integration #37

Closed
9 of 10 tasks
rufuspollock opened this issue Sep 21, 2020 · 5 comments
Closed
9 of 10 tasks

[resource] Resource edit page integration #37

rufuspollock opened this issue Sep 21, 2020 · 5 comments
Assignees

Comments

@rufuspollock
Copy link
Member

rufuspollock commented Sep 21, 2020

Have DataPub work for resource edit as well as resource create

This issue will probably require changes both here and in ckanext-blob-storage to pass in the details of the existing resource (either just the resource id (and dataset id?) and then DataPub code looks up the resource object from the API or by passing in complete JSON object).

Acceptance

Resource edit page works correctly

  • You can visit the page, edit metadata or schema and save
  • You can remove existing data file or link
  • You can then add a new one (including re-inferring schema and other metadata (??) TODO: work out correct behaviour)

Tasks

  • Have DataPub take over resource edit page (ckanext-blob-storage)
    • Have DataPub passed the right info by CKAN v2 system
  • Add state attribute to DataPub to indicate whether in create or edit mode (create is default)
  • Call resource_update rather than resource create
  • Pass in the resource object
  • Support for removing existing resource
  • Redirect to dataset page on save (like for resource create)
mariorodeghiero added a commit that referenced this issue Sep 23, 2020
@mariorodeghiero mariorodeghiero self-assigned this Sep 24, 2020
@mariorodeghiero
Copy link
Contributor

  • re-inferring and change metadata is OK

@rufuspollock

For re-inferring and change schema we have a problem. Because the result of the resource_show for schema and sample is a string with unicode like the code below and I need this information as a JSON to be able to render in tableschema component.

"{u'fields': [{u'type': u'string', u'name': u'Series_reference', u'format': u'default'}, {u'type': u'number', u'name': u'Period', u'format': u'default'}, {u'type': u'integer', u'name': u'Data_value', u'format': u'default'}, {u'type': u'string', u'name': u'STATUS', u'format': u'default'}, {u'type': u'string', u'name': u'UNITS', u'format': u'default'}, {u'type': u'integer', u'name': u'MAGNTUDE', u'format': u'default'}, {u'type': u'string', u'name': u'Subject', u'format': u'default'}, {u'type': u'string', u'name': u'Group', u'format': u'default'}, {u'type': u'string', u'name': u'Series_title_1', u'format': u'default'}, {u'type': u'string', u'name': u'Series_title_2', u'format': u'default'}, {u'type': u'string', u'name': u'Series_title_3', u'format': u'default'}, {u'type': u'string', u'name': u'Series_title_4', u'format': u'default'}, {u'type': u'string', u'name': u'Series_title_5', u'format': u'default'}], u'missingValues': [u'']}"

I tried to manage to create a regex and parse to a JSON object into a try catch but it works for some contents but fails for others. So the user can't see and edit the schema for some resources.

Solution:

As Anuar said on the chat, maybe we can create a new CKAN api action custom_resoruce_show for this to return the schema as JSON not as string. Or to override resource_show method in the extension.

cc: @anuveyatsu @mbeilin @Daniellappv

@mbeilin
Copy link
Contributor

mbeilin commented Sep 29, 2020

  • re-inferring and change metadata is OK

@rufuspollock

For re-inferring and change schema we have a problem. Because the result of the resource_show for schema and sample is a string with unicode like the code below and I need this information as a JSON to be able to render in tableschema component.

"{u'fields': [{u'type': u'string', u'name': u'Series_reference', u'format': u'default'}, {u'type': u'number', u'name': u'Period', u'format': u'default'}, {u'type': u'integer', u'name': u'Data_value', u'format': u'default'}, {u'type': u'string', u'name': u'STATUS', u'format': u'default'}, {u'type': u'string', u'name': u'UNITS', u'format': u'default'}, {u'type': u'integer', u'name': u'MAGNTUDE', u'format': u'default'}, {u'type': u'string', u'name': u'Subject', u'format': u'default'}, {u'type': u'string', u'name': u'Group', u'format': u'default'}, {u'type': u'string', u'name': u'Series_title_1', u'format': u'default'}, {u'type': u'string', u'name': u'Series_title_2', u'format': u'default'}, {u'type': u'string', u'name': u'Series_title_3', u'format': u'default'}, {u'type': u'string', u'name': u'Series_title_4', u'format': u'default'}, {u'type': u'string', u'name': u'Series_title_5', u'format': u'default'}], u'missingValues': [u'']}"

I tried to manage to create a regex and parse to a JSON object into a try catch but it works for some contents but fails for others. So the user can't see and edit the schema for some resources.

Solution:

As Anuar said on the chat, maybe we can create a new CKAN api action custom_resoruce_show for this to return the schema as JSON not as string. Or to override resource_show method in the extension.

cc: @anuveyatsu @mbeilin @Daniellappv

@anuveyatsu @shevron guys, any thoughts about this?
As far as I understand from @mariorodeghiero, that should be resolved in ckan-blob-storage, so he can move
forward in datapub. We are kind of blocked with this in NHS atm, missing the ability to update schema in resource...
cc: @Daniellappv

@anuveyatsu
Copy link
Member

anuveyatsu commented Sep 29, 2020

There are 2 options:

  1. Quick and hacky: create custom_resource_show API action as mentioned in the previous comment (est 2h)
  2. Change schema using https://github.com/ckan/ckanext-scheming (est 5-6h)

cc @mbeilin

@mariorodeghiero
Copy link
Contributor

I created an issue in ckan-blob-storage datopian/ckanext-blob-storage#29

@mariorodeghiero
Copy link
Contributor

FIXED. It was fixed in this PR #52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants