2020-04-05 03:17:28 +00:00
|
|
|
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2020-04-05 07:09:21 +00:00
|
|
|
from django import forms
|
2020-04-05 03:17:28 +00:00
|
|
|
from django.contrib.auth.forms import UserCreationForm
|
|
|
|
from django.contrib.auth.models import User
|
|
|
|
from django.utils.translation import gettext_lazy as _
|
2020-04-05 07:09:21 +00:00
|
|
|
from note.models import NoteSpecial
|
|
|
|
from note_kfet.inputs import AmountInput
|
2020-04-05 03:17:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
class SignUpForm(UserCreationForm):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super().__init__(*args, **kwargs)
|
|
|
|
self.fields['username'].widget.attrs.pop("autofocus", None)
|
|
|
|
self.fields['first_name'].widget.attrs.update({"autofocus": "autofocus"})
|
|
|
|
self.fields['first_name'].required = True
|
|
|
|
self.fields['last_name'].required = True
|
|
|
|
self.fields['email'].required = True
|
|
|
|
self.fields['email'].help_text = _("This address must be valid.")
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = User
|
|
|
|
fields = ('first_name', 'last_name', 'username', 'email', )
|
2020-04-05 07:09:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ValidationForm(forms.Form):
|
|
|
|
credit_type = forms.ModelChoiceField(
|
|
|
|
queryset=NoteSpecial.objects,
|
|
|
|
label=_("Credit type"),
|
|
|
|
empty_label=_("No credit"),
|
|
|
|
required=False,
|
|
|
|
)
|
|
|
|
|
|
|
|
credit_amount = forms.IntegerField(
|
|
|
|
label=_("Credit amount"),
|
|
|
|
required=False,
|
|
|
|
initial=0,
|
|
|
|
widget=AmountInput(),
|
|
|
|
)
|
|
|
|
|
|
|
|
last_name = forms.CharField(
|
|
|
|
label=_("Last name"),
|
|
|
|
required=False,
|
|
|
|
)
|
|
|
|
|
|
|
|
first_name = forms.CharField(
|
|
|
|
label=_("First name"),
|
|
|
|
required=False,
|
|
|
|
)
|
|
|
|
|
|
|
|
bank = forms.CharField(
|
|
|
|
label=_("Bank"),
|
|
|
|
required=False,
|
|
|
|
)
|
|
|
|
|
|
|
|
join_BDE = forms.BooleanField(
|
|
|
|
label=_("Join BDE"),
|
|
|
|
required=False,
|
|
|
|
initial=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
join_Kfet = forms.BooleanField(
|
|
|
|
label=_("Join Kfet"),
|
|
|
|
required=False,
|
|
|
|
initial=True,
|
|
|
|
)
|