Adding Custom System Roles in Open Event Server
In this blog, we will talk about how to add different custom system roles concerning a user on Open Event Server. The focus is on its model and Schema updation.
For the User Table, we’ll update our User Model as follows:
Now, let’s try to understand these hybrid properties.
In this feature, we are providing Admin the rights to see whether a user is acting as a Marketer and / or Sales Admin of any of the event or not. Here, _is__system_role method is used to check whether an user plays a system role like Marketer, Sales Admin or not. This is done by querying the record from UserSystemRole model. If the record is present then the returned value is True otherwise false.
For the User Model, we’ll update our Schema as follows:
Now, let’s try to understand this Schema.
Since all the properties will return either True or false so these all properties are set to Boolean in Schema.Here dump_only means, we will return this property in the Schema.
So, we saw how User Model and Schema is updated to show custom system roles concerning a user on Open Event Server.
- Documentation | Marshmallow: https://marshmallow-jsonapi.readthedocs.io/en/latest/
- Fossasia Blog | Permissions for Custom roles on Open Event Server: https://blog.fossasia.org/adding-panel-permissions-api-in-open-event-server/
- Documentation | Roles in Open Event Server: https://github.com/fossasia/open-event-server/blob/development/docs/general/roles.md
You must be logged in to post a comment.