stats4sd / aec_portfolio

A proof of concept for the AEC Consortium Project Management / Assessment System
GNU General Public License v3.0
0 stars 0 forks source link

Add Existing User to Institution Directly #241

Closed dan-tang-ssd closed 8 months ago

dan-tang-ssd commented 9 months ago

NOTE

There is a minor change to add a flag to indicate "contribute to funding flow" in portfolio level. The program change is committed to dev branch accidentally. This minor change will be reviewed when we create a PR for live env deployment. That PR will include all delta changes between dev branch and main branch.


This PR is submitted to add existing user to institution directly.

This PR contains below changes in backend:

  1. For email address not existed in existing users, use original workflow to send email invitation.
  2. For email address that existed in existing users, do below if user not belong to the institution 2.1 Send email confirmation instead of email invitation, it is not required to register again 2.2 Add role_invites record for reference purpose 2.3 Add organisation_members record, user will be added to institution immediately

Potential Change:

There are three possible roles for institutional user:

The user role is defined in user account level now. (i.e. model_has_roles table) This is not defined in institution member level. (i.e. organisation_members)

In other words, one login account can have one role only. For example:

  1. New user A has been invited to join institution Stats4SD as Institutional Assesser
  2. New user A registered login account, system assigned role Institutional Assesser to user A
  3. Existing user A has been invited to join institution ICRAF as another role, e.g. Institutional Member
  4. Existing user A will be added to institution ICRAF directly, but the role is Institutional Assesser instead of Institutional Member

In Invite members page, when we fill in an email address for an existing user, the selected role will have no effect. This is not ideal, but I am not sure whether this PR is now good enough to fulfill user's need at this moment.


If we need to support different role in different institution, more refinement work and testings are required. E.g.

  1. Move role from table model_has_roles to organisation_members
  2. Play around with Backpack permission manager, probably it may not be very straight forward to do our required change
  3. Prepare data migration for existing users in live env

I would recommend:

  1. Check whether institution level role is required or not
  2. If it is required, can we do it in version 2.0?