2021-12-05 13:50:34 +01:00
|
|
|
from django.contrib.auth.base_user import AbstractBaseUser
|
|
|
|
from django.db import models
|
|
|
|
|
2021-12-05 15:23:29 +01:00
|
|
|
from .managers import UserManager
|
|
|
|
|
2021-12-05 13:50:34 +01:00
|
|
|
|
|
|
|
class User(AbstractBaseUser):
|
2022-05-15 23:48:11 +02:00
|
|
|
|
|
|
|
ADMIN = "admin"
|
|
|
|
STANDARD = "standard"
|
|
|
|
|
|
|
|
USER_TYPES = (
|
|
|
|
("admin", ADMIN),
|
|
|
|
("standard", STANDARD),
|
|
|
|
)
|
|
|
|
|
2021-12-05 13:50:34 +01:00
|
|
|
first_name = models.CharField(max_length=100)
|
|
|
|
last_name = models.CharField(max_length=100)
|
|
|
|
|
|
|
|
email = models.EmailField(db_index=True, unique=True, max_length=50)
|
2021-12-21 08:02:19 +01:00
|
|
|
is_active = models.BooleanField(default=True)
|
2021-12-05 13:50:34 +01:00
|
|
|
|
|
|
|
confirmation_number = models.CharField(max_length=100)
|
2021-12-11 22:01:14 +01:00
|
|
|
reset_code = models.IntegerField(null=True)
|
2021-12-05 13:50:34 +01:00
|
|
|
avatar = models.ImageField(upload_to="avatars/", null=True)
|
2022-05-15 23:48:11 +02:00
|
|
|
type = models.CharField(choices=USER_TYPES, default=STANDARD, max_length=100)
|
2021-12-05 13:50:34 +01:00
|
|
|
|
|
|
|
USERNAME_FIELD = "email"
|
|
|
|
|
2021-12-05 15:23:29 +01:00
|
|
|
objects = UserManager()
|
|
|
|
|
2021-12-05 13:50:34 +01:00
|
|
|
class Meta:
|
|
|
|
ordering = ("id", )
|
|
|
|
|
|
|
|
def get_details(self):
|
|
|
|
return {
|
|
|
|
"first_name": self.first_name,
|
|
|
|
"last_name": self.last_name,
|
|
|
|
"email": self.email
|
|
|
|
}
|