Skip to content

Feat/add role permission helpers#29

Merged
AAdewunmi merged 6 commits into
mainfrom
feat/add-role-permission-helpers
May 7, 2026
Merged

Feat/add role permission helpers#29
AAdewunmi merged 6 commits into
mainfrom
feat/add-role-permission-helpers

Conversation

@AAdewunmi

Copy link
Copy Markdown
Owner

Summary

Add reusable role permission helpers and align role access with the current StudyBuddy user-role relationship.

Changes

  • Added role-aware helper coverage for user_has_role and user_has_any_role.
  • Fixed permission helpers to use user.studybuddy_roles.
  • Confirmed anonymous users fail role checks.
  • Confirmed superusers pass role checks.
  • Kept role checks out of templates by passing display-only role context from views.
  • Updated authentication/access-control documentation to describe the current role model, routes, dashboard flow, and permission helper behavior.

Behavior

  • Role checks now use the correct studybuddy_roles relation.
  • Future role-aware views can enforce access through permission helpers/decorators.
  • Templates only display role data passed by views and do not perform permission decisions.

Why

This prepares StudyBuddy for future role-aware product features while keeping authorization logic centralized in Python instead of scattered through templates.

Validation

  • Roles tests passed.
  • Auth view tests passed.
  • Black passed.
  • Ruff passed.
  • Full test suite passed.

Result

StudyBuddy now has a tested role-permission foundation that matches the current custom user and role models and is ready for future access-controlled features.

Notes

  • role_required() is available for future protected views, but no Sprint 1 dashboard access depends on roles yet.
  • The dashboard remains login-protected, not role-protected.
  • Role display in dashboard/profile is presentation only.
  • Permission decisions should stay in views, decorators, or service code using apps.roles.permissions.
  • The current user-side role relation is user.studybuddy_roles, not user.roles.
  • Full suite currently passes with 43 passed.

@codecov

codecov Bot commented May 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@AAdewunmi AAdewunmi merged commit c7039ef into main May 7, 2026
2 checks passed
@AAdewunmi AAdewunmi deleted the feat/add-role-permission-helpers branch May 7, 2026 13:19
@AAdewunmi AAdewunmi added sprint-1-roles-authorisation-backend Add roles foundation and removed sprint-2-roles-authorisation-backend Add role permission helpers labels May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

Add role permission helpers

1 participant