mirror of
https://gitlab.crans.org/mediatek/med.git
synced 2024-12-30 19:02:23 +00:00
58 lines
1.5 KiB
Python
58 lines
1.5 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 import forms
|
|
from django.contrib.auth.forms import UsernameField
|
|
from django.core.validators import MinLengthValidator
|
|
from django.forms import ModelForm
|
|
|
|
from .models import User
|
|
|
|
|
|
class PassForm(forms.Form):
|
|
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
|
|
)
|
|
|
|
|
|
class BaseInfoForm(ModelForm):
|
|
class Meta:
|
|
model = User
|
|
fields = [
|
|
'username',
|
|
'email',
|
|
'first_name',
|
|
'last_name',
|
|
'address',
|
|
'telephone',
|
|
]
|
|
|
|
|
|
class UserCreationAdminForm(ModelForm):
|
|
"""
|
|
A form that creates a user, with no privileges,
|
|
from the given information.
|
|
"""
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.fields['email'].required = True
|
|
self.fields['first_name'].required = True
|
|
self.fields['last_name'].required = True
|
|
|
|
class Meta:
|
|
model = User
|
|
fields = ("username", "email", "first_name", "last_name", "address",
|
|
"telephone")
|
|
field_classes = {'username': UsernameField}
|