Added missing endpoint to track chairs api
export presentations to CSV Change-Id: I53db367a30a9cda24830aea6af422e46ecb14d7a Signed-off-by: smarcet <smarcet@gmail.com>
This commit is contained in:
parent
6f8c96c19d
commit
40fe0d4e6a
@ -12,6 +12,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
use App\Http\Utils\EpochCellFormatter;
|
||||||
use App\Models\Exceptions\AuthzException;
|
use App\Models\Exceptions\AuthzException;
|
||||||
use App\Models\Foundation\Summit\Repositories\ISummitCategoryChangeRepository;
|
use App\Models\Foundation\Summit\Repositories\ISummitCategoryChangeRepository;
|
||||||
use App\Services\Model\ISummitSelectionPlanService;
|
use App\Services\Model\ISummitSelectionPlanService;
|
||||||
@ -420,6 +421,126 @@ final class OAuth2SummitSelectionPlansApiController extends OAuth2ProtectedContr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $summit_id
|
||||||
|
* @param $selection_plan_id
|
||||||
|
* @return \Illuminate\Http\JsonResponse|mixed
|
||||||
|
*/
|
||||||
|
public function getSelectionPlanPresentationsCSV($summit_id, $selection_plan_id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
|
||||||
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||||
|
if (is_null($summit)) return $this->error404();
|
||||||
|
|
||||||
|
$member = $this->resource_server_context->getCurrentUser();
|
||||||
|
|
||||||
|
if (is_null($member))
|
||||||
|
return $this->error403();
|
||||||
|
|
||||||
|
$authz = $summit->isTrackChair($member) || $summit->isTrackChairAdmin($member);
|
||||||
|
|
||||||
|
if (!$authz)
|
||||||
|
return $this->error403();
|
||||||
|
|
||||||
|
return $this->_getAllCSV(
|
||||||
|
function () {
|
||||||
|
return [
|
||||||
|
'title' => ['=@', '=='],
|
||||||
|
'abstract' => ['=@', '=='],
|
||||||
|
'social_summary' => ['=@', '=='],
|
||||||
|
'tags' => ['=@', '=='],
|
||||||
|
'level' => ['=@', '=='],
|
||||||
|
'summit_type_id' => ['=='],
|
||||||
|
'event_type_id' => ['=='],
|
||||||
|
'track_id' => ['=='],
|
||||||
|
'speaker_id' => ['=='],
|
||||||
|
'speaker' => ['=@', '=='],
|
||||||
|
'speaker_email' => ['=@', '=='],
|
||||||
|
'selection_status' => ['=='],
|
||||||
|
'id' => ['=='],
|
||||||
|
'selection_plan_id' => ['=='],
|
||||||
|
'status' => ['=='],
|
||||||
|
'is_chair_visible' => ['=='],
|
||||||
|
'is_voting_visible' => ['=='],
|
||||||
|
'track_chairs_status' => ['=='],
|
||||||
|
'viewed_status' => ['=='],
|
||||||
|
];
|
||||||
|
},
|
||||||
|
function () {
|
||||||
|
return [
|
||||||
|
'title' => 'sometimes|string',
|
||||||
|
'abstract' => 'sometimes|string',
|
||||||
|
'social_summary' => 'sometimes|string',
|
||||||
|
'tags' => 'sometimes|string',
|
||||||
|
'level' => 'sometimes|string',
|
||||||
|
'summit_type_id' => 'sometimes|integer',
|
||||||
|
'event_type_id' => 'sometimes|integer',
|
||||||
|
'track_id' => 'sometimes|integer',
|
||||||
|
'speaker_id' => 'sometimes|integer',
|
||||||
|
'speaker' => 'sometimes|string',
|
||||||
|
'speaker_email' => 'sometimes|string',
|
||||||
|
'selection_status' => 'sometimes|string',
|
||||||
|
'id' => 'sometimes|integer',
|
||||||
|
'selection_plan_id' => 'sometimes|integer',
|
||||||
|
'status' => 'sometimes|string',
|
||||||
|
'is_chair_visible' => 'sometimes|boolean',
|
||||||
|
'is_voting_visible' => 'sometimes|boolean',
|
||||||
|
'track_chairs_status' => 'sometimes|string|in:voted,untouched,team_selected,selected,maybe,pass',
|
||||||
|
'viewed_status' => 'sometimes|string|in:seen,unseen,moved',
|
||||||
|
];
|
||||||
|
},
|
||||||
|
function () {
|
||||||
|
return [
|
||||||
|
'track'
|
||||||
|
];
|
||||||
|
},
|
||||||
|
function ($filter) use ($summit, $selection_plan_id) {
|
||||||
|
if ($filter instanceof Filter) {
|
||||||
|
$filter->addFilterCondition(FilterElement::makeEqual('summit_id', $summit->getId()));
|
||||||
|
$filter->addFilterCondition(FilterElement::makeEqual('selection_plan_id', $selection_plan_id));
|
||||||
|
$current_member = $this->resource_server_context->getCurrentUser(false);
|
||||||
|
if(!is_null($current_member)) {
|
||||||
|
$filter->addFilterCondition(FilterElement::makeEqual('current_member_id', $current_member->getId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $filter;
|
||||||
|
},
|
||||||
|
function () {
|
||||||
|
return IPresentationSerializerTypes::TrackChairs;
|
||||||
|
},
|
||||||
|
function () {
|
||||||
|
return [
|
||||||
|
'created' => new EpochCellFormatter(),
|
||||||
|
'last_edited' => new EpochCellFormatter(),
|
||||||
|
];
|
||||||
|
},
|
||||||
|
function () {
|
||||||
|
return [];
|
||||||
|
},
|
||||||
|
'presentations-',
|
||||||
|
[],
|
||||||
|
function ($page, $per_page, $filter, $order, $applyExtraFilters) {
|
||||||
|
return $this->summit_event_repository->getAllByPage
|
||||||
|
(
|
||||||
|
new PagingInfo($page, $per_page),
|
||||||
|
call_user_func($applyExtraFilters, $filter),
|
||||||
|
$order
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (ValidationException $ex) {
|
||||||
|
Log::warning($ex);
|
||||||
|
return $this->error412($ex->getMessages());
|
||||||
|
} catch (EntityNotFoundException $ex) {
|
||||||
|
Log::warning($ex);
|
||||||
|
return $this->error404($ex->getMessage());
|
||||||
|
} catch (Exception $ex) {
|
||||||
|
Log::error($ex);
|
||||||
|
return $this->error500($ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $summit_id
|
* @param $summit_id
|
||||||
* @param $selection_plan_id
|
* @param $selection_plan_id
|
||||||
@ -437,8 +558,13 @@ final class OAuth2SummitSelectionPlansApiController extends OAuth2ProtectedContr
|
|||||||
if (is_null($selection_plan)) return $this->error404();
|
if (is_null($selection_plan)) return $this->error404();
|
||||||
|
|
||||||
$presentation = $selection_plan->getPresentation(intval($presentation_id));
|
$presentation = $selection_plan->getPresentation(intval($presentation_id));
|
||||||
|
if(is_null($presentation)) throw new EntityNotFoundException();
|
||||||
|
|
||||||
|
return $this->ok(SerializerRegistry::getInstance()->getSerializer
|
||||||
|
(
|
||||||
|
$presentation
|
||||||
|
)->serialize(Request::input('expand', '')));
|
||||||
|
|
||||||
return $this->ok(SerializerRegistry::getInstance()->getSerializer($presentation)->serialize(Request::input('expand', '')));
|
|
||||||
} catch (ValidationException $ex) {
|
} catch (ValidationException $ex) {
|
||||||
Log::warning($ex);
|
Log::warning($ex);
|
||||||
return $this->error412($ex->getMessages());
|
return $this->error412($ex->getMessages());
|
||||||
|
@ -246,6 +246,7 @@ Route::group([
|
|||||||
|
|
||||||
Route::group(['prefix' => 'presentations'], function () {
|
Route::group(['prefix' => 'presentations'], function () {
|
||||||
Route::get('', ['middleware' => 'auth.user', 'uses' => 'OAuth2SummitSelectionPlansApiController@getSelectionPlanPresentations']);
|
Route::get('', ['middleware' => 'auth.user', 'uses' => 'OAuth2SummitSelectionPlansApiController@getSelectionPlanPresentations']);
|
||||||
|
Route::get('csv', ['middleware' => 'auth.user', 'uses' => 'OAuth2SummitSelectionPlansApiController@getSelectionPlanPresentationsCSV']);
|
||||||
|
|
||||||
Route::group(['prefix' => 'all'], function () {
|
Route::group(['prefix' => 'all'], function () {
|
||||||
// category-change-requests
|
// category-change-requests
|
||||||
|
@ -5162,6 +5162,20 @@ class ApiEndpointsSeeder extends Seeder
|
|||||||
IGroup::TrackChairsAdmins,
|
IGroup::TrackChairsAdmins,
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'name' => 'get-selection-plan-presentations-csv',
|
||||||
|
'route' => '/api/v1/summits/{id}/selection-plans/{selection_plan_id}/presentations/csv',
|
||||||
|
'http_method' => 'GET',
|
||||||
|
'scopes' => [
|
||||||
|
sprintf(SummitScopes::ReadSummitData, $current_realm)
|
||||||
|
],
|
||||||
|
'authz_groups' => [
|
||||||
|
IGroup::SuperAdmins,
|
||||||
|
IGroup::Administrators,
|
||||||
|
IGroup::TrackChairs,
|
||||||
|
IGroup::TrackChairsAdmins,
|
||||||
|
]
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'name' => 'get-selection-plan-presentation',
|
'name' => 'get-selection-plan-presentation',
|
||||||
'route' => '/api/v1/summits/{id}/selection-plans/{selection_plan_id}/presentations/{presentation_id}',
|
'route' => '/api/v1/summits/{id}/selection-plans/{selection_plan_id}/presentations/{presentation_id}',
|
||||||
|
@ -403,6 +403,95 @@ final class OAuth2SelectionPlansApiTest extends ProtectedApiTest
|
|||||||
$this->assertTrue($presentations->total >= 1);
|
$this->assertTrue($presentations->total >= 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetPresentationsBySelectionPlanAndConditionsCSV(){
|
||||||
|
|
||||||
|
$params = [
|
||||||
|
'id' => self::$summit->getId(),
|
||||||
|
'track_id' => self::$defaultTrack->getId(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$headers = [
|
||||||
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||||
|
"CONTENT_TYPE" => "application/json"
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = $this->action(
|
||||||
|
"POST",
|
||||||
|
"OAuth2SummitSelectedPresentationListApiController@createIndividualSelectionList",
|
||||||
|
$params,
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
$headers,
|
||||||
|
""
|
||||||
|
);
|
||||||
|
|
||||||
|
$content = $response->getContent();
|
||||||
|
$this->assertResponseStatus(201);
|
||||||
|
$selection_list = json_decode($content);
|
||||||
|
$this->assertTrue(!is_null($selection_list));
|
||||||
|
|
||||||
|
$params = [
|
||||||
|
'id' => self::$summit->getId(),
|
||||||
|
'track_id' => self::$defaultTrack->getId(),
|
||||||
|
'collection' => SummitSelectedPresentation::CollectionSelected,
|
||||||
|
'presentation_id' => self::$presentations[0]->getId(),
|
||||||
|
'expand' => 'selected_presentations,interested_presentations,'
|
||||||
|
];
|
||||||
|
|
||||||
|
$headers = [
|
||||||
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||||
|
"CONTENT_TYPE" => "application/json"
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = $this->action(
|
||||||
|
"POST",
|
||||||
|
"OAuth2SummitSelectedPresentationListApiController@assignPresentationToMyIndividualList",
|
||||||
|
$params,
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
$headers,
|
||||||
|
""
|
||||||
|
);
|
||||||
|
|
||||||
|
$content = $response->getContent();
|
||||||
|
$this->assertResponseStatus(201);
|
||||||
|
$selection_list = json_decode($content);
|
||||||
|
$this->assertTrue(!is_null($selection_list));
|
||||||
|
$this->assertTrue(count($selection_list->selected_presentations) > 0);
|
||||||
|
|
||||||
|
|
||||||
|
$params = [
|
||||||
|
'id' => self::$summit->getId(),
|
||||||
|
'selection_plan_id' => self::$default_selection_plan->getId(),
|
||||||
|
'filter' => [
|
||||||
|
'status==Received',
|
||||||
|
'is_chair_visible==1',
|
||||||
|
'track_chairs_status==voted'
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$headers = [
|
||||||
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||||
|
"CONTENT_TYPE" => "application/json"
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = $this->action(
|
||||||
|
"GET",
|
||||||
|
"OAuth2SummitSelectionPlansApiController@getSelectionPlanPresentationsCSV",
|
||||||
|
$params,
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
$headers
|
||||||
|
);
|
||||||
|
|
||||||
|
$content = $response->getContent();
|
||||||
|
$this->assertResponseStatus(200);
|
||||||
|
$this->assertTrue(!empty($content));
|
||||||
|
}
|
||||||
|
|
||||||
public function testGetPresentationsBySelectionPlanAndConditionsMoved(){
|
public function testGetPresentationsBySelectionPlanAndConditionsMoved(){
|
||||||
|
|
||||||
$params = [
|
$params = [
|
||||||
@ -720,7 +809,7 @@ final class OAuth2SelectionPlansApiTest extends ProtectedApiTest
|
|||||||
'summit' => self::$summit->getId(),
|
'summit' => self::$summit->getId(),
|
||||||
'selection_plan_id' => self::$default_selection_plan->getId(),
|
'selection_plan_id' => self::$default_selection_plan->getId(),
|
||||||
'expand' => 'presentation, new_category, old_category',
|
'expand' => 'presentation, new_category, old_category',
|
||||||
'order' => '+requester_fullname'
|
'order' => '-old_category_name'
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = $this->action(
|
$response = $this->action(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user