diff --git a/SIRH/__pycache__/urls.cpython-310.pyc b/SIRH/__pycache__/urls.cpython-310.pyc index dc00624..d2c4290 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 6835a9e..0b6bdbc 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 5c859c6..84b35a4 100644 Binary files a/SIRH/__pycache__/wsgi.cpython-310.pyc and b/SIRH/__pycache__/wsgi.cpython-310.pyc differ diff --git a/SIRH/settings.py b/SIRH/settings.py index 4fc57e3..d896f89 100644 --- a/SIRH/settings.py +++ b/SIRH/settings.py @@ -28,7 +28,7 @@ SECRET_KEY = config('SECRET_KEY') DEBUG = config('DEBUG', default=True, cast=bool) ALLOWED_HOSTS = config('ALLOWED_HOSTS', default=[]).split(',') -CSRF_TRUSTED_ORIGINS = config("CSRF_TRUSTED_ORIGINS", default=[]).split(",") +#CSRF_TRUSTED_ORIGINS = config("CSRF_TRUSTED_ORIGINS", default=[]).split(",") # Application definition @@ -67,6 +67,7 @@ TEMPLATES = [ 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', + 'contexte_universel.contexte_universel', ], }, }, @@ -145,9 +146,9 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' # LOGIN_URL = '/client/' LOGIN_URL = 'simple-sso-login' -SSO_PRIVATE_KEY = 'D2brFY3LnNDLQBBnvYPXAn185Wi9EpPvnHsUosjEZ9vZMyEtXqkcVfFWkVbN0xpG' -SSO_PUBLIC_KEY = 'm9JDP3uGPmGG9ULqPw2BY3ryBNMTGRsuukgIOhk7lIN9lT0wlr2zhoRZiNZ28UCM' -SSO_SERVER = 'http://test-authentification.cerfig.org:89/server/' +SSO_PRIVATE_KEY = config('SSO_PRIVATE_KEY') +SSO_PUBLIC_KEY = config('SSO_PUBLIC_KEY') +SSO_SERVER = config('SSO_SERVER') #SSO_LOGOUT_URL = 'http://test-authentification.cerfig.org:89/deconnexion' # Configuration de l'email diff --git a/SIRH/sso.py b/SIRH/sso.py index 52e4660..b9804f7 100644 --- a/SIRH/sso.py +++ b/SIRH/sso.py @@ -10,19 +10,25 @@ class SIRHClient(Client): def build_user(self, user_data): """Crée le User et son Profile avec les infos reçues du serveur.""" user_data_copy = user_data.copy() - user_data.pop("departement") - user_data.pop("chef_departement") - user_data.pop("groups") + + print("Un petit test", user_data_copy) + + user_data.pop("departement", None) + user_data.pop("chef_departement", None) + user_data.pop("groups", None) user = super().build_user(user_data) - departement = Departement.objects.get_or_create( - nom=user_data_copy.get("departement", ""))[0] + departement = None + + if "departement" in user_data_copy: + departement = Departement.objects.get_or_create( + nom=user_data_copy.get("departement", ""))[0] Employe.objects.update_or_create( user = user, defaults = { "departement": departement, - "chef": user_data_copy.get("chef_departement", ""), + "chef": user_data_copy.get("chef_departement", None), } ) @@ -30,4 +36,4 @@ class SIRHClient(Client): group, _ = Group.objects.get_or_create(name=group_name) user.groups.add(group) - return user \ No newline at end of file + return user diff --git a/SIRH/templates/SIRH/parts/menu_application.html b/SIRH/templates/SIRH/parts/menu_application.html index 0487437..8e9a8b0 100644 --- a/SIRH/templates/SIRH/parts/menu_application.html +++ b/SIRH/templates/SIRH/parts/menu_application.html @@ -1,5 +1,5 @@
- + SIRH diff --git a/SIRH/urls.py b/SIRH/urls.py index 7123c35..c0dea85 100644 --- a/SIRH/urls.py +++ b/SIRH/urls.py @@ -18,7 +18,7 @@ from django.contrib import admin from django.urls import include, path # from django.conf.urls.static import static from django.conf import settings - +from . import views from .sso import SIRHClient client_sirh = SIRHClient( @@ -28,35 +28,23 @@ client_sirh = SIRHClient( ) urlpatterns = [ - # path('login/', - # views.login_view, - # name='login' - # ), - # path( - # 'deconnexion/', - # views.deconnexion_view, - # name='deconnexion' - # ), - path( - '', -<<<<<<< HEAD - views.login_view, - name='index' - ), - path('login/', - views.login_view, + views.connexion, name='login' ), path( 'deconnexion/', - views.deconnexion_view, + views.deconnexion, name='deconnexion' ), path( +<<<<<<< HEAD 'gestion-employe/', ======= >>>>>>> 4934b42 (Implementation de sso) +======= + '', +>>>>>>> 55e5a28 (Ajout du contexte processor) include("gestion_employe.urls") ), path( @@ -77,4 +65,4 @@ urlpatterns = [ ), path("client/", include(client_sirh.get_urls())), ] -# + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \ No newline at end of file +# + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/SIRH/views.py b/SIRH/views.py index e69de29..43033bf 100644 --- a/SIRH/views.py +++ b/SIRH/views.py @@ -0,0 +1,16 @@ +from django.contrib.auth import logout +from django.shortcuts import redirect +from django.urls import reverse_lazy + +from django.conf import settings + + +def connexion(request): + """Redirige vers le serveur SSO pour l'authentification.""" + return redirect(reverse_lazy("simple-sso-login")) + +def deconnexion(request): + """Gérez la déconnexion des utilisateurs.""" + logout(request) + #return redirect(settings.SSO_LOGOUT_URL) + return redirect("http://authentification.cerfig.org/login") diff --git a/contexte_universel.py b/contexte_universel.py new file mode 100644 index 0000000..9cd578e --- /dev/null +++ b/contexte_universel.py @@ -0,0 +1,7 @@ +from decouple import config + +def contexte_universel(request): + return { + "SIRH_LIEN": config("SIRH_LIEN"), + "SGL_LIEN": config("SGL_LIEN") + } diff --git a/fonction_utilitaire/__pycache__/fonctions_utilitaire.cpython-310.pyc b/fonction_utilitaire/__pycache__/fonctions_utilitaire.cpython-310.pyc index 5d73229..10a8fe3 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/fonction_utilitaire/fonctions_utilitaire.py b/fonction_utilitaire/fonctions_utilitaire.py index d3a3203..e7ea8aa 100644 --- a/fonction_utilitaire/fonctions_utilitaire.py +++ b/fonction_utilitaire/fonctions_utilitaire.py @@ -7,14 +7,11 @@ QUOTA_CONGE_ANNUEL = 30 NOMBRE_PAGINATION = 8 DEBUT_RAPPEL = 60 DUREE_FIN_CONTRAT = 90 -<<<<<<< HEAD + try: EMAIL_ASSISTANTE_DE_DIRECTION = list(Employe.objects.filter(fonction="assistant_direction").values_list('user__email', flat=True)) except: pass -======= -# EMAIL_ASSISTANTE_DE_DIRECTION = list(Employe.objects.filter(fonction="assistant_direction").values_list('user__email', flat=True)) ->>>>>>> 4934b42 (Implementation de sso) def solde_conge(employe): """Fonction de calcul du solde de congé restant l'employé""" diff --git a/gestion_conge/__pycache__/__init__.cpython-310.pyc b/gestion_conge/__pycache__/__init__.cpython-310.pyc index 2e4e608..0f5db88 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 8403b94..4a98ea9 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 f5e111f..b934e94 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 a383b85..584a4e5 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 4106b10..8f3f204 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 1366049..64ad42b 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 0707546..82c3c23 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_employe/__pycache__/__init__.cpython-310.pyc b/gestion_employe/__pycache__/__init__.cpython-310.pyc index 662a150..d4b7498 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 363ddf7..a9c93d4 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 97052b4..222847a 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 0cae160..8294db7 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 9d78655..82c004c 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 fd6ee13..2efdd50 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 4b79428..53e7edd 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_employe/views.py b/gestion_employe/views.py index f1141c2..c9ded02 100644 --- a/gestion_employe/views.py +++ b/gestion_employe/views.py @@ -21,6 +21,9 @@ from .models import Affectation, Contrat, Employe, Formation @login_required def index(request): """Vue d'index""" + if not request.user.groups.filter(name="ressource_humaine").exists(): + return redirect('gestion_employe:mon-profil') + employes = Employe.objects.all().order_by('-user__date_joined') nombre_employes = Employe.objects.count() nombre_cps = Contrat.objects.filter(type_contrat='contrat_prestation').count() @@ -95,7 +98,7 @@ def affecter_employe_projet(request): elif total_affectation + temps_nouveau > 100: messages.warning( request, - f"Les pourcentages d'affectation de l'employé {employe.first_name} {employe.last_name} dépasse 100% sur les différents projets ({total_affectation + temps_nouveau}%)." + f"Les pourcentages d'affectation de l'employé {employe.user.first_name} {employe.user.last_name} dépasse 100% sur les différents projets ({total_affectation + temps_nouveau}%)." ) return redirect('gestion_employe:index') diff --git a/gestion_projet/__pycache__/__init__.cpython-310.pyc b/gestion_projet/__pycache__/__init__.cpython-310.pyc index 6f58d41..fc450d8 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 07787b7..961f983 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 a6a63c4..45f6f82 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 3b93566..c61251e 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 0b16c0e..288ccfa 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 dda1808..b1aa739 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 d70727c..97ed76c 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 b0a85f3..5199f49 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 e1f3990..6ffca1b 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 8d57e79..9ebd884 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 8a699eb..f284349 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 637f582..535d878 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 85a7479..3882920 100644 Binary files a/gestion_salle/__pycache__/views.cpython-310.pyc and b/gestion_salle/__pycache__/views.cpython-310.pyc differ