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

rest: invalid deposit class detection when missing pid_value view argument causes missing action "links" #167

Open
slint opened this issue May 9, 2017 · 0 comments

Comments

@slint
Copy link
Member

slint commented May 9, 2017

On POST calls, since request.view_args['pid_value'] is not part of the url (/api/deposit/depositions), the detected deposit class always falls back to invenio_deposit.api.Deposit, causing any additional action links added using the invenio_deposit.urils.mark_as_action decorator to be skipped.

Perhaps adding a pid_type -> deposit_class mapping as part of a current_records_rest.default_pid_classes might help to determine the desired default:

deposit_cls = current_records_rest.default_pid_classes.get(pid.pid_type, Deposit)
if 'pid_value' in request.view_args:
    deposit_cls = request.view_args['pid_value'].data[1].__class__

Update: This issue leads to incorrect links generation which is extremely problematic when there are additional actions implemented in a deposit class, and responses have to be consumed by a Javascript UI application. Example:

  1. (assume we have a custom deposit class with a MyDeposit.custom_action)
  2. Client does POST /api/deposit/depositions, gets back depid: 1234 and links with missing custom_action link.
  3. Client wants to perform custom_action, but link is missing...
  4. Client "reloads" the page (i.e. refetches /api/deposit/depositions/1234), which now contains the missing custom_action link.
@slint slint added the Type: bug label May 9, 2017
@slint slint changed the title rest: invalid deposit class detection when missing pid_value view argument rest: invalid deposit class detection when missing pid_value view argument causes missing action "links" Sep 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant