med/users/models.py

47 lines
1.2 KiB
Python

# -*- mode: python; coding: utf-8 -*-
# Copyright (C) 2017-2019 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
from django.contrib.auth.models import AbstractUser
from django.db import models
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from med.settings import MAX_EMPRUNT
class User(AbstractUser):
telephone = models.CharField(
verbose_name=_('phone number'),
max_length=15,
blank=True,
)
address = models.CharField(
verbose_name=_('address'),
max_length=255,
blank=True,
)
maxemprunt = models.IntegerField(
verbose_name=_('maximum borrowed'),
help_text=_('Maximal amount of simultaneous borrowed item '
'authorized.'),
default=MAX_EMPRUNT,
)
comment = models.CharField(
verbose_name=_('comment'),
help_text=_('Promotion...'),
max_length=255,
blank=True,
)
date_joined = models.DateTimeField(
_('date joined'),
default=timezone.now,
null=True,
)
REQUIRED_FIELDS = ['first_name', 'last_name', 'email']
@property
def is_member(self):
# FIXME Use NK20
return True