Fix: Nom des produits doivent être unique
Some checks failed
Organisation/sgl/pipeline/head There was a failure building this commit

This commit is contained in:
2026-09-18 09:31:46 +00:00
parent 827a164cbd
commit 165894c92b
6 changed files with 56 additions and 3 deletions

51
Jenkinsfile vendored Normal file
View File

@@ -0,0 +1,51 @@
pipeline
{
agent any
options {
skipDefaultCheckout(true)
}
environment
{
SUDO_PASSWORD = credentials('sudo-password')
}
stages
{
stage ( 'checkout' )
{
steps
{
sh 'echo "Debut du pipeline"'
cleanWs()
checkout scm
}
}
stage ( 'Deploiement' )
{
when { branch 'main' }
steps {
sh '''
cd /var/www/sgl
echo $SUDO_PASSWORD | sudo -S chown -R jenkins:jenkins /var/www/sgl
git fetch origin main
git reset --hard origin/main
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
python manage.py makemigrations
python manage.py migrate
echo $SUDO_PASSWORD | sudo -S rm -r staticfiles
python manage.py collectstatic --noinput
echo $SUDO_PASSWORD | sudo -S chown -R www-data:www-data /var/www/sgl
echo "Deploiement reussi"
echo $SUDO_PASSWORD | sudo -S supervisorctl restart sgl
'''
}
}
}
}

View File

@@ -25,7 +25,11 @@ class Produit(models.Model):
("carton", "Carton"), ("carton", "Carton"),
) )
libelle = models.CharField(verbose_name="Libellé", max_length=255) libelle = models.CharField(
verbose_name="Libellé",
max_length=255,
unique=True
)
quantite_stock = models.PositiveIntegerField( quantite_stock = models.PositiveIntegerField(
verbose_name="Quantité actuellement en stock" verbose_name="Quantité actuellement en stock"
) )

View File

@@ -5,7 +5,6 @@ from django.core.paginator import Paginator
from django.db.models import Sum from django.db.models import Sum
from authentification.models import Profile from authentification.models import Profile
# from django.views.decorators.csrf import csrf_exempt
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.http import JsonResponse from django.http import JsonResponse
@@ -189,7 +188,6 @@ def detail_produit(request, id_produit):
Réponse JSON contenant les détails du produit. Réponse JSON contenant les détails du produit.
""" """
detail_produit = calcul_stock_produit(Produit.objects.get(id=id_produit)) detail_produit = calcul_stock_produit(Produit.objects.get(id=id_produit))
categories = Categorie.objects.all() categories = Categorie.objects.all()