55 lines
1.3 KiB
Python
55 lines
1.3 KiB
Python
from django.db import models
|
|
from django.contrib.auth.models import AbstractBaseUser
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
from ..managers import UserManager
|
|
|
|
|
|
class User(AbstractBaseUser):
|
|
"""
|
|
Custom user model for Restoroo
|
|
"""
|
|
|
|
email = models.EmailField(_("email"), unique=True)
|
|
is_superuser = models.BooleanField(default=False)
|
|
is_active = models.BooleanField(default=True)
|
|
|
|
USERNAME_FIELD = "email"
|
|
REQUIRED_FIELDS = []
|
|
|
|
objects = UserManager()
|
|
|
|
@property
|
|
def is_staff(self) -> bool:
|
|
"""
|
|
Returns value of is_superuser - required by Django admin backend
|
|
|
|
TODO - Remove this after implementing custom admin backend
|
|
|
|
Returns:
|
|
bool: Value of is_superuser
|
|
"""
|
|
return self.is_superuser
|
|
|
|
def has_module_perms(self, *args, **kwargs) -> bool:
|
|
"""
|
|
Returns value of is_superuser - required by Django admin backend
|
|
|
|
TODO - Remove this after implementing custom admin backend
|
|
|
|
Returns:
|
|
bool: Value of is_superuser
|
|
"""
|
|
|
|
return self.is_superuser
|
|
|
|
has_perm = has_module_perms
|
|
|
|
def __str__(self):
|
|
"""
|
|
Returns string representation for User object
|
|
|
|
Returns:
|
|
str: Value of email
|
|
"""
|
|
return self.email
|