Relecture du code v1
This commit is contained in:
BIN
.coverage:Zone.Identifier
Normal file
BIN
.coverage:Zone.Identifier
Normal file
Binary file not shown.
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
.ruff_cache/
|
.ruff_cache/
|
||||||
.coverage
|
.coverage
|
||||||
db.sqlite3
|
db.sqlite3
|
||||||
|
__pycache__/*.pyc
|
||||||
BIN
.gitignore:Zone.Identifier
Normal file
BIN
.gitignore:Zone.Identifier
Normal file
Binary file not shown.
BIN
SGL/__init__.py:Zone.Identifier
Normal file
BIN
SGL/__init__.py:Zone.Identifier
Normal file
Binary file not shown.
BIN
SGL/__pycache__/__init__.cpython-310.pyc:Zone.Identifier
Normal file
BIN
SGL/__pycache__/__init__.cpython-310.pyc:Zone.Identifier
Normal file
Binary file not shown.
BIN
SGL/__pycache__/__init__.cpython-313.pyc:Zone.Identifier
Normal file
BIN
SGL/__pycache__/__init__.cpython-313.pyc:Zone.Identifier
Normal file
Binary file not shown.
BIN
SGL/__pycache__/settings.cpython-310.pyc:Zone.Identifier
Normal file
BIN
SGL/__pycache__/settings.cpython-310.pyc:Zone.Identifier
Normal file
Binary file not shown.
BIN
SGL/__pycache__/settings.cpython-313.pyc:Zone.Identifier
Normal file
BIN
SGL/__pycache__/settings.cpython-313.pyc:Zone.Identifier
Normal file
Binary file not shown.
Binary file not shown.
BIN
SGL/__pycache__/urls.cpython-310.pyc:Zone.Identifier
Normal file
BIN
SGL/__pycache__/urls.cpython-310.pyc:Zone.Identifier
Normal file
Binary file not shown.
BIN
SGL/__pycache__/urls.cpython-313.pyc:Zone.Identifier
Normal file
BIN
SGL/__pycache__/urls.cpython-313.pyc:Zone.Identifier
Normal file
Binary file not shown.
Binary file not shown.
BIN
SGL/__pycache__/views.cpython-310.pyc:Zone.Identifier
Normal file
BIN
SGL/__pycache__/views.cpython-310.pyc:Zone.Identifier
Normal file
Binary file not shown.
BIN
SGL/__pycache__/views.cpython-313.pyc:Zone.Identifier
Normal file
BIN
SGL/__pycache__/views.cpython-313.pyc:Zone.Identifier
Normal file
Binary file not shown.
BIN
SGL/__pycache__/wsgi.cpython-310.pyc:Zone.Identifier
Normal file
BIN
SGL/__pycache__/wsgi.cpython-310.pyc:Zone.Identifier
Normal file
Binary file not shown.
BIN
SGL/__pycache__/wsgi.cpython-313.pyc:Zone.Identifier
Normal file
BIN
SGL/__pycache__/wsgi.cpython-313.pyc:Zone.Identifier
Normal file
Binary file not shown.
BIN
SGL/asgi.py:Zone.Identifier
Normal file
BIN
SGL/asgi.py:Zone.Identifier
Normal file
Binary file not shown.
BIN
SGL/settings.py:Zone.Identifier
Normal file
BIN
SGL/settings.py:Zone.Identifier
Normal file
Binary file not shown.
BIN
SGL/templates/BASE.html:Zone.Identifier
Normal file
BIN
SGL/templates/BASE.html:Zone.Identifier
Normal file
Binary file not shown.
BIN
SGL/templates/emails/email_template.html:Zone.Identifier
Normal file
BIN
SGL/templates/emails/email_template.html:Zone.Identifier
Normal file
Binary file not shown.
@@ -124,6 +124,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<form action="">
|
<form action="">
|
||||||
|
{% csrf_token %}
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="produit" class="form-label">Produit</label>
|
<label for="produit" class="form-label">Produit</label>
|
||||||
<input type="text" class="form-control" id="produitCommande" readonly>
|
<input type="text" class="form-control" id="produitCommande" readonly>
|
||||||
|
|||||||
BIN
SGL/templates/index.html:Zone.Identifier
Normal file
BIN
SGL/templates/index.html:Zone.Identifier
Normal file
Binary file not shown.
26
SGL/urls.py
26
SGL/urls.py
@@ -26,11 +26,27 @@ from django.conf.urls.static import static
|
|||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("", views.index, name="index"),
|
path(
|
||||||
path("gestion-produit/", include("gestion_produit.urls")),
|
"",
|
||||||
path("gestion-fournisseur/", include("gestion_fournisseur.urls")),
|
views.index,
|
||||||
path("gestion-vehicule/", include("gestion_vehicule.urls")),
|
name="index"
|
||||||
path("authentification/", include("authentification.urls")),
|
),
|
||||||
|
path(
|
||||||
|
"gestion-produit/",
|
||||||
|
include("gestion_produit.urls")
|
||||||
|
),
|
||||||
|
path(
|
||||||
|
"gestion-fournisseur/",
|
||||||
|
include("gestion_fournisseur.urls")
|
||||||
|
),
|
||||||
|
path(
|
||||||
|
"gestion-vehicule/",
|
||||||
|
include("gestion_vehicule.urls")
|
||||||
|
),
|
||||||
|
path(
|
||||||
|
"authentification/",
|
||||||
|
include("authentification.urls")
|
||||||
|
),
|
||||||
path(
|
path(
|
||||||
"liste-commande-en-cours/",
|
"liste-commande-en-cours/",
|
||||||
views.liste_produit_commander,
|
views.liste_produit_commander,
|
||||||
|
|||||||
BIN
SGL/urls.py:Zone.Identifier
Normal file
BIN
SGL/urls.py:Zone.Identifier
Normal file
Binary file not shown.
31
SGL/views.py
31
SGL/views.py
@@ -9,7 +9,7 @@ Principales fonctionnalités couvertes :
|
|||||||
from django.shortcuts import render, redirect
|
from django.shortcuts import render, redirect
|
||||||
from django.http import JsonResponse
|
from django.http import JsonResponse
|
||||||
from gestion_produit.models import Commander, Demander, Produit
|
from gestion_produit.models import Commander, Demander, Produit
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
# from django.views.decorators.csrf import csrf_exempt
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
|
|
||||||
import json
|
import json
|
||||||
@@ -29,10 +29,6 @@ def dashboard_quantite_produit():
|
|||||||
"""
|
"""
|
||||||
tous_les_produits = Produit.objects.all()
|
tous_les_produits = Produit.objects.all()
|
||||||
|
|
||||||
nombre_rupture = 0
|
|
||||||
nombre_pre_rupture = 0
|
|
||||||
nombre_normal = 0
|
|
||||||
|
|
||||||
produit_rupture = []
|
produit_rupture = []
|
||||||
produit_pre_rupture = []
|
produit_pre_rupture = []
|
||||||
produit_normal = []
|
produit_normal = []
|
||||||
@@ -41,19 +37,16 @@ def dashboard_quantite_produit():
|
|||||||
stock_actuel = calcul_stock_produit(produit)
|
stock_actuel = calcul_stock_produit(produit)
|
||||||
stock_actuel.pop("image")
|
stock_actuel.pop("image")
|
||||||
if stock_actuel["stockActuel"] == 0:
|
if stock_actuel["stockActuel"] == 0:
|
||||||
nombre_rupture += 1
|
|
||||||
produit_rupture.append(stock_actuel)
|
produit_rupture.append(stock_actuel)
|
||||||
elif stock_actuel["stockActuel"] < produit.seuil_pre_rupture:
|
elif stock_actuel["stockActuel"] < produit.seuil_pre_rupture:
|
||||||
nombre_pre_rupture += 1
|
|
||||||
produit_pre_rupture.append(stock_actuel)
|
produit_pre_rupture.append(stock_actuel)
|
||||||
else:
|
else:
|
||||||
nombre_normal += 1
|
|
||||||
produit_normal.append(stock_actuel)
|
produit_normal.append(stock_actuel)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"nombre_rupture": nombre_rupture,
|
"nombre_rupture": len(produit_rupture),
|
||||||
"nombre_pre_rupture": nombre_pre_rupture,
|
"nombre_pre_rupture": len(produit_pre_rupture),
|
||||||
"nombre_normal": nombre_normal,
|
"nombre_normal": len(produit_normal),
|
||||||
"produit_rupture": produit_rupture,
|
"produit_rupture": produit_rupture,
|
||||||
"produit_pre_rupture": produit_pre_rupture,
|
"produit_pre_rupture": produit_pre_rupture,
|
||||||
"produit_normale": produit_normal,
|
"produit_normale": produit_normal,
|
||||||
@@ -62,7 +55,7 @@ def dashboard_quantite_produit():
|
|||||||
|
|
||||||
@login_required(login_url="authentification:login")
|
@login_required(login_url="authentification:login")
|
||||||
def index(request):
|
def index(request):
|
||||||
"""Vue pour la page d'accueil du dashboard.
|
"""Retournez la page d'accueil du dashboard.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
@@ -104,10 +97,9 @@ def index(request):
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@login_required(login_url="login")
|
@login_required(login_url="login")
|
||||||
def produit_a_rendre(request): #noqa: ARG001
|
def produit_a_rendre(_request):
|
||||||
"""Vue pour obtenir la liste des équipements à rendre.
|
"""Retournez la liste des équipements à rendre.
|
||||||
|
|
||||||
Cette vue est appelée via une requête AJAX et renvoie une liste
|
Cette vue est appelée via une requête AJAX et renvoie une liste
|
||||||
d'équipements qui doivent être rendus.
|
d'équipements qui doivent être rendus.
|
||||||
@@ -141,9 +133,8 @@ def produit_a_rendre(request): #noqa: ARG001
|
|||||||
return JsonResponse(liste_equipement, safe=False)
|
return JsonResponse(liste_equipement, safe=False)
|
||||||
|
|
||||||
@login_required(login_url="login")
|
@login_required(login_url="login")
|
||||||
@csrf_exempt
|
|
||||||
def produit_a_rendre_update(request):
|
def produit_a_rendre_update(request):
|
||||||
"""Vue pour mettre à jour le statut des équipements à rendre.
|
"""Mettez à jour le statut des équipements à rendre.
|
||||||
|
|
||||||
Lorsqu'une requête POST est reçue, cette vue met à jour le statut
|
Lorsqu'une requête POST est reçue, cette vue met à jour le statut
|
||||||
des équipements à rendre en fonction des données fournies dans la
|
des équipements à rendre en fonction des données fournies dans la
|
||||||
@@ -248,7 +239,6 @@ def liste_produit_commander(request):
|
|||||||
|
|
||||||
|
|
||||||
@login_required(login_url="login")
|
@login_required(login_url="login")
|
||||||
@csrf_exempt
|
|
||||||
def enregistrer_livraison_produit(request):
|
def enregistrer_livraison_produit(request):
|
||||||
"""Enregistrez la livraison d'un produit commandé.
|
"""Enregistrez la livraison d'un produit commandé.
|
||||||
|
|
||||||
@@ -322,7 +312,10 @@ def liste_demandes(request):
|
|||||||
"produit": demande.produit.libelle,
|
"produit": demande.produit.libelle,
|
||||||
"quantite": demande.quantite,
|
"quantite": demande.quantite,
|
||||||
"motifs": demande.motifs,
|
"motifs": demande.motifs,
|
||||||
"date_de_mise_a_dispo_souhaite": demande.date_de_mise_a_dispo_souhaite.strftime("%Y-%m-%d"),
|
"date_de_mise_a_dispo_souhaite": (
|
||||||
|
demande.date_de_mise_a_dispo_souhaite
|
||||||
|
.strftime("%Y-%m-%d")
|
||||||
|
),
|
||||||
"a_rendre": demande.a_rendre,
|
"a_rendre": demande.a_rendre,
|
||||||
"valider_par_chef": demande.valider_par_chef,
|
"valider_par_chef": demande.valider_par_chef,
|
||||||
"valider_par_logisticien": demande.valider_par_logisticien,
|
"valider_par_logisticien": demande.valider_par_logisticien,
|
||||||
|
|||||||
BIN
SGL/views.py:Zone.Identifier
Normal file
BIN
SGL/views.py:Zone.Identifier
Normal file
Binary file not shown.
BIN
SGL/wsgi.py:Zone.Identifier
Normal file
BIN
SGL/wsgi.py:Zone.Identifier
Normal file
Binary file not shown.
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 django import template
|
||||||
from authentification.models import Profile
|
# from authentification.models import Profile
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
@register.filter
|
@register.filter
|
||||||
def has_group(user, group_name):
|
def has_group(user, group_name):
|
||||||
|
"""Vérifiez si un utilisateur appartient à un groupe spécifique."""
|
||||||
return user.groups.filter(name=group_name).exists()
|
return user.groups.filter(name=group_name).exists()
|
||||||
|
|
||||||
|
|
||||||
# On recupère l'utilisateur et le produit
|
# 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
|
## Si l'utilisateur est un chef de département
|
||||||
### Afficher la liste de ses demandes
|
### Afficher la liste de ses demandes
|
||||||
### Verifier pour chaque demande que l'utilisateur appartient à son departement
|
### 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
|
#### Si non, ne pas afficher le produit
|
||||||
|
|
||||||
|
|
||||||
@register.filter
|
# @register.filter
|
||||||
def affichage_demande(user, demande):
|
# def affichage_demande(user, demande):
|
||||||
if user.profile.chef_departement:
|
# if user.profile.chef_departement:
|
||||||
chef_profile = Profile.objects.get(id=user.profile)
|
# chef_profile = Profile.objects.get(id=user.profile)
|
||||||
departement = chef_profile.departement
|
# departement = chef_profile.departement
|
||||||
ids_profils_departement = Profile.objects.filter(departement=departement)["id"]
|
# ids_profils_departement = Profile.objects.filter(departement=departement)["id"]
|
||||||
|
|
||||||
return demande.user_id in ids_profils_departement
|
# return demande.user_id in ids_profils_departement
|
||||||
return user.profile.id == demande.user_id
|
# 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):
|
def connexion(request):
|
||||||
"""Gérez la connexion des utilisateurs."""
|
"""Gérez la connexion des utilisateurs."""
|
||||||
authentification_echoue = False
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
username = request.POST["username"]
|
username = request.POST["username"]
|
||||||
password = request.POST["password"]
|
password = request.POST["password"]
|
||||||
@@ -24,7 +23,6 @@ def connexion(request):
|
|||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
"authentification/login.html",
|
"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.
BIN
db.sqlite3:Zone.Identifier
Normal file
BIN
db.sqlite3:Zone.Identifier
Normal file
Binary file not shown.
BIN
gestion_fournisseur/__init__.py:Zone.Identifier
Normal file
BIN
gestion_fournisseur/__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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
gestion_fournisseur/admin.py:Zone.Identifier
Normal file
BIN
gestion_fournisseur/admin.py:Zone.Identifier
Normal file
Binary file not shown.
@@ -1,6 +1,6 @@
|
|||||||
from django.apps import AppConfig
|
from django.apps import AppConfig # noqa: D100
|
||||||
|
|
||||||
|
|
||||||
class GestionFournisseurConfig(AppConfig):
|
class GestionFournisseurConfig(AppConfig): # noqa: D101
|
||||||
default_auto_field = "django.db.models.BigAutoField"
|
default_auto_field = "django.db.models.BigAutoField"
|
||||||
name = "gestion_fournisseur"
|
name = "gestion_fournisseur"
|
||||||
|
|||||||
BIN
gestion_fournisseur/apps.py:Zone.Identifier
Normal file
BIN
gestion_fournisseur/apps.py:Zone.Identifier
Normal file
Binary file not shown.
BIN
gestion_fournisseur/forms.py:Zone.Identifier
Normal file
BIN
gestion_fournisseur/forms.py:Zone.Identifier
Normal file
Binary file not shown.
BIN
gestion_fournisseur/migrations/__init__.py:Zone.Identifier
Normal file
BIN
gestion_fournisseur/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.
Binary file not shown.
Binary file not shown.
BIN
gestion_fournisseur/models.py:Zone.Identifier
Normal file
BIN
gestion_fournisseur/models.py:Zone.Identifier
Normal file
Binary file not shown.
@@ -10,6 +10,14 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 col-lg-8 border rounded p-3 mx-auto">
|
<div class="col-12 col-lg-8 border rounded p-3 mx-auto">
|
||||||
|
{% if messages %}
|
||||||
|
{% for message in messages %}
|
||||||
|
<div class="alert {% if message.tags %}alert-{{ message.tags }}{% else %}alert-info{% endif %} alert-dismissible fade show" role="alert">
|
||||||
|
{{ message }}
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
<form action="{% url 'gestion_fournisseur:mise-a-jour-fournisseur' id_fournisseur %}" method="post">
|
<form action="{% url 'gestion_fournisseur:mise-a-jour-fournisseur' id_fournisseur %}" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
|
|||||||
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user