-
Notifications
You must be signed in to change notification settings - Fork 2
User Lab Assignment
Variant Classification records are created under a lab. To be able to create records for a lab, there's not currently a lab user association but it is done by assigning a user to a group that happens to align to a lab's group_name field.
This was primarily done for being able to assign users to labs via OAuth (see backend.py)
Lab groups are currently
<institution>/<lab>/(head)
Rather than pre-define the groups, if we define the Labs via the admin tool, the groups will be automatically created. If you create a Lab with a "group_name" field of sa_pathology/familial_cancer_frome the following groups will be auto-created if they don't already exist
sa_pathology
sa_pathology/familial_cancer_frome
-
sa_pathology/familial_cancer_frome/head
then repeat for the other labs.
Also note that the current_lab
in user settings is set on login from keycloak, see UserSettings auto_set_current_lab. Note that if current lab is already set to a valid value for the user, this method wont override that. (also as of now that field isn't used, but it will be soon as a default).
Now to assign people to a lab, assign them to the most specific relevant group, and each group below. e.g. if they're a regular lab member for Familial Cancer assign them to
-
sa_pathology/familial_cancer_frome
and sa_pathology
If they're the head of that lab assign them to
-
sa_pathology/familial_cancer_frome/head
and -
sa_pathology/familial_cancer_frome
and -
sa_pathology
Note that the OAuth login automatically assigns to groups in the hierarchy, but for regular Django login you need to make sure you manually set it.
# requires "default_lab" be set if they have multiple labs
user_settings.get_lab()
# Return users for a lab
for user in lab.lab_users:
pass
# Return labs for a user
for lab in Lab.valid_labs_qs(user: User):
pass