astrosat / django-astrosat-users

Common backend library for Astrosat projects' user management
GNU General Public License v3.0
2 stars 0 forks source link

serialize roles & permissions separately when serializing a User #12

Closed allynt closed 4 years ago

allynt commented 4 years ago

Is your feature request related to a problem? Please describe

Currently, the default UserRoleSerializer is used when serializing users. This produces a list of objects:

"roles": [
        {
            "id": 1,
            "name": "ManagerRole",
            "description": "",
            "permissions": [
                {
                    "id": 1,
                    "name": "can_do_important_stuff",
                    "description": ""
                }
            ]
        }
    ]

This is probably overkill for the frontend.

Describe the solution you'd like

Instead I should just output a list of the role & permission names:

"roles": [ "ManagerRole"],
"permissions": ["name": "can_do_important_stuff"],

These will probably be SerializerMethodField.

Additional context

Note that this means that updating a User's roles will be done via another endpoint.

allynt commented 4 years ago

fixed by #13