Skip to content

Prevent deletion of last user from a reporting organisation#72

Merged
simon-20 merged 6 commits intodevelopfrom
sk-fix-prevent-delete-removing-all-users
Mar 24, 2026
Merged

Prevent deletion of last user from a reporting organisation#72
simon-20 merged 6 commits intodevelopfrom
sk-fix-prevent-delete-removing-all-users

Conversation

@simon-20
Copy link
Copy Markdown
Contributor

@simon-20 simon-20 commented Mar 23, 2026

This PR:

  • Refactors the assert_precondition_met function and the RYDUserException class, removing their dependencies on rich context objects, and making them depend only on primitive values they require - this should make it easier to test.
  • Adds tests to check the the last user and the last admin user of an org can't be deleted.
  • Implements checks to ensure that the last user and last admin users cannot be deleted.

NOTE: this PR is setup as a compare against the sk-search-discoverable-orgs branch - the pre-existing PR for that branch (#70) should be merged and this branch rebased onto develop before merging this.

This should close issues #47 and #71.

@simon-20 simon-20 requested a review from a team March 23, 2026 16:11
@simon-20 simon-20 changed the title Sk fix prevent delete removing all users Prevent deletion of last user from a reporting organisation Mar 23, 2026
This refactor removes the unused context parameter from the
assert_precondition_met function, decoupling this utility function
from the app context object.
This refactoring removes from the RYDUserException class the
dependency on the UserAndCredentials object, making it depend
only on the fields it uses, which should facilitate easier testing.
This refactoring removes from the assert_precondition_met function
dependence on the UserAndCredentials object, making it depend
only on the fields it uses, which should facilitate easier testing
This commit adds two checks to ensure that the user being
deleted from an organisation isn't the last user or last admin
user belonging to the org. Closes #47 and #71.
@simon-20 simon-20 force-pushed the sk-fix-prevent-delete-removing-all-users branch from 33e5b86 to 6c86f5c Compare March 24, 2026 11:24
@simon-20 simon-20 changed the base branch from sk-search-discoverable-orgs to develop March 24, 2026 11:25
@simon-20 simon-20 merged commit 8e02d2c into develop Mar 24, 2026
5 checks passed
@simon-20 simon-20 deleted the sk-fix-prevent-delete-removing-all-users branch March 24, 2026 11:26
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

Successfully merging this pull request may close these issues.

2 participants