From 94591611540809f47462be9aa2bb13771094392d Mon Sep 17 00:00:00 2001 From: d1ff1cult0 Date: Mon, 4 Nov 2024 11:06:41 +0100 Subject: [PATCH 1/3] Added check so you can't reserve products from sale sessions not visible due to reservation_trashold configuration --- .../ShopBundle/Controller/ShopController.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/module/ShopBundle/Controller/ShopController.php b/module/ShopBundle/Controller/ShopController.php index 7253ffd1e..c6b98d63f 100644 --- a/module/ShopBundle/Controller/ShopController.php +++ b/module/ShopBundle/Controller/ShopController.php @@ -31,6 +31,14 @@ public function reserveproductsAction() ); } + if(!$this->saleSessionIsOpen()){ + $this->flashMessenger()->error( + 'Error', + 'No session was found!' + ); + $this->redirect()->toRoute('shop'); + } + $salesSession = $this->getSalesSessionEntity(); $stockEntries = $this->getStockEntries($salesSession); @@ -546,4 +554,14 @@ private function getStockEntries($salesSession) ) ); } + + private function saleSessionIsOpen(){ + $salesSessionId = $this->getSalesSessionEntity()->getId(); + $openSaleSessions = $this->getSalesSessions(); + $openSaleSessionsIds = array_map(function($session) { + return $session->getId(); + }, $openSaleSessions); + + return in_array($salesSessionId, $openSaleSessionsIds); + } } From 8494978ec59a3dd03185074fb9f1149ac85cde71 Mon Sep 17 00:00:00 2001 From: d1ff1cult0 Date: Mon, 4 Nov 2024 11:12:25 +0100 Subject: [PATCH 2/3] Updated gitlab-ci.yml --- .gitlab-ci.yml | 8 ++++++-- module/ShopBundle/Controller/ShopController.php | 14 +++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5b95feb23..1532c5f1e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,9 +6,11 @@ variables: COMPOSER_HOME: $CI_PROJECT_DIR/.composer NO_PROXY: "gitlab.vtk.be" - build: stage: build + before_script: + - export PATH="/usr/bin/php7.4:$PATH" + - php -v script: - composer update --no-dev - composer install --no-dev @@ -28,9 +30,12 @@ build: .deploy: &deploy stage: deploy before_script: + - export PATH="/usr/bin/php7.4:$PATH" + - php -v - eval $(ssh-agent -s) - ssh-add <(echo $SSH_PRIVATE_KEY | base64 -d) script: + - export SENTRY_LOG_LEVEL=debug - scp -o StrictHostKeyChecking=no litus.tar.gz root@$SSH_HOSTNAME:/tmp - ssh -o StrictHostKeyChecking=no root@$SSH_HOSTNAME /usr/local/sbin/deploy.sh only: @@ -54,4 +59,3 @@ deploy_liv: environment: name: liv url: https://vtk.be - diff --git a/module/ShopBundle/Controller/ShopController.php b/module/ShopBundle/Controller/ShopController.php index c6b98d63f..4def14116 100644 --- a/module/ShopBundle/Controller/ShopController.php +++ b/module/ShopBundle/Controller/ShopController.php @@ -31,7 +31,7 @@ public function reserveproductsAction() ); } - if(!$this->saleSessionIsOpen()){ + if (!$this->saleSessionIsOpen()){ $this->flashMessenger()->error( 'Error', 'No session was found!' @@ -555,12 +555,16 @@ private function getStockEntries($salesSession) ); } - private function saleSessionIsOpen(){ + private function saleSessionIsOpen() + { $salesSessionId = $this->getSalesSessionEntity()->getId(); $openSaleSessions = $this->getSalesSessions(); - $openSaleSessionsIds = array_map(function($session) { - return $session->getId(); - }, $openSaleSessions); + $openSaleSessionsIds = array_map( + function ($session) { + return $session->getId(); + }, + $openSaleSessions + ); return in_array($salesSessionId, $openSaleSessionsIds); } From 019f6afe889a428058417e2adcb0b4af69edf6df Mon Sep 17 00:00:00 2001 From: d1ff1cult0 Date: Mon, 4 Nov 2024 11:12:35 +0100 Subject: [PATCH 3/3] Updated gitlab-ci.yml --- module/ShopBundle/Controller/ShopController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/ShopBundle/Controller/ShopController.php b/module/ShopBundle/Controller/ShopController.php index 4def14116..332c126e1 100644 --- a/module/ShopBundle/Controller/ShopController.php +++ b/module/ShopBundle/Controller/ShopController.php @@ -31,7 +31,7 @@ public function reserveproductsAction() ); } - if (!$this->saleSessionIsOpen()){ + if (!$this->saleSessionIsOpen()) { $this->flashMessenger()->error( 'Error', 'No session was found!'