first commit

This commit is contained in:
NORBOYEVSAMARIDDIN
2026-02-07 11:18:38 +05:00
commit 493cb58222
228 changed files with 10859 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
from django.contrib.auth import models as auth_models
from django.db import models
from .choices import RoleChoice
from .managers import UserManager
from ..management.models import Region, Warehouse
class User(auth_models.AbstractUser):
phone = models.CharField(max_length=255, unique=True)
username = models.CharField(max_length=255, null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
validated_at = models.DateTimeField(null=True, blank=True)
role = models.CharField(
max_length=255,
choices=RoleChoice,
default=RoleChoice.EMPLOYEE,
)
region = models.ForeignKey(
Region,
on_delete=models.SET_NULL,
null=True,
blank=True,
help_text="Only for managers"
)
warehouse = models.ForeignKey(
Warehouse,
on_delete=models.PROTECT,
null=True,
blank=True,
help_text="Only for employees"
)
def get_full_name(self):
return f"{self.first_name} {self.last_name}".strip() or self.phone
USERNAME_FIELD = "phone"
objects = UserManager()
def __str__(self):
return self.phone