8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-21 19:03:11 +00:00

Request for GTU validation

This commit is contained in:
Yohann D'ANELLO 2021-02-01 11:49:12 +01:00
parent a81ede5b38
commit 1291fcd8d7
No known key found for this signature in database
GPG key ID: 3A75C55819C8CF85

View file

@ -19,12 +19,13 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from cotisations.models import Article, Paiement
from django import forms
from django.contrib.auth.forms import UserCreationForm
from django.db.models import Q
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _
from cotisations.models import Article, Paiement
from preferences.models import GeneralOption
from re2o.widgets import AutocompleteModelWidget
from users.models import Adherent
@ -39,10 +40,28 @@ class AdherentForm(UserCreationForm):
"login page or contacting support.")
)
# Checkbox for GTU
gtu_check = forms.BooleanField(
required=True,
)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
gtu_file = GeneralOption.get_cached_value("GTU")
self.fields["email"].required = True
self.fields["gtu_check"].label = mark_safe(
"%s <a href='%s' download='CGU'>%s</a>."
% (
_("I commit to accept the"),
gtu_file.url if gtu_file else "#",
_("General Terms of Use"),
)
)
class Meta:
model = Adherent
fields = ("name", "surname", "pseudo", "email", "telephone", "password1", "password2", "room", "school",
"former_user_check",)
"former_user_check", "gtu_check",)
widgets = {
"school": AutocompleteModelWidget(url="/users/school-autocomplete"),
"room": AutocompleteModelWidget(