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

Add endpoint for getting a role's users #1576

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

robines
Copy link
Member

@robines robines commented Oct 31, 2024

Role is basically just a group of permissions. It's not directly tied to users. To tie a role to a user, one must use either UserOrgRole, UserGangRole, or UserGangSectionRole. This will give the role to the user on a specific hierarchical level (on a specific object instance of an Organization, Gang or Section).

This PR adds an endpoint which gets all UserOrgRole/UserGangRole/UserGangSectionRoles and their users, based on the specified role id. The object is also fetched, meaning we can easily it in frontend.

Response looks something like:

[
  {
    "user": UserDto,
    // org_role when role is given on Org level, gang_role for Gang, and section_role for Section
    "gang_role": {
      "created_at": "2024-10-29T23:37:39.950095Z",
      "created_by": UserDto, // Who gave the role
      // organization when org_role, gang when gang_role, section when section_role
      "gang": {
        "id": 4,
        "name_nb": "Markedsføringsgjengen",
        "name_en": "Markedsføringsgjengen",
        "abbreviation": "MG",
        ...
      }
    }
  },
  ...
]

@robines robines added the backend Task related to backend. label Oct 31, 2024
@robines robines self-assigned this Oct 31, 2024
@robines robines mentioned this pull request Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Task related to backend.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant