diff --git a/SIRH/__pycache__/__init__.cpython-310.pyc b/SIRH/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..5e35e10 Binary files /dev/null and b/SIRH/__pycache__/__init__.cpython-310.pyc differ diff --git a/SIRH/__pycache__/settings.cpython-310.pyc b/SIRH/__pycache__/settings.cpython-310.pyc new file mode 100644 index 0000000..f05b619 Binary files /dev/null and b/SIRH/__pycache__/settings.cpython-310.pyc differ diff --git a/SIRH/__pycache__/urls.cpython-310.pyc b/SIRH/__pycache__/urls.cpython-310.pyc new file mode 100644 index 0000000..6e6a5ff Binary files /dev/null and b/SIRH/__pycache__/urls.cpython-310.pyc differ diff --git a/SIRH/__pycache__/views.cpython-310.pyc b/SIRH/__pycache__/views.cpython-310.pyc new file mode 100644 index 0000000..7c3081c Binary files /dev/null and b/SIRH/__pycache__/views.cpython-310.pyc differ diff --git a/SIRH/__pycache__/wsgi.cpython-310.pyc b/SIRH/__pycache__/wsgi.cpython-310.pyc new file mode 100644 index 0000000..d453f99 Binary files /dev/null and b/SIRH/__pycache__/wsgi.cpython-310.pyc differ diff --git a/fonction_utilitaire/__pycache__/fonctions_utilitaire.cpython-310.pyc b/fonction_utilitaire/__pycache__/fonctions_utilitaire.cpython-310.pyc new file mode 100644 index 0000000..3ff9247 Binary files /dev/null and b/fonction_utilitaire/__pycache__/fonctions_utilitaire.cpython-310.pyc differ diff --git a/gestion_conge/__pycache__/__init__.cpython-310.pyc b/gestion_conge/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..a6a2b7f Binary files /dev/null and b/gestion_conge/__pycache__/__init__.cpython-310.pyc differ diff --git a/gestion_conge/__pycache__/admin.cpython-310.pyc b/gestion_conge/__pycache__/admin.cpython-310.pyc new file mode 100644 index 0000000..f0233de Binary files /dev/null and b/gestion_conge/__pycache__/admin.cpython-310.pyc differ diff --git a/gestion_conge/__pycache__/apps.cpython-310.pyc b/gestion_conge/__pycache__/apps.cpython-310.pyc new file mode 100644 index 0000000..1445f2b Binary files /dev/null and b/gestion_conge/__pycache__/apps.cpython-310.pyc differ diff --git a/gestion_conge/__pycache__/forms.cpython-310.pyc b/gestion_conge/__pycache__/forms.cpython-310.pyc new file mode 100644 index 0000000..5dd4fa0 Binary files /dev/null and b/gestion_conge/__pycache__/forms.cpython-310.pyc differ diff --git a/gestion_conge/__pycache__/models.cpython-310.pyc b/gestion_conge/__pycache__/models.cpython-310.pyc new file mode 100644 index 0000000..6ff9b49 Binary files /dev/null and b/gestion_conge/__pycache__/models.cpython-310.pyc differ diff --git a/gestion_conge/__pycache__/urls.cpython-310.pyc b/gestion_conge/__pycache__/urls.cpython-310.pyc new file mode 100644 index 0000000..f60e9ec Binary files /dev/null and b/gestion_conge/__pycache__/urls.cpython-310.pyc differ diff --git a/gestion_conge/__pycache__/views.cpython-310.pyc b/gestion_conge/__pycache__/views.cpython-310.pyc new file mode 100644 index 0000000..53bdfa6 Binary files /dev/null and b/gestion_conge/__pycache__/views.cpython-310.pyc differ diff --git a/gestion_employe/__pycache__/__init__.cpython-310.pyc b/gestion_employe/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..f3cb21d Binary files /dev/null and b/gestion_employe/__pycache__/__init__.cpython-310.pyc differ diff --git a/gestion_employe/__pycache__/admin.cpython-310.pyc b/gestion_employe/__pycache__/admin.cpython-310.pyc new file mode 100644 index 0000000..05b664a Binary files /dev/null and b/gestion_employe/__pycache__/admin.cpython-310.pyc differ diff --git a/gestion_employe/__pycache__/forms.cpython-310.pyc b/gestion_employe/__pycache__/forms.cpython-310.pyc new file mode 100644 index 0000000..b5463d9 Binary files /dev/null and b/gestion_employe/__pycache__/forms.cpython-310.pyc differ diff --git a/gestion_employe/__pycache__/models.cpython-310.pyc b/gestion_employe/__pycache__/models.cpython-310.pyc new file mode 100644 index 0000000..6cc8588 Binary files /dev/null and b/gestion_employe/__pycache__/models.cpython-310.pyc differ diff --git a/gestion_employe/__pycache__/urls.cpython-310.pyc b/gestion_employe/__pycache__/urls.cpython-310.pyc new file mode 100644 index 0000000..a10b192 Binary files /dev/null and b/gestion_employe/__pycache__/urls.cpython-310.pyc differ diff --git a/gestion_employe/__pycache__/views.cpython-310.pyc b/gestion_employe/__pycache__/views.cpython-310.pyc new file mode 100644 index 0000000..4d272bc Binary files /dev/null and b/gestion_employe/__pycache__/views.cpython-310.pyc differ diff --git a/gestion_employe/templatetags/__pycache__/tags_personnaliser.cpython-310.pyc b/gestion_employe/templatetags/__pycache__/tags_personnaliser.cpython-310.pyc new file mode 100644 index 0000000..f098287 Binary files /dev/null and b/gestion_employe/templatetags/__pycache__/tags_personnaliser.cpython-310.pyc differ diff --git a/gestion_employe/views.py b/gestion_employe/views.py index be04a7f..dc61818 100644 --- a/gestion_employe/views.py +++ b/gestion_employe/views.py @@ -1,5 +1,5 @@ import json -from datetime import timedelta, datetime +from datetime import date, timedelta, datetime from dateutil.relativedelta import relativedelta from django.utils import timezone @@ -247,14 +247,25 @@ def suppression_affectation(request): return JsonResponse({"message": "Affectation supprimée avec succès."}) def creation_contrat(request): - """Vue pour permettre à un utilisateur de créer un contrat pour un employé""" + """Créer un contrat pour un employé (avec contrôle d'existence de contrat actif)""" + try: employe = Employe.objects.get(id=request.POST.get('employe_id')) except Employe.DoesNotExist: messages.error(request, "Employé non trouvé.") return redirect('employe-index') - + contrat_actif = Contrat.objects.filter( + employe=employe, + date_fin__gte=date.today() + ).exists() + if request.method == "POST": + if contrat_actif: + messages.error( + request, + "Impossible de créer un contrat : cet employé a déjà un contrat actif." + ) + return redirect('gestion_employe:index') form = ContratForm(request.POST, request.FILES) if form.is_valid(): contrat = form.save(commit=False) @@ -263,9 +274,13 @@ def creation_contrat(request): messages.success(request, "Contrat créé avec succès.") return redirect('gestion_employe:index') messages.error(request, "Formulaire non valide") + else: form = ContratForm(initial={'employe': employe}) - return render(request, 'gestion_employe/index.html', {'contrat_form': form}) + + return render(request, 'gestion_employe/index.html', { + 'contrat_form': form + }) @login_required def enregistrer_detail_employe(request): diff --git a/gestion_projet/__pycache__/__init__.cpython-310.pyc b/gestion_projet/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..a8f2514 Binary files /dev/null and b/gestion_projet/__pycache__/__init__.cpython-310.pyc differ diff --git a/gestion_projet/__pycache__/admin.cpython-310.pyc b/gestion_projet/__pycache__/admin.cpython-310.pyc new file mode 100644 index 0000000..390b1e1 Binary files /dev/null and b/gestion_projet/__pycache__/admin.cpython-310.pyc differ diff --git a/gestion_projet/__pycache__/forms.cpython-310.pyc b/gestion_projet/__pycache__/forms.cpython-310.pyc new file mode 100644 index 0000000..e3e023b Binary files /dev/null and b/gestion_projet/__pycache__/forms.cpython-310.pyc differ diff --git a/gestion_projet/__pycache__/models.cpython-310.pyc b/gestion_projet/__pycache__/models.cpython-310.pyc new file mode 100644 index 0000000..e1e2a52 Binary files /dev/null and b/gestion_projet/__pycache__/models.cpython-310.pyc differ diff --git a/gestion_projet/__pycache__/urls.cpython-310.pyc b/gestion_projet/__pycache__/urls.cpython-310.pyc new file mode 100644 index 0000000..4889252 Binary files /dev/null and b/gestion_projet/__pycache__/urls.cpython-310.pyc differ diff --git a/gestion_projet/__pycache__/views.cpython-310.pyc b/gestion_projet/__pycache__/views.cpython-310.pyc new file mode 100644 index 0000000..28ad673 Binary files /dev/null and b/gestion_projet/__pycache__/views.cpython-310.pyc differ diff --git a/gestion_salle/__pycache__/__init__.cpython-310.pyc b/gestion_salle/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..4901dbb Binary files /dev/null and b/gestion_salle/__pycache__/__init__.cpython-310.pyc differ diff --git a/gestion_salle/__pycache__/admin.cpython-310.pyc b/gestion_salle/__pycache__/admin.cpython-310.pyc new file mode 100644 index 0000000..01450da Binary files /dev/null and b/gestion_salle/__pycache__/admin.cpython-310.pyc differ diff --git a/gestion_salle/__pycache__/apps.cpython-310.pyc b/gestion_salle/__pycache__/apps.cpython-310.pyc new file mode 100644 index 0000000..2bd8901 Binary files /dev/null and b/gestion_salle/__pycache__/apps.cpython-310.pyc differ diff --git a/gestion_salle/__pycache__/forms.cpython-310.pyc b/gestion_salle/__pycache__/forms.cpython-310.pyc new file mode 100644 index 0000000..4ed6625 Binary files /dev/null and b/gestion_salle/__pycache__/forms.cpython-310.pyc differ diff --git a/gestion_salle/__pycache__/models.cpython-310.pyc b/gestion_salle/__pycache__/models.cpython-310.pyc new file mode 100644 index 0000000..1d327ec Binary files /dev/null and b/gestion_salle/__pycache__/models.cpython-310.pyc differ diff --git a/gestion_salle/__pycache__/urls.cpython-310.pyc b/gestion_salle/__pycache__/urls.cpython-310.pyc new file mode 100644 index 0000000..794fb5d Binary files /dev/null and b/gestion_salle/__pycache__/urls.cpython-310.pyc differ diff --git a/gestion_salle/__pycache__/views.cpython-310.pyc b/gestion_salle/__pycache__/views.cpython-310.pyc new file mode 100644 index 0000000..aa6461b Binary files /dev/null and b/gestion_salle/__pycache__/views.cpython-310.pyc differ