diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..ee9f705 --- /dev/null +++ b/Jenkinsfile @@ -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 + ''' + } + } + } +} \ No newline at end of file diff --git a/SGL/__pycache__/settings.cpython-310.pyc b/SGL/__pycache__/settings.cpython-310.pyc index c8e8244..549db9d 100644 Binary files a/SGL/__pycache__/settings.cpython-310.pyc and b/SGL/__pycache__/settings.cpython-310.pyc differ diff --git a/gestion_produit/__pycache__/models.cpython-310.pyc b/gestion_produit/__pycache__/models.cpython-310.pyc index e841d06..0b38abe 100644 Binary files a/gestion_produit/__pycache__/models.cpython-310.pyc and b/gestion_produit/__pycache__/models.cpython-310.pyc differ diff --git a/gestion_produit/__pycache__/views.cpython-310.pyc b/gestion_produit/__pycache__/views.cpython-310.pyc index 923058b..f24e54b 100644 Binary files a/gestion_produit/__pycache__/views.cpython-310.pyc and b/gestion_produit/__pycache__/views.cpython-310.pyc differ diff --git a/gestion_produit/models.py b/gestion_produit/models.py index b69478b..02d6baa 100644 --- a/gestion_produit/models.py +++ b/gestion_produit/models.py @@ -25,7 +25,11 @@ class Produit(models.Model): ("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( verbose_name="Quantité actuellement en stock" ) diff --git a/gestion_produit/views.py b/gestion_produit/views.py index 5019d69..b491173 100644 --- a/gestion_produit/views.py +++ b/gestion_produit/views.py @@ -5,7 +5,6 @@ from django.core.paginator import Paginator from django.db.models import Sum from authentification.models import Profile -# from django.views.decorators.csrf import csrf_exempt from django.contrib.auth.decorators import login_required from django.http import JsonResponse @@ -189,7 +188,6 @@ def detail_produit(request, id_produit): Réponse JSON contenant les détails du produit. """ - detail_produit = calcul_stock_produit(Produit.objects.get(id=id_produit)) categories = Categorie.objects.all()