SOITA/users/models.py
Hubert Jankowski 5e9d26ff8e added user type
2022-05-15 23:48:11 +02:00

41 lines
1.0 KiB
Python

from django.contrib.auth.base_user import AbstractBaseUser
from django.db import models
from .managers import UserManager
class User(AbstractBaseUser):
ADMIN = "admin"
STANDARD = "standard"
USER_TYPES = (
("admin", ADMIN),
("standard", STANDARD),
)
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)
is_active = models.BooleanField(default=True)
confirmation_number = models.CharField(max_length=100)
reset_code = models.IntegerField(null=True)
avatar = models.ImageField(upload_to="avatars/", null=True)
type = models.CharField(choices=USER_TYPES, default=STANDARD, max_length=100)
USERNAME_FIELD = "email"
objects = UserManager()
class Meta:
ordering = ("id", )
def get_details(self):
return {
"first_name": self.first_name,
"last_name": self.last_name,
"email": self.email
}