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
|
2017-06-11 23:34:13 +00:00
|
|
|
|
|
|
|
from django import forms
|
|
|
|
from django.core.validators import MinLengthValidator
|
2019-08-08 13:35:25 +00:00
|
|
|
from django.forms import ModelForm
|
2019-08-02 12:57:53 +00:00
|
|
|
|
2019-08-08 13:35:25 +00:00
|
|
|
from .models import User
|
2017-06-11 23:34:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
class PassForm(forms.Form):
|
2019-08-08 13:35:25 +00:00
|
|
|
passwd1 = forms.CharField(
|
|
|
|
label=u'Nouveau mot de passe',
|
|
|
|
max_length=255,
|
|
|
|
validators=[MinLengthValidator(8)],
|
|
|
|
widget=forms.PasswordInput,
|
|
|
|
)
|
|
|
|
passwd2 = forms.CharField(
|
|
|
|
label=u'Saisir à nouveau le mot de passe',
|
|
|
|
max_length=255,
|
|
|
|
validators=[MinLengthValidator(8)],
|
|
|
|
widget=forms.PasswordInput
|
|
|
|
)
|
2017-06-11 23:34:13 +00:00
|
|
|
|
|
|
|
|
2017-07-06 15:41:10 +00:00
|
|
|
class BaseInfoForm(ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = User
|
|
|
|
fields = [
|
2019-08-08 10:16:40 +00:00
|
|
|
'first_name',
|
2019-08-02 19:35:30 +00:00
|
|
|
'username',
|
2019-08-02 19:47:54 +00:00
|
|
|
'last_name',
|
2017-07-06 15:41:10 +00:00
|
|
|
'email',
|
|
|
|
'telephone',
|
2019-08-08 10:16:40 +00:00
|
|
|
'address',
|
2017-07-06 15:41:10 +00:00
|
|
|
]
|
|
|
|
|
2019-08-02 12:57:53 +00:00
|
|
|
|
2017-07-06 15:41:10 +00:00
|
|
|
class InfoForm(BaseInfoForm):
|
|
|
|
class Meta(BaseInfoForm.Meta):
|
2019-08-02 12:57:53 +00:00
|
|
|
fields = [
|
2019-08-08 10:16:40 +00:00
|
|
|
'first_name',
|
2019-08-02 19:35:30 +00:00
|
|
|
'username',
|
2019-08-02 19:47:54 +00:00
|
|
|
'last_name',
|
2017-07-06 15:41:10 +00:00
|
|
|
'email',
|
|
|
|
'telephone',
|
2019-08-08 10:16:40 +00:00
|
|
|
'address',
|
2017-07-06 15:41:10 +00:00
|
|
|
'maxemprunt',
|
|
|
|
]
|