Gobarau Backend implements a role-based access control (RBAC) system built directly on top of Django REST Framework’s permission layer. EveryDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/muhammadbugaje/gobarau_backend/llms.txt
Use this file to discover all available pages before exploring further.
User record carries a role field (a CharField with choices from RoleChoices) that identifies what that user is permitted to do across the system. Rather than relying on Django’s group-based permissions or per-object Permission records, the system uses four custom DRF BasePermission subclasses that inspect request.user.role at the view level. This keeps permission logic explicit, centralised in core/permissions.py, and easy to audit.
Roles
All valid roles are declared incore/choices.py as a TextChoices enumeration. The string values stored in the database are listed below along with their display names and typical system use.
| Role value | Display name | Typical use |
|---|---|---|
super_admin | Super Admin | Full unrestricted system access; can manage all records, users, and settings |
principal | Principal | School leadership; broad read/write access across academic and administrative data |
vice_principal | Vice Principal | School leadership; same access tier as Principal |
bursar | Bursar | Finance management; access to fee structures, invoices, and payment records |
teacher | Teacher | Academic and attendance management for assigned classes and subjects |
student | Student | View their own academic records, timetable, attendance, and scores |
parent | Parent | View data belonging to their registered wards only |
alumni | Alumni | Access alumni features, wall of fame, and mentorship listings |
nurse | School Nurse | Create and manage health records and welfare entries |
counsellor | Counsellor | Record and manage counselling sessions and student welfare interventions |
role field is declared on accounts.User with a default of student, meaning every newly created user starts with the least-privileged role:
Wing Assignment
In addition to their role, every user is assigned a wing that reflects which educational programme they belong to. Wing assignment is stored onUser.wing and is also represented as a FK on StudentProfile.
| Wing value | Display name | Description |
|---|---|---|
regular | Regular | Standard national curriculum programme |
islamiyyah | Islamiyyah | Integrated Islamic studies curriculum |
tahfeez | Tahfeez | Quran memorisation (Hifz) programme |
core/choices.py:
Permission Classes
All four permission classes live incore/permissions.py and extend DRF’s BasePermission. They implement both has_permission (view-level) and, where relevant, has_object_permission (object-level) checks.
All endpoints require
IsAuthenticated in addition to whichever role-based permission class is applied. The custom permission classes also guard against unauthenticated requests internally, but setting IsAuthenticated explicitly in the ViewSet’s permission_classes is the recommended pattern.IsAdminLevel
Grants access exclusively to the three leadership roles: super_admin, principal, and vice_principal. Use this on ViewSets that manage users, roles, system configuration, or any data that only school leadership should touch.
IsStaffOrAdmin
Extends BasePermission to permit the same three admin-level roles as IsAdminLevel plus the bursar and teacher roles. Use this on ViewSets where operational staff — not just leadership — need read or write access, such as student lists, class schedules, and finance summaries.
IsOwnStudent
Intended for ViewSets that expose student-centric data (attendance, scores, assignments). At the view level it allows teachers and all admin-level roles. At the object level it always returns True as a base — individual app ViewSets are expected to supplement with class-assignment logic to ensure teachers only see students in their own classes.
IsOwnWard
Controls parent access to student data. At the view level it allows the parent role and all admin-level roles. At the object level admin roles are always permitted — app-level ViewSets should add ward-assignment filtering to restrict parents to their own children’s records.
How Permissions Are Applied
Permission classes are set on each ViewSet via thepermission_classes attribute. The table below shows representative examples from across the application:
| ViewSet / Endpoint area | Permission class | Rationale |
|---|---|---|
UserViewSet (accounts) | IsAdminLevel | Only leadership can create, modify, or deactivate user accounts |
PersonViewSet (accounts) | IsStaffOrAdmin | All staff need to look up identity records |
StudentProfileViewSet (people) | IsStaffOrAdmin | Teachers and admin manage student profiles |
AttendanceRecordViewSet (academics) | IsOwnStudent | Teachers record attendance for their own class |
ScoreViewSet (academics) | IsOwnStudent | Teachers enter scores; admins have full access |
WardRelationshipViewSet (people) | IsOwnWard | Parents view their linked wards; admin can manage all links |
FinanceViewSet (finance) | IsStaffOrAdmin | Bursars and admin manage fee and payment records |
HealthRecordViewSet (welfare) | IsStaffOrAdmin | Nurses and admin manage health entries |