Spaces:
Runtime error
Runtime error
Download auth_app/models.py from neurostack-in/pms_server: direct link, hf CLI and curl.
- Browser
- Download file 1.38 kB
-
https://huggingface.co/spaces/neurostack-in/pms_server/resolve/main/auth_app/models.py
- Command line
-
hf download hf://spaces/neurostack-in/pms_server/auth_app/models.py
-
curl -L -o models.py https://huggingface.co/spaces/neurostack-in/pms_server/resolve/main/auth_app/models.py
1.38 kB
| from django.db import models | |
| from django.contrib.auth.models import AbstractUser, UserManager | |
| import uuid | |
| class CustomUserManager(UserManager): | |
| def create_superuser(self, username, email=None, password=None, **extra_fields): | |
| extra_fields.setdefault('is_staff', True) | |
| extra_fields.setdefault('is_superuser', True) | |
| extra_fields.setdefault('role', 'ADMIN') # Set role to ADMIN for superusers | |
| if extra_fields.get('is_staff') is not True: | |
| raise ValueError('Superuser must have is_staff=True.') | |
| if extra_fields.get('is_superuser') is not True: | |
| raise ValueError('Superuser must have is_superuser=True.') | |
| return self._create_user(username, email, password, **extra_fields) | |
| class User(AbstractUser): | |
| ROLE_CHOICES = ( | |
| ('ADMIN', 'Admin'), | |
| ('RESEARCHER', 'Researcher'), | |
| ) | |
| STATUS_CHOICES = ( | |
| ('ACTIVE', 'Active'), | |
| ('FROZEN', 'Frozen'), | |
| ('INACTIVE', 'Inactive'), | |
| ) | |
| id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) | |
| role = models.CharField(max_length=20, choices=ROLE_CHOICES, default='RESEARCHER') | |
| status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='ACTIVE') | |
| objects = CustomUserManager() | |
| class Meta: | |
| verbose_name = 'User' | |
| verbose_name_plural = 'Users' | |