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

Allow users to have additional organisations #2454

Conversation

benshimmin
Copy link
Contributor

This creates a has_and_belongs_to_many join table relationship between organisations and users, allowing a user to belong to additional_organisations and paves the way to allowing a user to set their organisation to be a Current.organisation and thus view data for that organisation instead of their own "real" organisation.

This should change nothing about the existing functionality of the site and will be entirely invisible to end users. (The next phase will include front-end changes which will allow selected users to switch their current organisation.)

Helper methods on the User model to navigate this relationship include primary_organisation (to retrieve the user's actual organisation, which is necessarily overwritten), all_organisations (the union of primary_organisation and additional_organisations) and additional_organisations? (to determine whether a user has a non-zero number of additional_organisations).

Next steps

  • Is an ADR required? An ADR should be added if this PR introduces a change to the architecture.
  • Is a changelog entry required? An entry should always be made in CHANGELOG.md, unless this PR is a small tweak which has no impact outside the development team.
  • Do any environment variables need amending or adding?
  • Have any changes to the XML been checked with the IATI validator? See XML Validation

@benshimmin benshimmin marked this pull request as ready for review December 5, 2024 09:48
@benshimmin benshimmin force-pushed the feature/data-migration-to-allow-users-to-have-additional-organisations branch 3 times, most recently from 152c3b4 to aa7df87 Compare December 6, 2024 10:14
This creates a `has_and_belongs_to_many` join table relationship between
organisations and users, allowing a user to belong to
`additional_organisations` and paves the way to allowing a user to set their
`organisation` to be a `Current.user_organisation` and thus view data for that
organisation instead of their own "real" organisation.

This should change nothing about the existing functionality of the site and
will be entirely invisible to end users. (The next phase will include
front-end changes which *will* allow selected users to switch their current
organisation.)

Helper methods on the `User` model to navigate this relationship include
`primary_organisation` (to retrieve the user's actual `organisation`, which
is necessarily overwritten), `all_organisations` (the union of
`primary_organisation` and `additional_organisations`) and
`additional_organisations?` (to determine whether a user has a non-zero
number of `additional_organisations`).
@benshimmin benshimmin force-pushed the feature/data-migration-to-allow-users-to-have-additional-organisations branch from aa7df87 to 12a2413 Compare December 6, 2024 10:18
@benshimmin benshimmin closed this Dec 6, 2024
@benshimmin benshimmin deleted the feature/data-migration-to-allow-users-to-have-additional-organisations branch December 6, 2024 10:28
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.

1 participant