diff --git a/.gitignore b/.gitignore index 2d1e761..dd45891 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ media/ staticfiles/ .env migrations/ +*.pyc \ No newline at end of file diff --git a/SIRH/__pycache__/__init__.cpython-310.pyc b/SIRH/__pycache__/__init__.cpython-310.pyc index 4fb9cb6..78d9696 100644 Binary files a/SIRH/__pycache__/__init__.cpython-310.pyc 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 index 180f602..1a69996 100644 Binary files a/SIRH/__pycache__/settings.cpython-310.pyc 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 index 1507cc0..c54e4be 100644 Binary files a/SIRH/__pycache__/urls.cpython-310.pyc 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 index 3ba4f66..612ae06 100644 Binary files a/SIRH/__pycache__/views.cpython-310.pyc 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 index 51f6382..4d358a4 100644 Binary files a/SIRH/__pycache__/wsgi.cpython-310.pyc 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 index a362d2a..73a176d 100644 Binary files a/fonction_utilitaire/__pycache__/fonctions_utilitaire.cpython-310.pyc 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 index 2f5762e..35500d6 100644 Binary files a/gestion_conge/__pycache__/__init__.cpython-310.pyc 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 index 1d36b5b..fdcb0d4 100644 Binary files a/gestion_conge/__pycache__/admin.cpython-310.pyc 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 index cd7b0cb..4277d0f 100644 Binary files a/gestion_conge/__pycache__/apps.cpython-310.pyc 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 index c10b7e0..697858f 100644 Binary files a/gestion_conge/__pycache__/forms.cpython-310.pyc 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 index 0d59d80..a1c070d 100644 Binary files a/gestion_conge/__pycache__/models.cpython-310.pyc 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 index 27a90f3..5d9dcb2 100644 Binary files a/gestion_conge/__pycache__/urls.cpython-310.pyc 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 index 1ad974f..a666076 100644 Binary files a/gestion_conge/__pycache__/views.cpython-310.pyc and b/gestion_conge/__pycache__/views.cpython-310.pyc differ diff --git a/gestion_conge/views.py b/gestion_conge/views.py index 338770c..6d9e0a6 100644 --- a/gestion_conge/views.py +++ b/gestion_conge/views.py @@ -135,66 +135,69 @@ def demander_conge(request): @login_required def liste_demande_conges(request): - """Vue de liste des demandes de congés en attente de validation selon le statut de l'utilisateur actuel""" + try: - employe = Employe.objects.get(user__username = request.user) + employe = Employe.objects.get(user=request.user) except Employe.DoesNotExist: return JsonResponse({ "success": False, - "message": "Votre profil Utilisateur n'est lié à aucun profil Employé. Veuillez contacter l'administrateur." + "message": "Profil employé introuvable" }) - try: - affectation = Affectation.objects.get( - employe=employe, - date_fin_daffectation__gte=timezone.now().date() - ) - except Affectation.DoesNotExist: - affectation = None + affectation = Affectation.objects.filter( + employe=employe, + date_fin_daffectation__gte=timezone.now().date() + ).first() + + is_direction = employe.user.groups.filter(name='direction').exists() if employe.chef: - print("chef") - conges_en_attente = Conge.objects.filter( - employe__departement = employe.departement, - validation_hierarchique = None + + conges = Conge.objects.filter( + Q(employe__departement=employe.departement) | + Q(employe=employe) ).order_by('-date_demande') elif affectation and affectation.role == "chef_projet": + employes_du_projet = Affectation.objects.filter( - projet = affectation.projet, - date_fin_daffectation__gte = timezone.now().date() - ).values('employe') + projet=affectation.projet, + date_fin_daffectation__gte=timezone.now().date() + ).values_list('employe', flat=True) - conges_en_attente = Conge.objects.filter( - employe__in = employes_du_projet, - validation_hierarchique = None + conges = Conge.objects.filter( + Q(employe__in=employes_du_projet) | + Q(employe=employe) ).order_by('-date_demande') - elif 'direction' in employe.user.groups.values_list('name', flat=True): - conges_en_attente = Conge.objects.filter( - validation_hierarchique = True, - validation_direction = None - ).order_by('-date_demande') + + elif is_direction: + + conges = Conge.objects.filter( + Q(validation_hierarchique=True) | + Q(employe__user__groups__name='direction') + ).distinct().order_by('-date_demande') else: - conges_en_attente = Conge.objects.filter( - employe__user__username = request.user + + conges = Conge.objects.filter( + employe=employe ).order_by('-date_demande') return JsonResponse({ "success": True, - "data":[ - { - **model_to_dict(conge), - "prenom_nom": f"{conge.employe.user.first_name} {conge.employe.user.last_name}", - "date_demande": conge.date_demande, - "nombre_jours": conge.nombre_jours, - "type": dict(conge.TYPE_CHOICES).get(conge.type), - "solde_conge": fonctions_utilitaire.solde_conge(conge.employe)["quota_annuel"] - } - for conge in conges_en_attente]}, - safe=False - ) + "data": [ + { + **model_to_dict(conge), + "prenom_nom": f"{conge.employe.user.first_name} {conge.employe.user.last_name}", + "date_demande": conge.date_demande, + "nombre_jours": conge.nombre_jours, + "type": dict(conge.TYPE_CHOICES).get(conge.type), + "solde_conge": fonctions_utilitaire.solde_conge(conge.employe)["quota_annuel"] + } + for conge in conges + ] + }) @login_required def validation_de_conge(request): diff --git a/gestion_employe/__pycache__/__init__.cpython-310.pyc b/gestion_employe/__pycache__/__init__.cpython-310.pyc index 446b36c..7eb8cf8 100644 Binary files a/gestion_employe/__pycache__/__init__.cpython-310.pyc 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 index 9e885bb..947a89b 100644 Binary files a/gestion_employe/__pycache__/admin.cpython-310.pyc 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 index f0df9aa..317d145 100644 Binary files a/gestion_employe/__pycache__/forms.cpython-310.pyc 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 index e64a2f5..5fe7a42 100644 Binary files a/gestion_employe/__pycache__/models.cpython-310.pyc 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 index c4747fb..cafc2f8 100644 Binary files a/gestion_employe/__pycache__/urls.cpython-310.pyc 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 index 01c8955..481b9bb 100644 Binary files a/gestion_employe/__pycache__/views.cpython-310.pyc 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 index cdb50e1..2dc6580 100644 Binary files a/gestion_employe/templatetags/__pycache__/tags_personnaliser.cpython-310.pyc and b/gestion_employe/templatetags/__pycache__/tags_personnaliser.cpython-310.pyc differ diff --git a/gestion_projet/__pycache__/__init__.cpython-310.pyc b/gestion_projet/__pycache__/__init__.cpython-310.pyc index 0164acf..0033989 100644 Binary files a/gestion_projet/__pycache__/__init__.cpython-310.pyc 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 index 4c5a626..ec3bca3 100644 Binary files a/gestion_projet/__pycache__/admin.cpython-310.pyc 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 index 90ef066..d9a0c6b 100644 Binary files a/gestion_projet/__pycache__/forms.cpython-310.pyc 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 index c057aea..884b5cc 100644 Binary files a/gestion_projet/__pycache__/models.cpython-310.pyc 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 index 6288b67..8383432 100644 Binary files a/gestion_projet/__pycache__/urls.cpython-310.pyc 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 index 5b82d00..5570f3f 100644 Binary files a/gestion_projet/__pycache__/views.cpython-310.pyc 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 index ae1b83c..85587a6 100644 Binary files a/gestion_salle/__pycache__/__init__.cpython-310.pyc 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 index 0b5c756..082cec0 100644 Binary files a/gestion_salle/__pycache__/admin.cpython-310.pyc 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 index 676e30c..3e0b9e8 100644 Binary files a/gestion_salle/__pycache__/apps.cpython-310.pyc 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 index d7b4374..15fd593 100644 Binary files a/gestion_salle/__pycache__/forms.cpython-310.pyc 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 index d02440b..563752a 100644 Binary files a/gestion_salle/__pycache__/models.cpython-310.pyc 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 index 2d9c5af..34c1e6f 100644 Binary files a/gestion_salle/__pycache__/urls.cpython-310.pyc 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 index 7119077..a8f37d8 100644 Binary files a/gestion_salle/__pycache__/views.cpython-310.pyc and b/gestion_salle/__pycache__/views.cpython-310.pyc differ