From 46c68ae4c2eb385ee053e725f57630c68ad57378 Mon Sep 17 00:00:00 2001 From: gmorel Date: Wed, 1 Jan 2014 16:17:07 +0100 Subject: [PATCH 1/2] Coupon : Fix bug preventing to update coupon Use $parent instead of $folder_id in folders admin template uncomment needed return statement add missing value in folder modification form uncomment needed loop for parent folder start a new section in changelog file --- CHANGELOG.md | 2 + .../Controller/Admin/CouponController.php | 38 +++++++++++++------ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec425be8a..f4caa6979 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,8 @@ - http://www.mnot.net/cache_docs/ (fr) - http://tomayko.com/writings/things-caches-do (en) - http://symfony.com/doc/current/book/http_cache.html#http-cache-introduction (en and fr) + +#2.0.0-beta3 - Coupon effect inputs are now more customisable (input text, select, ajax, etc.. are usable) and unlimited amount of input for coupon effect are now possible too diff --git a/core/lib/Thelia/Controller/Admin/CouponController.php b/core/lib/Thelia/Controller/Admin/CouponController.php index d4162f80e..a46411aca 100755 --- a/core/lib/Thelia/Controller/Admin/CouponController.php +++ b/core/lib/Thelia/Controller/Admin/CouponController.php @@ -35,6 +35,7 @@ use Thelia\Core\Security\AccessManager; use Thelia\Coupon\CouponFactory; use Thelia\Coupon\CouponManager; use Thelia\Condition\ConditionCollection; +use Thelia\Coupon\Type\CouponAbstract; use Thelia\Coupon\Type\CouponInterface; use Thelia\Coupon\Type\RemoveXPercent; use Thelia\Form\CouponCreationForm; @@ -205,7 +206,8 @@ class CouponController extends BaseAdminController $lang, $eventToDispatch, 'updated', - 'update' + 'update', + $coupon ); } else { // Display @@ -348,7 +350,7 @@ class CouponController extends BaseAdminController $coupon->getCode(), $coupon->getType(), $coupon->getTitle(), - array('quantity' => $coupon->getAmount()), + $coupon->getEffects(), $coupon->getShortDescription(), $coupon->getDescription(), $coupon->getIsEnabled(), @@ -456,10 +458,11 @@ class CouponController extends BaseAdminController * @param string $eventToDispatch Event which will activate actions * @param string $log created|edited * @param string $action creation|edition + * @param Coupon $model Model if in update mode * * @return $this */ - protected function validateCreateOrUpdateForm(I18n $i18n, Lang $lang, $eventToDispatch, $log, $action) + protected function validateCreateOrUpdateForm(I18n $i18n, Lang $lang, $eventToDispatch, $log, $action, Coupon $model = null) { // Create the form from the request $creationForm = new CouponCreationForm($this->getRequest()); @@ -469,7 +472,7 @@ class CouponController extends BaseAdminController // Check the form against conditions violations $form = $this->validateForm($creationForm, 'POST'); - $couponEvent = $this->feedCouponCreateOrUpdateEvent($form); + $couponEvent = $this->feedCouponCreateOrUpdateEvent($form, $model); // Dispatch Event to the Action $this->dispatch( @@ -635,29 +638,40 @@ class CouponController extends BaseAdminController /** * Feed the Coupon Create or Update event with the User inputs * - * @param Form $form + * @param Form $form Form containing user data + * @param Coupon $model Model if in update mode * * @return CouponCreateOrUpdateEvent */ - protected function feedCouponCreateOrUpdateEvent(Form $form) + protected function feedCouponCreateOrUpdateEvent(Form $form, Coupon $model = null) { // Get the form field values $data = $form->getData(); $serviceId = $data['type']; /** @var CouponInterface $couponManager */ $couponManager = $this->container->get($serviceId); - $effects = array('amount' => $data['amount']); + $effects = array(CouponAbstract::INPUT_AMOUNT_NAME => $data[CouponAbstract::INPUT_AMOUNT_NAME]); $effects = $this->addExtendedLogic($effects, $couponManager->getExtendedInputs()); $couponEvent = new CouponCreateOrUpdateEvent( - $data['code'], $serviceId, $data['title'], $effects, $data['shortDescription'], $data['description'], $data['isEnabled'], \DateTime::createFromFormat('Y-m-d', $data['expirationDate']), $data['isAvailableOnSpecialOffers'], $data['isCumulative'], $data['isRemovingPostage'], $data['maxUsage'], $data['locale'] + $data['code'], + $serviceId, + $data['title'], + $effects, + $data['shortDescription'], + $data['description'], + $data['isEnabled'], + \DateTime::createFromFormat('Y-m-d', $data['expirationDate']), + $data['isAvailableOnSpecialOffers'], + $data['isCumulative'], + $data['isRemovingPostage'], + $data['maxUsage'], + $data['locale'] ); // If Update mode - $couponQuery = new CouponQuery(); - $coupon = $couponQuery->findOneByCode($data['code']); - if (isset($coupon)) { - $couponEvent->setCouponModel($coupon); + if (isset($model)) { + $couponEvent->setCouponModel($model); } return $couponEvent; From 49782765b48da8ae161c167ccb0703f484cd9873 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 31 Dec 2013 09:22:30 +0100 Subject: [PATCH 2/2] put at the beginning of changelog file the new features --- CHANGELOG.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4caa6979..53b20dd27 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +#2.0.0-beta3 +- Coupon effect inputs are now more customisable (input text, select, ajax, etc.. are usable) and unlimited amount of input for coupon effect are now possible too + #2.0.0-beta2 - http://doc.thelia.net is available in beta. @@ -24,9 +27,4 @@ - resources : - http://www.mnot.net/cache_docs/ (fr) - http://tomayko.com/writings/things-caches-do (en) - - http://symfony.com/doc/current/book/http_cache.html#http-cache-introduction (en and fr) - -#2.0.0-beta3 -- Coupon effect inputs are now more customisable (input text, select, ajax, etc.. are usable) and unlimited amount of input for coupon effect are now possible too - - + - http://symfony.com/doc/current/book/http_cache.html#http-cache-introduction (en and fr) \ No newline at end of file