From 6a674a6dd81fe9f038dab8f5eef6f205e0675a59 Mon Sep 17 00:00:00 2001 From: smarcet Date: Tue, 21 May 2019 17:47:40 -0300 Subject: [PATCH] added new public endpoints GET /api/public/v1/summits/all/current GET /api/public/v1/summits/all/selection-plans/current/{status} where status could be submission|selection|voting Change-Id: I0b91eef19bf4567744354bb263e79795e70d884c --- .../Summit/OAuth2SummitApiController.php | 24 +++++++++++++++++++ app/Http/Routes/public.php | 8 +++++++ .../Summit/SummitSerializer.php | 9 ++++--- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitApiController.php b/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitApiController.php index 9dd03acd..d361e3fc 100644 --- a/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitApiController.php +++ b/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitApiController.php @@ -187,6 +187,30 @@ final class OAuth2SummitApiController extends OAuth2ProtectedController } } + + /** + * @return mixed + */ + public function getAllCurrentSummit() + { + $expand = Request::input('expand', ''); + + try { + $summit = $this->repository->getCurrent(); + if (is_null($summit)) return $this->error404(); + $serializer_type = $this->serializer_type_selector->getSerializerType(); + return $this->ok(SerializerRegistry::getInstance()->getSerializer($summit, $serializer_type)->serialize($expand)); + } + catch(HTTP403ForbiddenException $ex1){ + Log::warning($ex1); + return $this->error403(); + } + catch (Exception $ex) { + Log::error($ex); + return $this->error500($ex); + } + } + /** * @return mixed */ diff --git a/app/Http/Routes/public.php b/app/Http/Routes/public.php index b2f8a2f4..9f611948 100644 --- a/app/Http/Routes/public.php +++ b/app/Http/Routes/public.php @@ -45,6 +45,14 @@ Route::group([ // summits Route::group(['prefix'=>'summits'], function() { Route::get('', [ 'middleware' => 'cache:'.Config::get('cache_api_response.get_summit_response_lifetime', 600), 'uses' => 'OAuth2SummitApiController@getSummits']); + + Route::group(['prefix' => 'all'], function () { + Route::get('current', 'OAuth2SummitApiController@getAllCurrentSummit'); + Route::group(['prefix' => 'selection-plans'], function () { + Route::get('current/{status}', 'OAuth2SummitSelectionPlansApiController@getCurrentSelectionPlanByStatus')->where('status', 'submission|selection|voting'); + }); + }); + Route::group(['prefix' => '{id}'], function () { Route::get('', [ 'middleware' => 'cache:'.Config::get('cache_api_response.get_summit_response_lifetime', 1200), 'uses' => 'OAuth2SummitApiController@getSummit'])->where('id', 'current|[0-9]+'); // locations diff --git a/app/ModelSerializers/Summit/SummitSerializer.php b/app/ModelSerializers/Summit/SummitSerializer.php index 2586c1d5..94cdc2b3 100644 --- a/app/ModelSerializers/Summit/SummitSerializer.php +++ b/app/ModelSerializers/Summit/SummitSerializer.php @@ -94,9 +94,12 @@ class SummitSerializer extends SilverStripeSerializer // pages info $main_page = $summit->getMainPage(); $schedule_page = $summit->getSchedulePage(); - $values['page_url'] = sprintf("%s%s", Config::get("server.assets_base_url", 'https://www.openstack.org/'), $main_page); - $values['schedule_page_url'] = sprintf("%s%s", Config::get("server.assets_base_url", 'https://www.openstack.org/'), $schedule_page); - $values['schedule_event_detail_url'] = sprintf("%s%s/%s", Config::get("server.assets_base_url", 'https://www.openstack.org/'), $schedule_page, 'events/:event_id/:event_title'); + $values['page_url'] = + empty($main_page)? null : + sprintf("%s%s", Config::get("server.assets_base_url", 'https://www.openstack.org/'), $main_page); + $values['schedule_page_url'] = empty($schedule_page) ? null : + sprintf("%s%s", Config::get("server.assets_base_url", 'https://www.openstack.org/'), $schedule_page); + $values['schedule_event_detail_url'] = empty($schedule_page) ? null : sprintf("%s%s/%s", Config::get("server.assets_base_url", 'https://www.openstack.org/'), $schedule_page, 'events/:event_id/:event_title'); // tickets if(in_array('ticket_types', $relations)) {