Added event publishing to TBD location
Change-Id: If7cf20bb681da3deebd7e8f93deb0b486fb72eb8
This commit is contained in:
parent
ec1b904092
commit
a57b59820d
@ -135,7 +135,7 @@ final class OAuth2SummitLocationsApiController extends OAuth2ProtectedController
|
||||
|
||||
/**
|
||||
* @param string $summit_id
|
||||
* @param int $location_id
|
||||
* @param string $location_id
|
||||
* @param bool $published
|
||||
* @return PagingResponse
|
||||
* @throws EntityNotFoundException
|
||||
@ -147,17 +147,19 @@ final class OAuth2SummitLocationsApiController extends OAuth2ProtectedController
|
||||
if (is_null($summit))
|
||||
throw new EntityNotFoundException;
|
||||
|
||||
$location = $summit->getLocation($location_id);
|
||||
if (is_null($location))
|
||||
throw new EntityNotFoundException;
|
||||
if(strtolower($location_id) != "tbd") {
|
||||
$location = $summit->getLocation(intval($location_id));
|
||||
if (is_null($location))
|
||||
throw new EntityNotFoundException;
|
||||
}
|
||||
|
||||
$values = Input::all();
|
||||
|
||||
$rules = array
|
||||
(
|
||||
$rules =
|
||||
[
|
||||
'page' => 'integer|min:1',
|
||||
'per_page' => 'required_with:page|integer|min:5|max:100',
|
||||
);
|
||||
];
|
||||
|
||||
$validation = Validator::make($values, $rules);
|
||||
|
||||
@ -206,14 +208,19 @@ final class OAuth2SummitLocationsApiController extends OAuth2ProtectedController
|
||||
|
||||
if(is_null($filter)) $filter = new Filter();
|
||||
|
||||
$filter->addFilterCondition(FilterParser::buildFilter('location_id','==', $location_id));
|
||||
$filter->addFilterCondition(FilterParser::buildFilter('summit_id','==', $summit_id));
|
||||
|
||||
if(intval($location_id) > 0)
|
||||
$filter->addFilterCondition(FilterParser::buildFilter('location_id','==', $location_id));
|
||||
|
||||
if($published)
|
||||
{
|
||||
$filter->addFilterCondition(FilterParser::buildFilter('published','==', 1));
|
||||
}
|
||||
|
||||
return $this->event_repository->getAllByPage(new PagingInfo($page, $per_page), $filter, $order);
|
||||
return strtolower($location_id) == "tbd" ?
|
||||
$this->event_repository->getAllByPageLocationTBD(new PagingInfo($page, $per_page), $filter, $order):
|
||||
$this->event_repository->getAllByPage(new PagingInfo($page, $per_page), $filter, $order);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -252,7 +259,6 @@ final class OAuth2SummitLocationsApiController extends OAuth2ProtectedController
|
||||
public function getLocationPublishedEvents($summit_id, $location_id)
|
||||
{
|
||||
try {
|
||||
|
||||
return $this->ok($this->_getLocationEvents($summit_id, $location_id, true)->toArray(Request::input('expand', '')));
|
||||
}
|
||||
catch (EntityNotFoundException $ex1) {
|
||||
@ -263,10 +269,6 @@ final class OAuth2SummitLocationsApiController extends OAuth2ProtectedController
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
}
|
||||
catch(FilterParserException $ex3){
|
||||
Log::warning($ex3);
|
||||
return $this->error412($ex3->getMessages());
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
|
@ -54,7 +54,7 @@ final class Filter
|
||||
*/
|
||||
public function getFilter($field)
|
||||
{
|
||||
$res = array();
|
||||
$res = [];
|
||||
foreach ($this->filters as $filter) {
|
||||
|
||||
if ($filter instanceof FilterElement && $filter->getField() === $field) {
|
||||
@ -62,7 +62,7 @@ final class Filter
|
||||
}
|
||||
else if (is_array($filter)) {
|
||||
// OR
|
||||
$or_res = array();
|
||||
$or_res = [];
|
||||
foreach ($filter as $e) {
|
||||
if ($e instanceof FilterElement && $e->getField() === $field) {
|
||||
$or_res[] = $e;
|
||||
@ -74,6 +74,16 @@ final class Filter
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
* @return null|FilterElement
|
||||
*/
|
||||
public function getUniqueFilter($field){
|
||||
$res = $this->getFilter($field);
|
||||
return count($res) == 1 ? $res[0]:null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
* @return bool
|
||||
|
@ -244,8 +244,8 @@ Route::group([
|
||||
Route::get('/airports', 'OAuth2SummitLocationsApiController@getAirports');
|
||||
Route::group(array('prefix' => '{location_id}'), function () {
|
||||
Route::get('', 'OAuth2SummitLocationsApiController@getLocation');
|
||||
Route::get('/events/published','OAuth2SummitLocationsApiController@getLocationPublishedEvents');
|
||||
Route::get('/events','OAuth2SummitLocationsApiController@getLocationEvents');
|
||||
Route::get('/events/published','OAuth2SummitLocationsApiController@getLocationPublishedEvents')->where('location_id', 'tbd|[0-9]+');
|
||||
Route::get('/events','OAuth2SummitLocationsApiController@getLocationEvents')->where('location_id', 'tbd|[0-9]+');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -38,6 +38,14 @@ interface ISummitEventRepository extends IBaseRepository
|
||||
*/
|
||||
public function getAllByPage(PagingInfo $paging_info, Filter $filter = null, Order $order = null);
|
||||
|
||||
/**
|
||||
* @param PagingInfo $paging_info
|
||||
* @param Filter|null $filter
|
||||
* @param Order|null $order
|
||||
* @return PagingResponse
|
||||
*/
|
||||
public function getAllByPageLocationTBD(PagingInfo $paging_info, Filter $filter = null, Order $order = null);
|
||||
|
||||
/**
|
||||
* @param int $event_id
|
||||
*/
|
||||
|
@ -168,14 +168,14 @@ final class DoctrineSummitEventRepository
|
||||
public function getAllByPage(PagingInfo $paging_info, Filter $filter = null, Order $order = null)
|
||||
{
|
||||
$class = $filter->hasFilter('speaker')
|
||||
|| $filter->hasFilter('selection_status')
|
||||
|| $filter->hasFilter('speaker_email')?
|
||||
|| $filter->hasFilter('selection_status')
|
||||
|| $filter->hasFilter('speaker_email')?
|
||||
\models\summit\Presentation::class:
|
||||
\models\summit\SummitEvent::class;
|
||||
|
||||
$query = $this->getEntityManager()->createQueryBuilder()
|
||||
->select("e")
|
||||
->from($class, "e");
|
||||
->from($class, "e")->leftJoin("e.location", 'l', Join::LEFT_JOIN);
|
||||
|
||||
if(!is_null($filter)){
|
||||
$filter->apply2Query($query, $this->getFilterMappings());
|
||||
@ -240,4 +240,68 @@ final class DoctrineSummitEventRepository
|
||||
{
|
||||
return SummitEvent::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PagingInfo $paging_info
|
||||
* @param Filter|null $filter
|
||||
* @param Order|null $order
|
||||
* @return PagingResponse
|
||||
*/
|
||||
public function getAllByPageLocationTBD(PagingInfo $paging_info, Filter $filter = null, Order $order = null)
|
||||
{
|
||||
$class = $filter->hasFilter('speaker')
|
||||
|| $filter->hasFilter('selection_status')
|
||||
|| $filter->hasFilter('speaker_email')?
|
||||
\models\summit\Presentation::class:
|
||||
\models\summit\SummitEvent::class;
|
||||
|
||||
$query = $this->getEntityManager()->createQueryBuilder()
|
||||
->select("e")
|
||||
->from($class, "e")
|
||||
->leftJoin("e.location", 'l', Join::LEFT_JOIN)
|
||||
->where("l.id is null");
|
||||
|
||||
if(!is_null($filter)){
|
||||
$filter->apply2Query($query, $this->getFilterMappings());
|
||||
}
|
||||
|
||||
if (!is_null($order)) {
|
||||
$order->apply2Query($query, $this->getOrderMappings());
|
||||
} else {
|
||||
//default order
|
||||
$query = $query->addOrderBy("e.start_date",'ASC');
|
||||
$query = $query->addOrderBy("e.end_date", 'ASC');
|
||||
}
|
||||
|
||||
if($class == \models\summit\Presentation::class) {
|
||||
$query = $query->innerJoin("e.category", "cc", Join::WITH);
|
||||
$query = $query->leftJoin("e.speakers", "sp", Join::WITH);
|
||||
$query = $query->leftJoin('e.selected_presentations', "ssp", Join::LEFT_JOIN);
|
||||
$query = $query->leftJoin('ssp.list', "sspl", Join::LEFT_JOIN);
|
||||
$query = $query->leftJoin('e.moderator', "spm", Join::LEFT_JOIN);
|
||||
$query = $query->leftJoin('sp.member', "spmm", Join::LEFT_JOIN);
|
||||
$query = $query->leftJoin('sp.registration_request', "sprr", Join::LEFT_JOIN);
|
||||
}
|
||||
|
||||
$query = $query
|
||||
->andWhere("not e INSTANCE OF ('" . implode("','", self::$forbidded_classes) . "')")
|
||||
->setFirstResult($paging_info->getOffset())
|
||||
->setMaxResults($paging_info->getPerPage());
|
||||
|
||||
$paginator = new Paginator($query, $fetchJoinCollection = true);
|
||||
$total = $paginator->count();
|
||||
$data = [];
|
||||
|
||||
foreach($paginator as $entity)
|
||||
$data[]= $entity;
|
||||
|
||||
return new PagingResponse
|
||||
(
|
||||
$total,
|
||||
$paging_info->getPerPage(),
|
||||
$paging_info->getCurrentPage(),
|
||||
$paging_info->getLastPage($total),
|
||||
$data
|
||||
);
|
||||
}
|
||||
}
|
@ -810,16 +810,19 @@ final class SummitService implements ISummitService
|
||||
throw new ValidationException(sprintf("end_date its not assigned to event id %s!", $event_id));
|
||||
|
||||
if (isset($data['location_id'])) {
|
||||
$location = $summit->getLocation(intval($data['location_id']));
|
||||
if (is_null($location))
|
||||
throw new EntityNotFoundException(sprintf("location id %s does not exists!", $data['location_id']));
|
||||
$event->setLocation($location);
|
||||
$location_id = intval($data['location_id']);
|
||||
$event->clearLocation();
|
||||
if($location_id > 0){
|
||||
$location = $summit->getLocation($location_id);
|
||||
if (is_null($location))
|
||||
throw new EntityNotFoundException(sprintf("location id %s does not exists!", $data['location_id']));
|
||||
$event->setLocation($location);
|
||||
}
|
||||
}
|
||||
|
||||
$this->validateBlackOutTimesAndTimes($event);
|
||||
$event->unPublish();
|
||||
$event->publish();
|
||||
|
||||
$this->event_repository->add($event);
|
||||
return $event;
|
||||
});
|
||||
|
@ -1973,6 +1973,38 @@ final class OAuth2SummitApiTest extends ProtectedApiTest
|
||||
$this->assertTrue(!is_null($events));
|
||||
}
|
||||
|
||||
public function testCurrentSummitPublishedLocationTBAEvents()
|
||||
{
|
||||
$params = array
|
||||
(
|
||||
'id' => 23,
|
||||
'location_id' => "tba",
|
||||
);
|
||||
|
||||
$headers = array
|
||||
(
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
);
|
||||
|
||||
$response = $this->action
|
||||
(
|
||||
"GET",
|
||||
"OAuth2SummitLocationsApiController@getLocationPublishedEvents",
|
||||
$params,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(200);
|
||||
|
||||
$events = json_decode($content);
|
||||
$this->assertTrue(!is_null($events));
|
||||
}
|
||||
|
||||
public function testAddPresentationVideo($summit_id = 7, $presentation_id = 15404)
|
||||
{
|
||||
$params = array
|
||||
|
Loading…
x
Reference in New Issue
Block a user