feat: implement user management system

- Add role field to UserProfile (superadmin/admin/trainer)
- Add role-based permission classes
- Create UserManagementViewSet with CRUD and password change
- Add API types and components for user management
- Create users management page in settings
- Only superadmins can manage users
This commit is contained in:
Andrej Spielmann
2026-03-26 16:42:08 +01:00
parent 7611533718
commit 28222d634d
19 changed files with 1960 additions and 7 deletions
+8 -1
View File
@@ -3,11 +3,18 @@ from django.contrib.auth.models import User
class UserProfile(models.Model):
ROLE_CHOICES = [
('superadmin', 'Super Admin'),
('admin', 'Admin'),
('trainer', 'Trainer'),
]
user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='profile')
club = models.ForeignKey('clubs.Club', on_delete=models.SET_NULL, null=True, blank=True, related_name='user_profiles')
role = models.CharField(max_length=20, choices=ROLE_CHOICES, default='trainer')
def __str__(self):
return f"{self.user.username} Profile"
return f"{self.user.username} Profile ({self.get_role_display()})"
class UserPreferences(models.Model):