-
Notifications
You must be signed in to change notification settings - Fork 1
Permissions
All user levels are specified in the Employee
object in the backend models.py
file.
The user levels currently available are:
- Employee
- HR
- Supervisor
- Admin (this one is kinda pointless)
User levels cascade, meaning that if someone is level 3, they are also considered all user levels with smaller numbers (meaning, 1 and 2).
The backend permissions.py
files contains decorators that can be imported to protect entire views defined in views.py
.
For example, if you only want supervisors to have access to a specific page, you can use the @supervisor_login_required
decorator. An example of this in use can be found in the frontend views.py
file on the sales
, reports
and vendors
views.
The permissions.py
file - in conjunction with a template processor in sporkify/settings.py
- provides three variables in the context for all pages. The variables are as follows:
is_hr
is_supervisor
is_admin
These can be used with {% if ... endif %}
tags to conditionally hide/display items on the page depending on user level. See the employees.html
template for an example.