105 lines
3.3 KiB
Python
105 lines
3.3 KiB
Python
|
|
"""Génération des formulaires pour la gestion des produits."""
|
||
|
|
|
||
|
|
from django import forms
|
||
|
|
from .models import Produit, Categorie, Commander, Demander
|
||
|
|
|
||
|
|
|
||
|
|
class EnregistrementProduit(forms.ModelForm):
|
||
|
|
"""Formulaire pour l'enregistrement d'un produit."""
|
||
|
|
|
||
|
|
class Meta:
|
||
|
|
"""Métadonnées du formulaire."""
|
||
|
|
|
||
|
|
model = Produit
|
||
|
|
fields = (
|
||
|
|
"image",
|
||
|
|
"libelle",
|
||
|
|
"quantite_stock",
|
||
|
|
"conditionnement",
|
||
|
|
"seuil_pre_rupture",
|
||
|
|
"categorie",
|
||
|
|
)
|
||
|
|
widgets = {
|
||
|
|
"libelle": forms.TextInput(attrs={"class": "form-control"}),
|
||
|
|
"quantite_stock": forms.NumberInput(
|
||
|
|
attrs={"class": "form-control"}
|
||
|
|
),
|
||
|
|
"conditionnement": forms.Select(attrs={"class": "form-select"}),
|
||
|
|
"seuil_pre_rupture": forms.NumberInput(
|
||
|
|
attrs={"class": "form-control"}
|
||
|
|
),
|
||
|
|
"categorie": forms.Select(attrs={"class": "form-select"}),
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
class EnregistrementCategorie(forms.ModelForm):
|
||
|
|
"""Formulaire pour l'enregistrement d'une catégorie de produit."""
|
||
|
|
|
||
|
|
class Meta:
|
||
|
|
"""Métadonnées du formulaire."""
|
||
|
|
|
||
|
|
model = Categorie
|
||
|
|
fields = ("categorie", )
|
||
|
|
widgets = {
|
||
|
|
"categorie": forms.TextInput(attrs={"class": "form-control"})
|
||
|
|
}
|
||
|
|
|
||
|
|
class CommanderProduit(forms.ModelForm):
|
||
|
|
"""Formulaire pour l'enregistrement d'une commande de produit."""
|
||
|
|
|
||
|
|
class Meta:
|
||
|
|
"""Métadonnées du formulaire."""
|
||
|
|
|
||
|
|
model = Commander
|
||
|
|
fields = (
|
||
|
|
"produit",
|
||
|
|
"fournisseur",
|
||
|
|
"quantite_commander",
|
||
|
|
"prix_achat",
|
||
|
|
"date_commande",
|
||
|
|
"date_livraison",
|
||
|
|
)
|
||
|
|
widgets = {
|
||
|
|
"produit": forms.Select(attrs={"class": "form-select"}),
|
||
|
|
"fournisseur": forms.Select(attrs={"class": "form-select"}),
|
||
|
|
"quantite_commander": forms.NumberInput(
|
||
|
|
attrs={"class": "form-control"}
|
||
|
|
),
|
||
|
|
"prix_achat": forms.NumberInput(attrs={"class": "form-control"}),
|
||
|
|
"date_commande": forms.DateInput(
|
||
|
|
attrs={"class": "form-control", "type": "date"}
|
||
|
|
),
|
||
|
|
"date_livraison": forms.DateInput(
|
||
|
|
attrs={"class": "form-control", "type": "date"}
|
||
|
|
),
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
class DemanderProduit(forms.ModelForm):
|
||
|
|
"""Formulaire pour l'enregistrement d'une demande de produit."""
|
||
|
|
|
||
|
|
class Meta:
|
||
|
|
"""Métadonnées du formulaire."""
|
||
|
|
|
||
|
|
model = Demander
|
||
|
|
fields = (
|
||
|
|
"produit",
|
||
|
|
"quantite",
|
||
|
|
"motifs",
|
||
|
|
"date_de_mise_a_dispo_souhaite",
|
||
|
|
"a_rendre",
|
||
|
|
)
|
||
|
|
widgets = {
|
||
|
|
"produit": forms.Select(attrs={"class": "form-select"}),
|
||
|
|
"quantite": forms.NumberInput(attrs={"class": "form-control"}),
|
||
|
|
"motifs": forms.Textarea(
|
||
|
|
attrs={"class": "form-control", "rows": 4}
|
||
|
|
),
|
||
|
|
"date_de_mise_a_dispo_souhaite": forms.DateInput(
|
||
|
|
attrs={"class": "form-control", "type": "date"}
|
||
|
|
),
|
||
|
|
"a_rendre": forms.CheckboxInput(
|
||
|
|
attrs={"class": "form-check-input"}
|
||
|
|
),
|
||
|
|
}
|