med/users/models.py

47 lines
1.2 KiB
Python
Raw Normal View History

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