mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-06-23 14:36:39 +02:00
Restructure add juree page
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
@ -6,9 +6,8 @@ from io import StringIO
|
||||
import re
|
||||
from typing import Iterable
|
||||
|
||||
from crispy_forms.bootstrap import InlineField
|
||||
from crispy_forms.helper import FormHelper
|
||||
from crispy_forms.layout import Div, Fieldset, Submit
|
||||
from crispy_forms.layout import Div, Submit, Field
|
||||
from django import forms
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.exceptions import ValidationError
|
||||
@ -206,25 +205,28 @@ class PoolTeamsForm(forms.ModelForm):
|
||||
class AddJuryForm(forms.ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields['first_name'].required = True
|
||||
self.fields['last_name'].required = True
|
||||
self.fields['email'].required = True
|
||||
self.helper = FormHelper()
|
||||
self.helper.form_class = 'form-inline'
|
||||
self.helper.layout = Div(
|
||||
Div(
|
||||
Div(
|
||||
InlineField('first_name', autofocus="autofocus"),
|
||||
Field('first_name', autofocus="autofocus"),
|
||||
css_class='col-md-3',
|
||||
),
|
||||
Div(
|
||||
InlineField('last_name'),
|
||||
Field('last_name'),
|
||||
css_class='col-md-3',
|
||||
),
|
||||
Div(
|
||||
InlineField('email'),
|
||||
Field('email'),
|
||||
css_class='col-md-5',
|
||||
),
|
||||
Div(
|
||||
Submit('submit', _("Add")),
|
||||
css_class='col-md-1',
|
||||
css_class='col-md-1 py-md-4',
|
||||
),
|
||||
css_class='row',
|
||||
)
|
||||
@ -236,7 +238,7 @@ class AddJuryForm(forms.ModelForm):
|
||||
"""
|
||||
email = self.data["email"]
|
||||
if User.objects.filter(email=email).exists():
|
||||
self.add_error("email", _("This email address is already used."))
|
||||
self.instance = User.objects.get(email=email)
|
||||
return email
|
||||
|
||||
class Meta:
|
||||
|
Reference in New Issue
Block a user