176 lines
6.1 KiB
Python
176 lines
6.1 KiB
Python
|
|
from django import forms
|
|||
|
|
from gestion_projet.models import Projet
|
|||
|
|
from .models import (
|
|||
|
|
ActiviteProjet,
|
|||
|
|
Bailleur,
|
|||
|
|
DocumentProjet,
|
|||
|
|
FinancementProjet,
|
|||
|
|
LivrablesLivres,
|
|||
|
|
DomaineDeRecherche
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
class ProjetForm(forms.ModelForm):
|
|||
|
|
"""Formulaire de création et de modification d'un projet, avec validation des dates et personnalisation des champs."""
|
|||
|
|
class Meta:
|
|||
|
|
model = Projet
|
|||
|
|
fields = (
|
|||
|
|
'id_projet',
|
|||
|
|
'nom_projet',
|
|||
|
|
'date_debut',
|
|||
|
|
'date_fin',
|
|||
|
|
'numero_convention',
|
|||
|
|
'domaine_recherche',
|
|||
|
|
'type_projet',
|
|||
|
|
'budget',
|
|||
|
|
'budget_RH',
|
|||
|
|
'description'
|
|||
|
|
)
|
|||
|
|
# domaine_recherche = forms.ModelMultipleChoiceField(
|
|||
|
|
# queryset=DomaineDeRecherche.objects.all(),
|
|||
|
|
# to_field_name="nom",
|
|||
|
|
# required=False
|
|||
|
|
# )
|
|||
|
|
widgets = {
|
|||
|
|
'id_projet': forms.TextInput(attrs={'class': "form-control"}),
|
|||
|
|
'nom_projet': forms.TextInput(attrs={'class': "form-control"}),
|
|||
|
|
'numero_convention': forms.TextInput(attrs={'class': "form-control"}),
|
|||
|
|
'domaine_recherche': forms.SelectMultiple(attrs={'class': "form-control"}),
|
|||
|
|
'type_projet': forms.Select(attrs={'class': "form-select"}),
|
|||
|
|
'budget': forms.NumberInput(attrs={'class': "form-control"}),
|
|||
|
|
'budget_RH': forms.NumberInput(attrs={'class': "form-control"}),
|
|||
|
|
'description': forms.Textarea(attrs={'class': "form-control"}),
|
|||
|
|
'date_debut': forms.DateInput(attrs={'type': 'date', 'class': "form-control"}),
|
|||
|
|
'date_fin': forms.DateInput(attrs={'type': 'date', 'class': "form-control"}),
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
class BailleurForm(forms.ModelForm):
|
|||
|
|
"""
|
|||
|
|
Formulaire de création et de modification d'un bailleur,
|
|||
|
|
avec validation des champs et personnalisation des labels.
|
|||
|
|
"""
|
|||
|
|
class Meta:
|
|||
|
|
model = Bailleur
|
|||
|
|
fields = ('nom_organisme', 'contact', 'email', 'pays')
|
|||
|
|
widgets = {
|
|||
|
|
'nom_organisme':forms.TextInput(attrs={
|
|||
|
|
'class':'form-control',
|
|||
|
|
}),
|
|||
|
|
'contact':forms.TextInput(attrs={
|
|||
|
|
'class':'form-control',
|
|||
|
|
}),
|
|||
|
|
'email':forms.TextInput(attrs={
|
|||
|
|
'class':'form-control',
|
|||
|
|
}),
|
|||
|
|
'pays':forms.TextInput(attrs={
|
|||
|
|
'class':'form-control',
|
|||
|
|
}),
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
class DocumentProjetForm(forms.ModelForm):
|
|||
|
|
"""
|
|||
|
|
Formulaire pour ajouter ou modifier un document associé à un projet,
|
|||
|
|
avec validation des champs et personnalisation des labels.
|
|||
|
|
"""
|
|||
|
|
class Meta:
|
|||
|
|
model = DocumentProjet
|
|||
|
|
fields = [
|
|||
|
|
'nom_document',
|
|||
|
|
'numero',
|
|||
|
|
'date_validite',
|
|||
|
|
'fichier',
|
|||
|
|
'description'
|
|||
|
|
]
|
|||
|
|
widgets = {
|
|||
|
|
'nom_document': forms.Select(attrs={'class': 'form-select'}),
|
|||
|
|
'description': forms.Textarea(attrs={'class': 'form-control', 'rows': 3}),
|
|||
|
|
'numero': forms.TextInput(attrs={'class': 'form-control'}),
|
|||
|
|
'date_validite': forms.DateInput(attrs={'class': 'form-control', 'type': 'date'}),
|
|||
|
|
'fichier': forms.ClearableFileInput(attrs={'class': 'form-control'}),
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
class ActiviteProjetForm(forms.ModelForm):
|
|||
|
|
"""Formulaire pour créer ou modifier une activité de projet, avec validation des champs et personnalisation des widgets."""
|
|||
|
|
class Meta:
|
|||
|
|
model = ActiviteProjet
|
|||
|
|
fields = (
|
|||
|
|
'titre',
|
|||
|
|
'date_debut',
|
|||
|
|
'date_fin',
|
|||
|
|
'besoin_ressource_materielle',
|
|||
|
|
'budget_prevu',
|
|||
|
|
'description',
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
widgets = {
|
|||
|
|
'titre':forms.TextInput(attrs={
|
|||
|
|
'class':'form-control',
|
|||
|
|
'placeholder':'Titre de l’activité'
|
|||
|
|
}),
|
|||
|
|
'description':forms.Textarea(attrs={
|
|||
|
|
'class':'form-control',
|
|||
|
|
'rows':3,
|
|||
|
|
'placeholder':'Description de l’activité'
|
|||
|
|
}),
|
|||
|
|
'date_debut':forms.DateInput(attrs={
|
|||
|
|
'class':'form-control',
|
|||
|
|
'type':'date'
|
|||
|
|
}),
|
|||
|
|
'date_fin':forms.DateInput(attrs={
|
|||
|
|
'class':'form-control',
|
|||
|
|
'type':'date'
|
|||
|
|
}),
|
|||
|
|
'besoin_ressource_materielle': forms.Textarea(attrs={
|
|||
|
|
'class':'form-control',
|
|||
|
|
'rows':3,
|
|||
|
|
'placeholder':'Besoin de ressources matérielles'
|
|||
|
|
}),
|
|||
|
|
'budget_prevu': forms.NumberInput(attrs={
|
|||
|
|
'class':'form-control',
|
|||
|
|
'placeholder':'Budget prévu'
|
|||
|
|
}),
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
class FinancementProjetFrom(forms.ModelForm):
|
|||
|
|
"""Formulaire pour créer ou modifier le financement relatif à un projet."""
|
|||
|
|
class Meta:
|
|||
|
|
model = FinancementProjet
|
|||
|
|
fields = (
|
|||
|
|
'projet',
|
|||
|
|
'bailleur',
|
|||
|
|
'pourcentage',
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
widgets = {
|
|||
|
|
'projet':forms.Select(attrs={
|
|||
|
|
'class':'form-select',
|
|||
|
|
}),
|
|||
|
|
'bailleur':forms.Select(attrs={
|
|||
|
|
'class':'form-select',
|
|||
|
|
}),
|
|||
|
|
'pourcentage':forms.NumberInput(attrs={
|
|||
|
|
'class':'form-control',
|
|||
|
|
}),
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
class LivrablesLivresForm(forms.ModelForm):
|
|||
|
|
"""Formulaire pour créer ou modifier un livrable livré dans le cadre d'une activité de projet."""
|
|||
|
|
class Meta:
|
|||
|
|
model = LivrablesLivres
|
|||
|
|
fields = (
|
|||
|
|
'activite',
|
|||
|
|
'nom',
|
|||
|
|
'fichier',
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
widgets = {
|
|||
|
|
'activite': forms.Select(attrs={
|
|||
|
|
'class':'form-select',
|
|||
|
|
}),
|
|||
|
|
'nom': forms.TextInput(attrs={
|
|||
|
|
'class':'form-control',
|
|||
|
|
'placeholder':'Nom du livrable'
|
|||
|
|
}),
|
|||
|
|
'fichier': forms.ClearableFileInput(attrs={
|
|||
|
|
'class':'form-control',
|
|||
|
|
}),
|
|||
|
|
}
|