Skip to content

draft: User 'ownsOrg' value

james kiger requested to merge add-owns_org-user-detail into master

related to glitchtip#27

I have previously updated the frontend to enable superusers to create new organizations when ENABLE_USER_REGISTRATION is set to false. However, our backend permissions also allow users who own an organization to create new orgs. This is not reflected on the frontend.

The problem I'm attempting to solve here is that the frontend needs to know if a user owns at least one organization to determine whether or not this user has permission to create a new organization. And the frontend does not pull in the kind of data it would need to determine this on its own (i.e. an array of a user's orgs with either sub-arrays of org members and roles or just the user's role).

My solution here is to make this determination on the backend in the user serializer so when api/0/users/me is called the frontend will now get a boolean value indicating whether or not the user owns at least one org.

In terms of queries, this only adds one _set query per user and unless I'm reading the code wrong (possible), I think even the list view only ever returns one user. I wasn't sure if I should look into optimization under the circumstances.

I'm also not sure about the name ownsOrg. I was divided between that and "orgOwner".

Edited by james kiger

Merge request reports