mirror of
https://gitlab.crans.org/mediatek/med.git
synced 2025-07-05 16:43:56 +02:00
Massive cleanup (1)
This commit is contained in:
@ -1,46 +1,29 @@
|
||||
# Re2o est un logiciel d'administration développé initiallement au rezometz. Il
|
||||
# se veut agnostique au réseau considéré, de manière à être installable en
|
||||
# quelques clics.
|
||||
#
|
||||
# Copyright © 2017 Gabriel Détraz
|
||||
# Copyright © 2017 Goulven Kermarec
|
||||
# Copyright © 2017 Augustin Lemesle
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# -*- 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.forms import ModelForm, Form
|
||||
from django.contrib.auth.forms import ReadOnlyPasswordHashField
|
||||
from django.core.validators import MinLengthValidator
|
||||
from django.utils import timezone
|
||||
from django.forms import ModelForm, Form
|
||||
|
||||
from .models import Adhesion, Clef, ListRight, Right, User
|
||||
|
||||
from .models import Adhesion, Clef, ListRight, Right, Request, 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)
|
||||
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 UserCreationForm(forms.ModelForm):
|
||||
"""A form for creating new users. Includes all the required
|
||||
fields, plus a repeated password."""
|
||||
password1 = forms.CharField(label='Password', widget=forms.PasswordInput, validators=[MinLengthValidator(8)], max_length=255)
|
||||
password2 = forms.CharField(label='Password confirmation', widget=forms.PasswordInput, validators=[MinLengthValidator(8)], max_length=255)
|
||||
password1 = forms.CharField(label='Password', widget=forms.PasswordInput, validators=[MinLengthValidator(8)],
|
||||
max_length=255)
|
||||
password2 = forms.CharField(label='Password confirmation', widget=forms.PasswordInput,
|
||||
validators=[MinLengthValidator(8)], max_length=255)
|
||||
is_admin = forms.BooleanField(label='is admin')
|
||||
|
||||
class Meta:
|
||||
@ -95,16 +78,18 @@ class UserChangeForm(forms.ModelForm):
|
||||
user.save()
|
||||
return user
|
||||
|
||||
|
||||
class ResetPasswordForm(forms.Form):
|
||||
pseudo = forms.CharField(label=u'Pseudo', max_length=255)
|
||||
email = forms.EmailField(max_length=255)
|
||||
|
||||
|
||||
class BaseInfoForm(ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(BaseInfoForm, self).__init__(*args, **kwargs)
|
||||
self.fields['name'].label = 'Prénom'
|
||||
self.fields['surname'].label = 'Nom'
|
||||
#self.fields['comment'].label = 'Commentaire'
|
||||
# self.fields['comment'].label = 'Commentaire'
|
||||
|
||||
class Meta:
|
||||
model = User
|
||||
@ -117,9 +102,10 @@ class BaseInfoForm(ModelForm):
|
||||
'adresse',
|
||||
]
|
||||
|
||||
|
||||
class InfoForm(BaseInfoForm):
|
||||
class Meta(BaseInfoForm.Meta):
|
||||
fields = [
|
||||
fields = [
|
||||
'name',
|
||||
'pseudo',
|
||||
'surname',
|
||||
@ -135,22 +121,26 @@ class PasswordForm(ModelForm):
|
||||
model = User
|
||||
fields = ['password']
|
||||
|
||||
|
||||
class StateForm(ModelForm):
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ['state']
|
||||
|
||||
|
||||
class ClefForm(ModelForm):
|
||||
class Meta:
|
||||
model = Clef
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class BaseClefForm(ClefForm):
|
||||
class Meta(ClefForm.Meta):
|
||||
fields = [
|
||||
fields = [
|
||||
'commentaire',
|
||||
]
|
||||
|
||||
|
||||
class AdhesionForm(ModelForm):
|
||||
adherent = forms.ModelMultipleChoiceField(User.objects.all(), widget=forms.CheckboxSelectMultiple, required=False)
|
||||
|
||||
@ -158,6 +148,7 @@ class AdhesionForm(ModelForm):
|
||||
model = Adhesion
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class RightForm(ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(RightForm, self).__init__(*args, **kwargs)
|
||||
@ -170,12 +161,13 @@ class RightForm(ModelForm):
|
||||
|
||||
|
||||
class DelRightForm(Form):
|
||||
rights = forms.ModelMultipleChoiceField(queryset=Right.objects.all(), widget=forms.CheckboxSelectMultiple)
|
||||
rights = forms.ModelMultipleChoiceField(queryset=Right.objects.all(), widget=forms.CheckboxSelectMultiple)
|
||||
|
||||
def __init__(self, right, *args, **kwargs):
|
||||
super(DelRightForm, self).__init__(*args, **kwargs)
|
||||
self.fields['rights'].queryset = Right.objects.filter(right=right)
|
||||
|
||||
|
||||
class ListRightForm(ModelForm):
|
||||
class Meta:
|
||||
model = ListRight
|
||||
@ -185,11 +177,12 @@ class ListRightForm(ModelForm):
|
||||
super(ListRightForm, self).__init__(*args, **kwargs)
|
||||
self.fields['listright'].label = 'Nom du droit/groupe'
|
||||
|
||||
|
||||
class NewListRightForm(ListRightForm):
|
||||
class Meta(ListRightForm.Meta):
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class DelListRightForm(Form):
|
||||
listrights = forms.ModelMultipleChoiceField(queryset=ListRight.objects.all(), label="Droits actuels", widget=forms.CheckboxSelectMultiple)
|
||||
|
||||
|
||||
listrights = forms.ModelMultipleChoiceField(queryset=ListRight.objects.all(), label="Droits actuels",
|
||||
widget=forms.CheckboxSelectMultiple)
|
||||
|
Reference in New Issue
Block a user