Skip to content

Commit

Permalink
components: cancel request instead of accept when deleting draft
Browse files Browse the repository at this point in the history
* some of the default status values were missing for `status_from`
  • Loading branch information
rekt-hard committed Sep 23, 2024
1 parent 7605c3a commit 89ee3bd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions invenio_curations/requests/curation.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,18 @@ class CurationCancelAction(actions.CancelAction):
"""Cancel a request."""

# A user might want to cancel their request.
status_from = ["submitted", "critiqued", "resubmitted"]
# Also done when a draft for an already published record is deleted/discarded
status_from = [
"accepted",
"cancelled",
"created",
"critiqued",
"declined",
"expired",
"resubmitted",
"review",
"submitted",
]


class CurationExpireAction(actions.ExpireAction):
Expand All @@ -136,6 +147,8 @@ class CurationDeleteAction(actions.DeleteAction):
"""Delete a request."""

# When a user deletes their draft, the request will get deleted. Should be possible from every state.
# Usually delete is only possible programmatically, as the base permissions allow user driven deletion
# only during `created` status
status_from = [
"accepted",
"cancelled",
Expand All @@ -147,7 +160,6 @@ class CurationDeleteAction(actions.DeleteAction):
"review",
"submitted",
]
status_to = "deleted"


class CurationReviewAction(actions.RequestAction):
Expand Down
2 changes: 1 addition & 1 deletion invenio_curations/services/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def delete_draft(self, identity, draft=None, record=None, force=False):
# Delete draft for a published record.
# Since only one request per record should exist, it is not deleted. Instead, put it back to accepted.
current_requests_service.execute_action(
system_identity, request["id"], "accept"
system_identity, request["id"], "cancel"
)

def update_draft(self, identity, data=None, record=None, errors=None):
Expand Down

0 comments on commit 89ee3bd

Please sign in to comment.