from django.contrib.auth.base_user import AbstractBaseUser from django.db import models from django.contrib.auth.models import User, PermissionsMixin from django.utils import timezone from users.managers import CustomUserManager class CustomUser(AbstractBaseUser, PermissionsMixin): zeus_id = models.IntegerField(unique=True, null=True) is_staff = models.BooleanField(default=False) username = models.CharField(max_length=50, unique=True) # zeus username student_number = models.CharField(max_length=255, verbose_name="Studentennummer") real_name = models.CharField(max_length=100, verbose_name="Echte naam") date_joined = models.DateTimeField(default=timezone.now) USERNAME_FIELD = 'username' REQUIRED_FIELDS = ['zeus_id'] objects = CustomUserManager() def __str__(self): return self.username @property def has_ugent_info(self): return self.real_name and self.student_number