2013-04-23 16:42:25 +02:00
|
|
|
from django.db import models
|
|
|
|
from django.core.validators import RegexValidator, MinLengthValidator, \
|
|
|
|
MaxLengthValidator
|
2013-04-23 22:36:01 +02:00
|
|
|
from django.utils.translation import ugettext_lazy as _, pgettext_lazy
|
2013-08-02 15:46:32 +02:00
|
|
|
from django.contrib.auth.models import Group
|
|
|
|
|
2013-03-22 00:31:08 +01:00
|
|
|
|
2013-04-23 16:42:25 +02:00
|
|
|
from authentic2.models import AbstractUser
|
2013-03-22 00:31:08 +01:00
|
|
|
|
2014-05-23 15:40:57 +02:00
|
|
|
from . import app_settings
|
|
|
|
|
2013-08-02 15:46:32 +02:00
|
|
|
|
2013-04-23 16:42:25 +02:00
|
|
|
class Citoyen(AbstractUser):
|
2013-04-23 22:36:01 +02:00
|
|
|
title = models.CharField(pgettext_lazy('person title', 'title'), max_length=16, blank=True,
|
2013-05-24 13:37:04 +02:00
|
|
|
choices=tuple((x, x) for x in (_('Mrs'),
|
|
|
|
_('Mr'))))
|
2013-04-23 16:42:25 +02:00
|
|
|
|
|
|
|
first_name = models.CharField(_('first name'), max_length=30, blank=True)
|
|
|
|
last_name = models.CharField(_('last name'), max_length=30, blank=True)
|
|
|
|
email = models.EmailField(_('e-mail address'), max_length=128, blank=True)
|
|
|
|
city = models.CharField(_('city'), max_length=64, blank=True)
|
|
|
|
address = models.CharField(_('address'), max_length=128, blank=True)
|
|
|
|
postal_code = models.CharField(_('postal code'), max_length=5, blank=True,
|
|
|
|
validators=[
|
2014-05-23 15:40:57 +02:00
|
|
|
RegexValidator(app_settings.POSTAL_CODE_REGEXP,
|
|
|
|
app_settings.POSTAL_CODE_MESSAGE,
|
|
|
|
'invalid postal code')])
|
2013-04-23 16:42:25 +02:00
|
|
|
phone = models.CharField(verbose_name=_("phone"),
|
2013-06-18 17:55:15 +02:00
|
|
|
max_length=16, blank=True,
|
|
|
|
help_text=_('Phone number must start with 01, 02, 03, 04, 05, 08 or 07 and be ten digits long without spaces'),
|
|
|
|
validators=[
|
2014-05-23 15:40:57 +02:00
|
|
|
RegexValidator(app_settings.HOME_PHONE_REGEXP,
|
|
|
|
app_settings.HOME_PHONE_MESSAGE,
|
|
|
|
'invalid phone'),])
|
2013-04-23 16:42:25 +02:00
|
|
|
mobile = models.CharField(verbose_name=_("mobile"),
|
2013-06-18 17:55:15 +02:00
|
|
|
max_length=16, blank=True,
|
|
|
|
help_text=_('Mobile phone number must start with 06 or 07 and be ten digits long without spaces'),
|
|
|
|
validators=[
|
2014-05-23 15:40:57 +02:00
|
|
|
RegexValidator(app_settings.MOBILE_PHONE_REGEXP,
|
|
|
|
app_settings.MOBILE_PHONE_MESSAGE,
|
|
|
|
'invalid phone'),])
|
2013-04-23 16:42:25 +02:00
|
|
|
|
2013-05-07 23:45:57 +02:00
|
|
|
REQUIRED_FIELDS = ['first_name', 'last_name', 'email']
|
2013-05-29 12:13:05 +02:00
|
|
|
USERNAME = 'username'
|
2013-04-23 16:42:25 +02:00
|
|
|
USER_PROFILE = ( 'title', 'username', 'first_name', 'last_name', 'email',
|
2013-06-19 10:26:11 +02:00
|
|
|
'phone', 'mobile', 'address', 'postal_code', 'city', 'roles')
|
2013-04-23 16:42:25 +02:00
|
|
|
|
|
|
|
from authentic2.attribute_aggregator.core import ATTRIBUTE_MAPPING
|
|
|
|
|
|
|
|
ATTRIBUTE_MAPPING['l']['profile_field_name'] = 'city'
|
|
|
|
ATTRIBUTE_MAPPING['personalTitle']['profile_field_name'] = 'title'
|
|
|
|
ATTRIBUTE_MAPPING['street']['profile_field_name'] = 'address'
|
|
|
|
ATTRIBUTE_MAPPING['postalCode']['profile_field_name'] = 'postal_code'
|
|
|
|
ATTRIBUTE_MAPPING['mobile']['profile_field_name'] = 'mobile'
|
2013-08-02 15:46:32 +02:00
|
|
|
|
|
|
|
class Role(Group):
|
|
|
|
class Meta:
|
|
|
|
proxy = True
|
|
|
|
verbose_name = _('role')
|
|
|
|
verbose_name_plural = _('roles')
|
|
|
|
|
2013-08-02 16:11:01 +02:00
|
|
|
import permission_hack
|