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

ANW-1341: Display user-friendly message when trying to delete an agent linked to a user #3035

Conversation

andrew-morrison
Copy link
Contributor

@andrew-morrison andrew-morrison commented Aug 22, 2023

Replacement for #3030 submitted from a fresh fork, which doesn't have commits from GitHub Actions automatically run on the other fork.

Description

Check whether an agent is linked to a user before deleting, rather than letting it fail if it violates a foreign key constraint.

Related JIRA Ticket or GitHub Issue

https://archivesspace.atlassian.net/browse/ANW-1341

How Has This Been Tested?

  1. Log in to staff interface.
  2. Find an agent which corresponds to a user.
  3. Click the delete button.

It correctly fails to delete, as before, but the message displayed is, in English...

Record cannot be deleted as it is linked to a user

...rather than...

Record deletion failed: Java::JavaSql::SQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (archivesspace.user, CONSTRAINT user_ibfk_1 FOREIGN KEY (agent_record_id) REFERENCES agent_person (id))`

Attempting to delete a user's agent via the API return a 409 response:

{'error': 'linked_to_user'}

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have read the CONTRIBUTING document.
  • I have authority to submit this code.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@andrew-morrison
Copy link
Contributor Author

The test failures appear to be unrelated to this pull request.

@cdibella cdibella added the community code contributed by community members not on or contracted by the ArchivesSpace program team label Aug 28, 2023
@donaldjosephsmith donaldjosephsmith merged commit 07cfaf2 into archivesspace:master Sep 22, 2023
10 checks passed
@cdibella cdibella added this to the 3.5.0 milestone Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community code contributed by community members not on or contracted by the ArchivesSpace program team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants