From 2116c3f314e236c773a34c3f7358df812757713c Mon Sep 17 00:00:00 2001 From: Sebastian Marcet Date: Tue, 12 Jun 2018 09:42:47 -0700 Subject: [PATCH] Selection Plans hotfix * fixed post/put * added v2 for get summit by id to remove cache Change-Id: I864aa863fe32f1417adc424ef2e03349fc0da0b7 --- app/Http/routes.php | 2 +- .../Summit/Factories/SummitSelectionPlanFactory.php | 2 ++ app/Services/Model/SummitSelectionPlanService.php | 2 +- database/seeds/ApiEndpointsSeeder.php | 10 +++++++++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/Http/routes.php b/app/Http/routes.php index a96c9da9..588ec059 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -532,7 +532,7 @@ Route::group([ Route::group(['prefix' => 'summits'], function () { Route::group(['prefix' => '{id}'], function () { - + Route::get('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2SummitApiController@getSummit'])->where('id', 'current|[0-9]+'); // events Route::group(['prefix' => 'events'], function () { diff --git a/app/Models/Foundation/Summit/Factories/SummitSelectionPlanFactory.php b/app/Models/Foundation/Summit/Factories/SummitSelectionPlanFactory.php index edd4e18a..a25062c4 100644 --- a/app/Models/Foundation/Summit/Factories/SummitSelectionPlanFactory.php +++ b/app/Models/Foundation/Summit/Factories/SummitSelectionPlanFactory.php @@ -36,6 +36,8 @@ final class SummitSelectionPlanFactory */ public static function populate(SelectionPlan $selection_plan, array $data, Summit $summit){ + $selection_plan->setSummit($summit); + if(isset($data['name'])) $selection_plan->setName(trim($data['name'])); diff --git a/app/Services/Model/SummitSelectionPlanService.php b/app/Services/Model/SummitSelectionPlanService.php index 30ece4d7..7a76334a 100644 --- a/app/Services/Model/SummitSelectionPlanService.php +++ b/app/Services/Model/SummitSelectionPlanService.php @@ -81,7 +81,7 @@ final class SummitSelectionPlanService if(isset($payload['name'])) { $former_selection_plan = $summit->getSelectionPlanByName($payload['name']); - if ($former_selection_plan->getId() != $selection_plan_id && !is_null($former_selection_plan)) { + if (!is_null($former_selection_plan) && $former_selection_plan->getId() != $selection_plan_id) { throw new ValidationException(trans( 'validation_errors.SummitSelectionPlanService.updateSelectionPlan.alreadyExistName', [ diff --git a/database/seeds/ApiEndpointsSeeder.php b/database/seeds/ApiEndpointsSeeder.php index 1deca3dc..63d99cc9 100644 --- a/database/seeds/ApiEndpointsSeeder.php +++ b/database/seeds/ApiEndpointsSeeder.php @@ -91,7 +91,7 @@ class ApiEndpointsSeeder extends Seeder ], ], [ - 'name' => 'get-summit', + 'name' => 'get-summit-cached', 'route' => '/api/v1/summits/{id}', 'http_method' => 'GET', 'scopes' => [ @@ -99,6 +99,14 @@ class ApiEndpointsSeeder extends Seeder sprintf(SummitScopes::ReadAllSummitData, $current_realm) ], ], + [ + 'name' => 'get-summit-non-cached', + 'route' => '/api/v2/summits/{id}', + 'http_method' => 'GET', + 'scopes' => [ + sprintf(SummitScopes::ReadAllSummitData, $current_realm) + ], + ], [ 'name' => 'add-summit', 'route' => '/api/v1/summits',