feat: add RBAC migrations, user modules, admin API updates, and utility scripts
This commit is contained in:
@@ -37,6 +37,23 @@ class User(AbstractUser):
|
||||
|
||||
profile_picture = models.ImageField(upload_to='profile_pictures/', blank=True, null=True, default='default.png')
|
||||
|
||||
allowed_modules = models.TextField(
|
||||
blank=True, null=True,
|
||||
help_text="Comma-separated module slugs this user can access"
|
||||
)
|
||||
|
||||
ALL_MODULES = ["dashboard", "partners", "events", "ad-control", "users", "reviews", "contributions", "financials", "settings"]
|
||||
|
||||
def get_allowed_modules(self):
|
||||
ALL = ["dashboard", "partners", "events", "ad-control", "users", "reviews", "contributions", "financials", "settings"]
|
||||
if self.is_superuser or self.role == "admin":
|
||||
return ALL
|
||||
if self.allowed_modules:
|
||||
return [m.strip() for m in self.allowed_modules.split(",") if m.strip()]
|
||||
if self.role == "manager":
|
||||
return ALL
|
||||
return []
|
||||
|
||||
objects = UserManager()
|
||||
|
||||
def __str__(self):
|
||||
|
||||
Reference in New Issue
Block a user