Relecture du code v1
This commit is contained in:
BIN
authentification/__init__.py:Zone.Identifier
Normal file
BIN
authentification/__init__.py:Zone.Identifier
Normal file
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.
Binary file not shown.
BIN
authentification/admin.py:Zone.Identifier
Normal file
BIN
authentification/admin.py:Zone.Identifier
Normal file
Binary file not shown.
BIN
authentification/apps.py:Zone.Identifier
Normal file
BIN
authentification/apps.py:Zone.Identifier
Normal file
Binary file not shown.
BIN
authentification/migrations/0001_initial.py:Zone.Identifier
Normal file
BIN
authentification/migrations/0001_initial.py:Zone.Identifier
Normal file
Binary file not shown.
BIN
authentification/migrations/__init__.py:Zone.Identifier
Normal file
BIN
authentification/migrations/__init__.py:Zone.Identifier
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
authentification/models.py:Zone.Identifier
Normal file
BIN
authentification/models.py:Zone.Identifier
Normal file
Binary file not shown.
Binary file not shown.
BIN
authentification/templatetags/__init__.py:Zone.Identifier
Normal file
BIN
authentification/templatetags/__init__.py:Zone.Identifier
Normal file
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.
@@ -1,16 +1,23 @@
|
||||
"""Tags personnalisés pour les templates d'authentification.
|
||||
|
||||
Ce fichier contient des tags personnalisés pour les templates du projet lié à
|
||||
la gestion de l'accès des utilisateurs aux différentes pages.
|
||||
"""
|
||||
|
||||
from django import template
|
||||
from authentification.models import Profile
|
||||
# from authentification.models import Profile
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.filter
|
||||
def has_group(user, group_name):
|
||||
"""Vérifiez si un utilisateur appartient à un groupe spécifique."""
|
||||
return user.groups.filter(name=group_name).exists()
|
||||
|
||||
|
||||
# On recupère l'utilisateur et le produit
|
||||
## Si l'utilisateur n'est pas le chef d'un département, afficher simplement ses demandes
|
||||
## Si l'utilisateur n'est pas le chef d'un département, afficher simplement ses
|
||||
# demandes
|
||||
## Si l'utilisateur est un chef de département
|
||||
### Afficher la liste de ses demandes
|
||||
### Verifier pour chaque demande que l'utilisateur appartient à son departement
|
||||
@@ -18,12 +25,12 @@ def has_group(user, group_name):
|
||||
#### Si non, ne pas afficher le produit
|
||||
|
||||
|
||||
@register.filter
|
||||
def affichage_demande(user, demande):
|
||||
if user.profile.chef_departement:
|
||||
chef_profile = Profile.objects.get(id=user.profile)
|
||||
departement = chef_profile.departement
|
||||
ids_profils_departement = Profile.objects.filter(departement=departement)["id"]
|
||||
# @register.filter
|
||||
# def affichage_demande(user, demande):
|
||||
# if user.profile.chef_departement:
|
||||
# chef_profile = Profile.objects.get(id=user.profile)
|
||||
# departement = chef_profile.departement
|
||||
# ids_profils_departement = Profile.objects.filter(departement=departement)["id"]
|
||||
|
||||
return demande.user_id in ids_profils_departement
|
||||
return user.profile.id == demande.user_id
|
||||
# return demande.user_id in ids_profils_departement
|
||||
# return user.profile.id == demande.user_id
|
||||
|
||||
Binary file not shown.
BIN
authentification/tests.py:Zone.Identifier
Normal file
BIN
authentification/tests.py:Zone.Identifier
Normal file
Binary file not shown.
BIN
authentification/urls.py:Zone.Identifier
Normal file
BIN
authentification/urls.py:Zone.Identifier
Normal file
Binary file not shown.
@@ -9,7 +9,6 @@ from SGL.views import index
|
||||
|
||||
def connexion(request):
|
||||
"""Gérez la connexion des utilisateurs."""
|
||||
authentification_echoue = False
|
||||
if request.method == "POST":
|
||||
username = request.POST["username"]
|
||||
password = request.POST["password"]
|
||||
@@ -24,7 +23,6 @@ def connexion(request):
|
||||
return render(
|
||||
request,
|
||||
"authentification/login.html",
|
||||
{"authentification_echoue": authentification_echoue},
|
||||
)
|
||||
|
||||
|
||||
|
||||
BIN
authentification/views.py:Zone.Identifier
Normal file
BIN
authentification/views.py:Zone.Identifier
Normal file
Binary file not shown.
Reference in New Issue
Block a user