kers/users/models.py

29 lines
949 B
Python
Raw Normal View History

2020-07-22 00:51:40 +02:00
from django.contrib.auth.base_user import AbstractBaseUser
2020-07-21 22:24:45 +02:00
from django.db import models
2020-07-22 00:51:40 +02:00
from django.contrib.auth.models import User, PermissionsMixin
from django.utils import timezone
2020-07-21 22:24:45 +02:00
2020-07-22 00:51:40 +02:00
from users.managers import CustomUserManager
2020-07-21 22:24:45 +02:00
2020-07-22 00:51:40 +02:00
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")
2020-07-22 00:51:40 +02:00
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