Mon commit initial
This commit is contained in:
105
gestion_vehicule/forms.py
Normal file
105
gestion_vehicule/forms.py
Normal file
@@ -0,0 +1,105 @@
|
||||
"""Gestion des formulaires liés aux véhicules."""
|
||||
|
||||
from . import models
|
||||
from django import forms
|
||||
|
||||
|
||||
class EnregistrerVehicule(forms.ModelForm):
|
||||
"""Formulaire pour enregistrer un véhicule."""
|
||||
|
||||
class Meta:
|
||||
"""Métadonnées du formulaire."""
|
||||
|
||||
model = models.Vehicule
|
||||
fields = ("image", "immatriculation")
|
||||
widgets = {
|
||||
"immatriculation": forms.TextInput(
|
||||
attrs={"class": "form-control"}
|
||||
),
|
||||
# "image": forms.TextInput(attrs=
|
||||
# {"class": "form-control", "type": "image"}),
|
||||
}
|
||||
|
||||
|
||||
class EnregistrerDemande(forms.ModelForm):
|
||||
"""Formulaire pour enregistrer une demande de véhicule."""
|
||||
|
||||
class Meta:
|
||||
"""Métadonnées du formulaire."""
|
||||
|
||||
model = models.DemandeVehicule
|
||||
fields = ("lieu_depart", "lieu_arrive", "date_heure")
|
||||
widgets = {
|
||||
"lieu_depart": forms.TextInput(attrs={"class": "form-control"}),
|
||||
"lieu_arrive": forms.TextInput(attrs={"class": "form-control"}),
|
||||
"date_heure": forms.DateTimeInput(
|
||||
attrs={"class": "form-control", "type": "datetime-local"}
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
class CarnetBord(forms.ModelForm):
|
||||
"""Formulaire pour le carnet de bord d'un véhicule."""
|
||||
|
||||
class Meta:
|
||||
"""Métadonnées du formulaire."""
|
||||
|
||||
model = models.CarnetBord
|
||||
fields = (
|
||||
"vehicule",
|
||||
"course",
|
||||
"heure_effectif_depart",
|
||||
"km_depart",
|
||||
"heure_arrive",
|
||||
"km_arrive",
|
||||
"course_termine",
|
||||
)
|
||||
|
||||
widgets = {
|
||||
"vehicule": forms.TextInput(attrs={"class": "form-control"}),
|
||||
"mois_concerne": forms.TextInput(
|
||||
attrs={"class": "form-control", "type": "month"}
|
||||
),
|
||||
"km_debut_mois": forms.TextInput(
|
||||
attrs={"class": "form-control", "type": "number"}
|
||||
),
|
||||
"km_fin_mois": forms.TextInput(
|
||||
attrs={"class": "form-control", "type": "number"}
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
class PriseCarburant(forms.ModelForm):
|
||||
"""Formulaire pour enregistrer une prise de carburant."""
|
||||
|
||||
class Meta:
|
||||
"""Métadonnées du formulaire."""
|
||||
|
||||
model = models.CarnetCarburant
|
||||
fields = (
|
||||
"date",
|
||||
"nom_station",
|
||||
"type_carburant",
|
||||
"litre",
|
||||
"prix",
|
||||
"kilometrage",
|
||||
"observation",
|
||||
)
|
||||
widgets = {
|
||||
"vehicule": forms.TextInput(attrs={"class": "form-control"}),
|
||||
"date": forms.DateInput(
|
||||
attrs={"class": "form-control", "type": "date"}
|
||||
),
|
||||
"nom_station": forms.TextInput(attrs={"class": "form-control"}),
|
||||
"type_carburant": forms.Select(attrs={"class": "form-select"}),
|
||||
"litre": forms.TextInput(
|
||||
attrs={"class": "form-control", "type": "number"}
|
||||
),
|
||||
"prix": forms.TextInput(
|
||||
attrs={"class": "form-control", "type": "number"}
|
||||
),
|
||||
"kilometrage": forms.TextInput(
|
||||
attrs={"class": "form-control", "type": "number"}
|
||||
),
|
||||
"observation": forms.Textarea(attrs={"class": "form-control"}),
|
||||
}
|
||||
Reference in New Issue
Block a user