Creating user roles

Until now, we saw how a view that is accessible to a certain set of admin users can be created easily using the is_accessible() method. This can be extended to have different kinds of scenarios where specific users will be able to view specific views. There is another way of implementing user roles at a much more granular level in a model where the roles determine whether a user can perform all, some, or any of the CRUD operations.

Getting ready

In this recipe, we will see a basic way of creating user roles, where an admin user can only perform actions they are entitled to.

Note

Remember that this is just one way of implementing user roles. There are many better ways of doing this, but this one seems to be the best one to demonstrate ...

Get Flask Framework Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.