Files
backend/core/models.py
Michel Wilhelm 733f3e5992 Basic game creating API (#2)
* Adding the base of our API

* Little file and lint adjustments

* Adding the lint command to Makefile

* Adding the Minesweeper logic for game creation

* Adding some tests for the Minesweeper algorithm

* Adding some tools command to Makefile like pre-commit and pip-tools

* Adding test help text to Makefile

* all new user is_staff=True, for development for now

* Now we can get the data from specific game

Adding game status

Adding game status

Fixing game models
2020-11-05 23:29:35 -03:00

42 lines
1.3 KiB
Python

from django.db import models
from django.contrib.auth.models import PermissionsMixin
from django.contrib.auth.base_user import AbstractBaseUser
from .managers import UserManager
class User(AbstractBaseUser, PermissionsMixin):
email = models.EmailField("E-mail", unique=True)
first_name = models.CharField("First name", max_length=30, blank=True)
last_name = models.CharField("Last name", max_length=30, blank=True)
date_joined = models.DateTimeField("date joined", auto_now_add=True)
is_active = models.BooleanField("User active?", default=True)
is_staff = models.BooleanField("Staff?", default=True)
is_superuser = models.BooleanField("Superuser?", default=False)
objects = UserManager()
USERNAME_FIELD = "email"
class Meta:
ordering = ["first_name", "last_name"]
verbose_name = "User"
verbose_name_plural = "Users"
db_table = "users"
def get_full_name(self):
"""
Returns the first_name plus the last_name, with a space in between.
"""
full_name = f"{self.first_name} {self.last_name}"
return full_name.strip()
def get_short_name(self):
"""
Returns the short name for the user.
"""
return self.first_name or "Unamed"