Ajout du contexte processor
All checks were successful
Organisation/sirh/pipeline/head This commit looks good
All checks were successful
Organisation/sirh/pipeline/head This commit looks good
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -27,7 +27,7 @@ SECRET_KEY = config('SECRET_KEY')
|
|||||||
DEBUG = config('DEBUG', default=True, cast=bool)
|
DEBUG = config('DEBUG', default=True, cast=bool)
|
||||||
|
|
||||||
ALLOWED_HOSTS = config('ALLOWED_HOSTS', default=[]).split(',')
|
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
|
# Application definition
|
||||||
|
|
||||||
@@ -66,6 +66,7 @@ TEMPLATES = [
|
|||||||
'django.template.context_processors.request',
|
'django.template.context_processors.request',
|
||||||
'django.contrib.auth.context_processors.auth',
|
'django.contrib.auth.context_processors.auth',
|
||||||
'django.contrib.messages.context_processors.messages',
|
'django.contrib.messages.context_processors.messages',
|
||||||
|
'contexte_universel.contexte_universel',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -144,9 +145,9 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
|||||||
# LOGIN_URL = '/client/'
|
# LOGIN_URL = '/client/'
|
||||||
LOGIN_URL = 'simple-sso-login'
|
LOGIN_URL = 'simple-sso-login'
|
||||||
|
|
||||||
SSO_PRIVATE_KEY = 'D2brFY3LnNDLQBBnvYPXAn185Wi9EpPvnHsUosjEZ9vZMyEtXqkcVfFWkVbN0xpG'
|
SSO_PRIVATE_KEY = config('SSO_PRIVATE_KEY')
|
||||||
SSO_PUBLIC_KEY = 'm9JDP3uGPmGG9ULqPw2BY3ryBNMTGRsuukgIOhk7lIN9lT0wlr2zhoRZiNZ28UCM'
|
SSO_PUBLIC_KEY = config('SSO_PUBLIC_KEY')
|
||||||
SSO_SERVER = 'http://test-authentification.cerfig.org:89/server/'
|
SSO_SERVER = config('SSO_SERVER')
|
||||||
#SSO_LOGOUT_URL = 'http://test-authentification.cerfig.org:89/deconnexion'
|
#SSO_LOGOUT_URL = 'http://test-authentification.cerfig.org:89/deconnexion'
|
||||||
|
|
||||||
# Configuration de l'email
|
# Configuration de l'email
|
||||||
|
|||||||
20
SIRH/sso.py
20
SIRH/sso.py
@@ -10,19 +10,25 @@ class SIRHClient(Client):
|
|||||||
def build_user(self, user_data):
|
def build_user(self, user_data):
|
||||||
"""Crée le User et son Profile avec les infos reçues du serveur."""
|
"""Crée le User et son Profile avec les infos reçues du serveur."""
|
||||||
user_data_copy = user_data.copy()
|
user_data_copy = user_data.copy()
|
||||||
user_data.pop("departement")
|
|
||||||
user_data.pop("chef_departement")
|
print("Un petit test", user_data_copy)
|
||||||
user_data.pop("groups")
|
|
||||||
|
user_data.pop("departement", None)
|
||||||
|
user_data.pop("chef_departement", None)
|
||||||
|
user_data.pop("groups", None)
|
||||||
|
|
||||||
user = super().build_user(user_data)
|
user = super().build_user(user_data)
|
||||||
departement = Departement.objects.get_or_create(
|
departement = None
|
||||||
nom=user_data_copy.get("departement", ""))[0]
|
|
||||||
|
if "departement" in user_data_copy:
|
||||||
|
departement = Departement.objects.get_or_create(
|
||||||
|
nom=user_data_copy.get("departement", ""))[0]
|
||||||
|
|
||||||
Employe.objects.update_or_create(
|
Employe.objects.update_or_create(
|
||||||
user = user,
|
user = user,
|
||||||
defaults = {
|
defaults = {
|
||||||
"departement": departement,
|
"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)
|
group, _ = Group.objects.get_or_create(name=group_name)
|
||||||
user.groups.add(group)
|
user.groups.add(group)
|
||||||
|
|
||||||
return user
|
return user
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<div class="col-1 bg-danger border d-flex flex-column vh-100 pt-5 sticky-top">
|
<div class="col-1 bg-danger border d-flex flex-column vh-100 pt-5 sticky-top">
|
||||||
<a href="http://test-sirh.cerfig.org:89/" class="text-white text-center fw-bold text-decoration-none mb-4" style="font-size:1.4em">
|
<a href="{{ SIRH_LIEN }}" class="text-white text-center fw-bold text-decoration-none mb-4" style="font-size:1.4em">
|
||||||
<i class="bi bi-people-fill fs-1 d-block"></i>SIRH
|
<i class="bi bi-people-fill fs-1 d-block"></i>SIRH
|
||||||
</a>
|
</a>
|
||||||
<a href="http://test-sgl.cerfig.org:89/" class="text-white text-center fw-bold text-decoration-none mb-4" style="font-size:1.4em">
|
<a href="{{ SGL_LIEN }}" class="text-white text-center fw-bold text-decoration-none mb-4" style="font-size:1.4em">
|
||||||
<i class="bi bi-building-gear fs-1 d-block"></i> SGL
|
<i class="bi bi-building-gear fs-1 d-block"></i> SGL
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
<i class="bi bi-calendar-check"></i> Réservation
|
<i class="bi bi-calendar-check"></i> Réservation
|
||||||
</a>
|
</a>
|
||||||
{% comment %} {% url 'deconnexion' %} {% endcomment %}
|
{% comment %} {% url 'deconnexion' %} {% endcomment %}
|
||||||
<a href="http://test-authentification.cerfig.org:89/deconnexion" class="text-white fw-bold text-decoration-none mb-4" style="font-size: 1.2em;">
|
<a href="{% url 'deconnexion' %}" class="text-white fw-bold text-decoration-none mb-4" style="font-size: 1.2em;">
|
||||||
<i class="bi bi-box-arrow-right"></i> Déconnexion
|
<i class="bi bi-box-arrow-right"></i> Déconnexion
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
28
SIRH/urls.py
28
SIRH/urls.py
@@ -18,7 +18,7 @@ from django.contrib import admin
|
|||||||
from django.urls import include, path
|
from django.urls import include, path
|
||||||
# from django.conf.urls.static import static
|
# from django.conf.urls.static import static
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from . import views
|
||||||
from .sso import SIRHClient
|
from .sso import SIRHClient
|
||||||
|
|
||||||
client_sirh = SIRHClient(
|
client_sirh = SIRHClient(
|
||||||
@@ -28,35 +28,17 @@ client_sirh = SIRHClient(
|
|||||||
)
|
)
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
# path('login/',
|
|
||||||
# views.login_view,
|
|
||||||
# name='login'
|
|
||||||
# ),
|
|
||||||
# path(
|
|
||||||
# 'deconnexion/',
|
|
||||||
# views.deconnexion_view,
|
|
||||||
# name='deconnexion'
|
|
||||||
# ),
|
|
||||||
path(
|
|
||||||
'',
|
|
||||||
<<<<<<< HEAD
|
|
||||||
views.login_view,
|
|
||||||
name='index'
|
|
||||||
),
|
|
||||||
|
|
||||||
path('login/',
|
path('login/',
|
||||||
views.login_view,
|
views.connexion,
|
||||||
name='login'
|
name='login'
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
'deconnexion/',
|
'deconnexion/',
|
||||||
views.deconnexion_view,
|
views.deconnexion,
|
||||||
name='deconnexion'
|
name='deconnexion'
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
'gestion-employe/',
|
'',
|
||||||
=======
|
|
||||||
>>>>>>> staging
|
|
||||||
include("gestion_employe.urls")
|
include("gestion_employe.urls")
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
@@ -77,4 +59,4 @@ urlpatterns = [
|
|||||||
),
|
),
|
||||||
path("client/", include(client_sirh.get_urls())),
|
path("client/", include(client_sirh.get_urls())),
|
||||||
]
|
]
|
||||||
# + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
# + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
|
|||||||
@@ -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")
|
||||||
|
|||||||
7
contexte_universel.py
Normal file
7
contexte_universel.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
from decouple import config
|
||||||
|
|
||||||
|
def contexte_universel(request):
|
||||||
|
return {
|
||||||
|
"SIRH_LIEN": config("SIRH_LIEN"),
|
||||||
|
"SGL_LIEN": config("SGL_LIEN")
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -7,14 +7,11 @@ QUOTA_CONGE_ANNUEL = 30
|
|||||||
NOMBRE_PAGINATION = 8
|
NOMBRE_PAGINATION = 8
|
||||||
DEBUT_RAPPEL = 60
|
DEBUT_RAPPEL = 60
|
||||||
DUREE_FIN_CONTRAT = 90
|
DUREE_FIN_CONTRAT = 90
|
||||||
<<<<<<< HEAD
|
|
||||||
try:
|
try:
|
||||||
EMAIL_ASSISTANTE_DE_DIRECTION = list(Employe.objects.filter(fonction="assistant_direction").values_list('user__email', flat=True))
|
EMAIL_ASSISTANTE_DE_DIRECTION = list(Employe.objects.filter(fonction="assistant_direction").values_list('user__email', flat=True))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
=======
|
|
||||||
# EMAIL_ASSISTANTE_DE_DIRECTION = list(Employe.objects.filter(fonction="assistant_direction").values_list('user__email', flat=True))
|
|
||||||
>>>>>>> staging
|
|
||||||
|
|
||||||
def solde_conge(employe):
|
def solde_conge(employe):
|
||||||
"""Fonction de calcul du solde de congé restant l'employé"""
|
"""Fonction de calcul du solde de congé restant l'employé"""
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -20,6 +20,9 @@ from fonction_utilitaire import fonctions_utilitaire
|
|||||||
@login_required
|
@login_required
|
||||||
def index(request):
|
def index(request):
|
||||||
"""Vue d'index"""
|
"""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')
|
employes = Employe.objects.all().order_by('-user__date_joined')
|
||||||
nombre_employes = Employe.objects.count()
|
nombre_employes = Employe.objects.count()
|
||||||
nombre_cps = Contrat.objects.filter(type_contrat='contrat_prestation').count()
|
nombre_cps = Contrat.objects.filter(type_contrat='contrat_prestation').count()
|
||||||
@@ -94,7 +97,7 @@ def affecter_employe_projet(request):
|
|||||||
elif total_affectation + temps_nouveau > 100:
|
elif total_affectation + temps_nouveau > 100:
|
||||||
messages.warning(
|
messages.warning(
|
||||||
request,
|
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')
|
return redirect('gestion_employe:index')
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user