Added endpoint to add presentation category group
as long as endpoint to manage child collections (associated tracks and allowed groups) POST /api/v1/summits/{id}/track-groups Payload * class_name (PresentationCategoryGroup|PrivatePresentationCategoryGroup) * name (required|string) * description (sometimes|string) * color (sometimes|hex_color) Payload for private groups ( optional if class_name == 'PrivatePresentationCategoryGroup' * submission_begin_date (sometimes|date_format:U) * submission_end_date (sometimes|date_format:U|required_with:submission_begin_date|after:submission_begin_date) * max_submission_allowed_per_user (sometimes|integer|min:1) endpoints to manage tracks PUT /api/v1/summits/{id}/track-groups/{track_group_id}/tracks/{track_id} DELETE /api/v1/summits/{id}/track-groups/{track_group_id}/tracks/{track_id} endpoints to manage allowed groups (only PrivatePresentationCategoryGroup) PUT /api/v1/summits/{id}/track-groups/{track_group_id}/allowed-groups/{group_id} DELETE /api/v1/summits/{id}/track-groups/{track_group_id}/allowed-groups/{group_id} Change-Id: Icf97c9b014609b71d1668faa654a51044d5bb3ec
This commit is contained in:
parent
4a98e4d3a2
commit
eeab19f748
60
app/Events/SummitTicketTypeAction.php
Normal file
60
app/Events/SummitTicketTypeAction.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php namespace App\Events;
|
||||
/**
|
||||
* Copyright 2018 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
/**
|
||||
* Class SummitTicketTypeAction
|
||||
* @package App\Events
|
||||
*/
|
||||
abstract class SummitTicketTypeAction
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $ticket_type_id;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $summit_id;
|
||||
|
||||
/**
|
||||
* SummitTicketTypeAction constructor.
|
||||
* @param int $ticket_type_id
|
||||
* @param int $summit_id
|
||||
*/
|
||||
public function __construct($ticket_type_id, $summit_id)
|
||||
{
|
||||
$this->ticket_type_id = $ticket_type_id;
|
||||
$this->summit_id = $summit_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTicketTypeId()
|
||||
{
|
||||
return $this->ticket_type_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSummitId()
|
||||
{
|
||||
return $this->summit_id;
|
||||
}
|
||||
|
||||
}
|
21
app/Events/SummitTicketTypeDeleted.php
Normal file
21
app/Events/SummitTicketTypeDeleted.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php namespace App\Events;
|
||||
/**
|
||||
* Copyright 2018 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
/**
|
||||
* Class SummitTicketTypeDeleted
|
||||
* @package App\Events
|
||||
*/
|
||||
final class SummitTicketTypeDeleted extends SummitTicketTypeAction
|
||||
{
|
||||
|
||||
}
|
17
app/Events/SummitTicketTypeInserted.php
Normal file
17
app/Events/SummitTicketTypeInserted.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php namespace App\Events;
|
||||
/**
|
||||
* Copyright 2018 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
final class SummitTicketTypeInserted extends SummitTicketTypeAction
|
||||
{
|
||||
|
||||
}
|
22
app/Events/SummitTicketTypeUpdated.php
Normal file
22
app/Events/SummitTicketTypeUpdated.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php namespace App\Events;
|
||||
/**
|
||||
* Copyright 2018 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
/**
|
||||
* Class SummitTicketTypeUpdated
|
||||
* @package App\Events
|
||||
*/
|
||||
final class SummitTicketTypeUpdated extends SummitTicketTypeAction
|
||||
{
|
||||
|
||||
}
|
@ -16,19 +16,19 @@ use Illuminate\Queue\SerializesModels;
|
||||
* Class TrackAction
|
||||
* @package App\Events
|
||||
*/
|
||||
class TrackAction
|
||||
abstract class TrackAction
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $track_id;
|
||||
protected $track_id;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $summit_id;
|
||||
protected $summit_id;
|
||||
|
||||
/**
|
||||
* TrackAction constructor.
|
||||
|
74
app/Events/TrackGroupAction.php
Normal file
74
app/Events/TrackGroupAction.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?php namespace App\Events;
|
||||
/**
|
||||
* Copyright 2018 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
/**
|
||||
* Class TrackGroupAction
|
||||
* @package App\Events
|
||||
*/
|
||||
abstract class TrackGroupAction
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $track_group_id;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $summit_id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $class_name;
|
||||
|
||||
/**
|
||||
* TrackGroupAction constructor.
|
||||
* @param int $track_group_id
|
||||
* @param int $summit_id
|
||||
* @param string $class_name
|
||||
*/
|
||||
public function __construct($track_group_id, $summit_id, $class_name)
|
||||
{
|
||||
$this->track_group_id = $track_group_id;
|
||||
$this->summit_id = $summit_id;
|
||||
$this->class_name = $class_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName()
|
||||
{
|
||||
return $this->class_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTrackGroupId()
|
||||
{
|
||||
return $this->track_group_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSummitId()
|
||||
{
|
||||
return $this->summit_id;
|
||||
}
|
||||
}
|
22
app/Events/TrackGroupDeleted.php
Normal file
22
app/Events/TrackGroupDeleted.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php namespace App\Events;
|
||||
/**
|
||||
* Copyright 2018 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
/**
|
||||
* Class TrackGroupDeleted
|
||||
* @package App\Events
|
||||
*/
|
||||
final class TrackGroupDeleted extends TrackGroupAction
|
||||
{
|
||||
|
||||
}
|
22
app/Events/TrackGroupInserted.php
Normal file
22
app/Events/TrackGroupInserted.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php namespace App\Events;
|
||||
/**
|
||||
* Copyright 2018 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
/**
|
||||
* Class TrackGroupInserted
|
||||
* @package App\Events
|
||||
*/
|
||||
final class TrackGroupInserted extends TrackGroupAction
|
||||
{
|
||||
|
||||
}
|
22
app/Events/TrackGroupUpdated.php
Normal file
22
app/Events/TrackGroupUpdated.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php namespace App\Events;
|
||||
/**
|
||||
* Copyright 2018 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
/**
|
||||
* Class TrackGroupUpdate
|
||||
* @package App\Events
|
||||
*/
|
||||
final class TrackGroupUpdated extends TrackGroupAction
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
<?php namespace App\Factories\EntityEvents;
|
||||
/**
|
||||
* Copyright 2018 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use App\Events\SummitTicketTypeAction;
|
||||
use models\main\IMemberRepository;
|
||||
use models\oauth2\IResourceServerContext;
|
||||
use models\summit\ISummitRepository;
|
||||
use models\summit\SummitEntityEvent;
|
||||
/**
|
||||
* Class SummitTicketTypeActionEntityEventFactory
|
||||
* @package App\Factories\EntityEvents
|
||||
*/
|
||||
final class SummitTicketTypeActionEntityEventFactory
|
||||
{
|
||||
/**
|
||||
* @param SummitTicketTypeAction $event
|
||||
* @param string $type
|
||||
* @return SummitEntityEvent
|
||||
*/
|
||||
public static function build(SummitTicketTypeAction $event, $type = 'UPDATE')
|
||||
{
|
||||
$resource_server_context = App::make(IResourceServerContext::class);
|
||||
$member_repository = App::make(IMemberRepository::class);
|
||||
$summit_repository = App::make(ISummitRepository::class);
|
||||
$summit = $summit_repository->getById($event->getSummitId());
|
||||
|
||||
$owner_id = $resource_server_context->getCurrentUserExternalId();
|
||||
if (is_null($owner_id)) $owner_id = 0;
|
||||
|
||||
|
||||
$entity_event = new SummitEntityEvent;
|
||||
$entity_event->setEntityClassName('SummitTicketType');
|
||||
$entity_event->setEntityId($event->getTicketTypeId());
|
||||
$entity_event->setType($type);
|
||||
|
||||
if ($owner_id > 0) {
|
||||
$member = $member_repository->getById($owner_id);
|
||||
$entity_event->setOwner($member);
|
||||
}
|
||||
|
||||
$entity_event->setSummit($summit);
|
||||
$entity_event->setMetadata('');
|
||||
|
||||
return $entity_event;
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
<?php namespace App\Factories\EntityEvents;
|
||||
/**
|
||||
* Copyright 2018 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use App\Events\TrackGroupAction;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use models\main\IMemberRepository;
|
||||
use models\oauth2\IResourceServerContext;
|
||||
use models\summit\ISummitRepository;
|
||||
use models\summit\SummitEntityEvent;
|
||||
/**
|
||||
* Class TrackGroupActionActionEntityEventFactory
|
||||
* @package App\Factories\EntityEvents
|
||||
*/
|
||||
final class TrackGroupActionActionEntityEventFactory
|
||||
{
|
||||
/**
|
||||
* @param TrackGroupAction $event
|
||||
* @param string $type
|
||||
* @return SummitEntityEvent
|
||||
*/
|
||||
public static function build(TrackGroupAction $event, $type = 'UPDATE')
|
||||
{
|
||||
$resource_server_context = App::make(IResourceServerContext::class);
|
||||
$member_repository = App::make(IMemberRepository ::class);
|
||||
$summit_repository = App::make(ISummitRepository::class);
|
||||
$summit = $summit_repository->getById($event->getSummitId());
|
||||
|
||||
$owner_id = $resource_server_context->getCurrentUserExternalId();
|
||||
if (is_null($owner_id)) $owner_id = 0;
|
||||
|
||||
$entity_event = new SummitEntityEvent;
|
||||
$entity_event->setEntityClassName($event->getClassName());
|
||||
$entity_event->setEntityId($event->getTrackGroupId());
|
||||
$entity_event->setType($type);
|
||||
|
||||
if ($owner_id > 0) {
|
||||
$member = $member_repository->getById($owner_id);
|
||||
$entity_event->setOwner($member);
|
||||
}
|
||||
|
||||
$entity_event->setSummit($summit);
|
||||
$entity_event->setMetadata('');
|
||||
|
||||
return $entity_event;
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
/**
|
||||
* Copyright 2018 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use App\Models\Foundation\Summit\Events\Presentations\PresentationCategoryGroupConstants;
|
||||
use models\exceptions\ValidationException;
|
||||
use models\summit\PrivatePresentationCategoryGroup;
|
||||
/**
|
||||
* Class PresentationCategoryGroupValidationRulesFactory
|
||||
* @package App\Http\Controllers
|
||||
*/
|
||||
final class PresentationCategoryGroupValidationRulesFactory
|
||||
{
|
||||
/**
|
||||
* @param array $data
|
||||
* @param bool $update
|
||||
* @return array
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public static function build(array $data, $update = false){
|
||||
|
||||
if (!isset($data['class_name']))
|
||||
throw new ValidationException("class_name parameter is mandatory");
|
||||
|
||||
$class_name = trim($data['class_name']);
|
||||
|
||||
if (!in_array($class_name, PresentationCategoryGroupConstants::$valid_class_names)) {
|
||||
throw new ValidationException(
|
||||
sprintf
|
||||
(
|
||||
"class_name param has an invalid value ( valid values are %s",
|
||||
implode(", ", PresentationCategoryGroupConstants::$valid_class_names)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$base_rules = [
|
||||
'name' => 'required|string',
|
||||
'description' => 'sometimes|string',
|
||||
'color' => 'sometimes|hex_color',
|
||||
];
|
||||
|
||||
if($update){
|
||||
$base_rules = [
|
||||
'name' => 'sometimes|string',
|
||||
'description' => 'sometimes|string',
|
||||
'color' => 'sometimes|hex_color',
|
||||
];
|
||||
}
|
||||
|
||||
$specific_rules = [];
|
||||
|
||||
switch ($class_name){
|
||||
case PrivatePresentationCategoryGroup::ClassName:
|
||||
{
|
||||
$specific_rules = [
|
||||
'submission_begin_date' => 'sometimes|date_format:U',
|
||||
'submission_end_date' => 'sometimes|date_format:U|required_with:submission_begin_date|after:submission_begin_date',
|
||||
'max_submission_allowed_per_user' => 'sometimes|integer|min:1',
|
||||
];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return array_merge($base_rules, $specific_rules);
|
||||
}
|
||||
}
|
@ -44,6 +44,11 @@ final class OAuth2PresentationCategoryGroupController
|
||||
*/
|
||||
private $summit_repository;
|
||||
|
||||
/**
|
||||
* @var IPresentationCategoryGroupService
|
||||
*/
|
||||
private $presentation_category_group_service;
|
||||
|
||||
/**
|
||||
* OAuth2SummitsTicketTypesApiController constructor.
|
||||
* @param IPresentationCategoryGroupRepository $repository
|
||||
@ -62,6 +67,7 @@ final class OAuth2PresentationCategoryGroupController
|
||||
parent::__construct($resource_server_context);
|
||||
$this->repository = $repository;
|
||||
$this->summit_repository = $summit_repository;
|
||||
$this->presentation_category_group_service = $presentation_category_group_service;
|
||||
}
|
||||
/**
|
||||
* @param $summit_id
|
||||
@ -185,8 +191,6 @@ final class OAuth2PresentationCategoryGroupController
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAllBySummitCSV($summit_id){
|
||||
$values = Input::all();
|
||||
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
@ -287,4 +291,172 @@ final class OAuth2PresentationCategoryGroupController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function addTrackGroupBySummit($summit_id){
|
||||
try {
|
||||
|
||||
if(!Request::isJson()) return $this->error400();
|
||||
$data = Input::json();
|
||||
$payload = $data->all();
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
$rules = PresentationCategoryGroupValidationRulesFactory::build($payload);
|
||||
// Creates a Validator instance and validates the data.
|
||||
$validation = Validator::make($payload, $rules);
|
||||
|
||||
if ($validation->fails()) {
|
||||
$messages = $validation->messages()->toArray();
|
||||
|
||||
return $this->error412
|
||||
(
|
||||
$messages
|
||||
);
|
||||
}
|
||||
|
||||
$track_group = $this->presentation_category_group_service->addTrackGroup($summit, $payload);
|
||||
|
||||
return $this->created(SerializerRegistry::getInstance()->getSerializer($track_group)->serialize());
|
||||
}
|
||||
catch (ValidationException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error412([$ex1->getMessage()]);
|
||||
}
|
||||
catch(EntityNotFoundException $ex2)
|
||||
{
|
||||
Log::warning($ex2);
|
||||
return $this->error404(['message'=> $ex2->getMessage()]);
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @param $track_group_id
|
||||
* @param $track_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function associateTrack2TrackGroup($summit_id, $track_group_id, $track_id){
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
$this->presentation_category_group_service->associateTrack2TrackGroup($summit, $track_group_id, $track_id);
|
||||
|
||||
return $this->updated();
|
||||
}
|
||||
catch (ValidationException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error412([$ex1->getMessage()]);
|
||||
}
|
||||
catch(EntityNotFoundException $ex2)
|
||||
{
|
||||
Log::warning($ex2);
|
||||
return $this->error404(['message'=> $ex2->getMessage()]);
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @param $track_group_id
|
||||
* @param $track_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function disassociateTrack2TrackGroup($summit_id, $track_group_id, $track_id){
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
$this->presentation_category_group_service->disassociateTrack2TrackGroup($summit, $track_group_id, $track_id);
|
||||
|
||||
return $this->deleted();
|
||||
}
|
||||
catch (ValidationException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error412([$ex1->getMessage()]);
|
||||
}
|
||||
catch(EntityNotFoundException $ex2)
|
||||
{
|
||||
Log::warning($ex2);
|
||||
return $this->error404(['message'=> $ex2->getMessage()]);
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @param $track_group_id
|
||||
* @param $group_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function associateAllowedGroup2TrackGroup($summit_id, $track_group_id, $group_id){
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
$this->presentation_category_group_service->associateAllowedGroup2TrackGroup($summit, $track_group_id, $group_id);
|
||||
|
||||
return $this->updated();
|
||||
}
|
||||
catch (ValidationException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error412([$ex1->getMessage()]);
|
||||
}
|
||||
catch(EntityNotFoundException $ex2)
|
||||
{
|
||||
Log::warning($ex2);
|
||||
return $this->error404(['message'=> $ex2->getMessage()]);
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @param $track_group_id
|
||||
* @param $group_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function disassociateAllowedGroup2TrackGroup($summit_id, $track_group_id, $group_id){
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
$this->presentation_category_group_service->disassociateAllowedGroup2TrackGroup($summit, $track_group_id, $group_id);
|
||||
|
||||
return $this->deleted();
|
||||
}
|
||||
catch (ValidationException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error412([$ex1->getMessage()]);
|
||||
}
|
||||
catch(EntityNotFoundException $ex2)
|
||||
{
|
||||
Log::warning($ex2);
|
||||
return $this->error404(['message'=> $ex2->getMessage()]);
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
}
|
@ -168,21 +168,12 @@ final class OAuth2SummitsTicketTypesApiController extends OAuth2ProtectedControl
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAllBySummitCSV($summit_id){
|
||||
$values = Input::all();
|
||||
$rules = [
|
||||
];
|
||||
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
$validation = Validator::make($values, $rules);
|
||||
|
||||
if ($validation->fails()) {
|
||||
$ex = new ValidationException();
|
||||
throw $ex->setMessages($validation->messages()->toArray());
|
||||
}
|
||||
|
||||
// default values
|
||||
$page = 1;
|
||||
|
@ -486,8 +486,24 @@ Route::group([
|
||||
Route::group(['prefix' => 'track-groups'], function () {
|
||||
Route::get('', 'OAuth2PresentationCategoryGroupController@getAllBySummit');
|
||||
Route::get('csv', 'OAuth2PresentationCategoryGroupController@getAllBySummitCSV');
|
||||
Route::post('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2PresentationCategoryGroupController@addTrackGroupBySummit']);
|
||||
|
||||
Route::group(['prefix' => '{track_group_id}'], function () {
|
||||
|
||||
Route::group(['prefix' => 'tracks'], function () {
|
||||
|
||||
Route::group(['prefix' => '{track_id}'], function () {
|
||||
Route::put('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2PresentationCategoryGroupController@associateTrack2TrackGroup']);
|
||||
Route::delete('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2PresentationCategoryGroupController@disassociateTrack2TrackGroup']);
|
||||
});
|
||||
});
|
||||
Route::group(['prefix' => 'allowed-groups'], function () {
|
||||
|
||||
Route::group(['prefix' => '{group_id}'], function () {
|
||||
Route::put('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2PresentationCategoryGroupController@associateAllowedGroup2TrackGroup']);
|
||||
Route::delete('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2PresentationCategoryGroupController@disassociateAllowedGroup2TrackGroup']);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -26,7 +26,7 @@ final class PresentationCategoryGroupEntityEventType extends GenericSummitEntity
|
||||
*/
|
||||
protected function registerEntity()
|
||||
{
|
||||
$entity = $this->entity_event->getSummit()->getCategoryGroup($this->entity_event->getEntityId());
|
||||
$entity = $this->entity_event->getSummit()->getCategoryGroupById($this->entity_event->getEntityId());
|
||||
if(is_null($entity)) return null;
|
||||
$this->entity_event->registerEntity($entity);
|
||||
return $entity;
|
||||
|
@ -27,7 +27,7 @@ final class TrackFromTrackGroupEventType extends EntityEventType
|
||||
{
|
||||
$metadata = $this->entity_event->getMetadata();
|
||||
if(!isset($metadata['group_id'])) return null;
|
||||
$group = $this->entity_event->getSummit()->getCategoryGroup(intval($metadata['group_id']));
|
||||
$group = $this->entity_event->getSummit()->getCategoryGroupById(intval($metadata['group_id']));
|
||||
if (is_null($group)) return null;
|
||||
$this->entity_event->registerEntity($group);
|
||||
return $group;
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php namespace models\summit;
|
||||
|
||||
/**
|
||||
* Copyright 2018 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -11,13 +12,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use models\main\Group;
|
||||
use models\summit\PresentationCategoryGroup;
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use models\main\Group;
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
/**
|
||||
* Class PrivatePresentationCategoryGroup
|
||||
* @ORM\Entity
|
||||
@ -57,16 +57,18 @@ class PrivatePresentationCategoryGroup extends PresentationCategoryGroup
|
||||
/**
|
||||
* @param Group $group
|
||||
*/
|
||||
public function addToGroup(Group $group){
|
||||
if($this->allowed_groups->contains($group)) return;
|
||||
public function addToGroup(Group $group)
|
||||
{
|
||||
if ($this->allowed_groups->contains($group)) return;
|
||||
$this->allowed_groups->add($group);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Group $group
|
||||
*/
|
||||
public function removeFromGroup(Group $group){
|
||||
if(!$this->allowed_groups->contains($group)) return;
|
||||
public function removeFromGroup(Group $group)
|
||||
{
|
||||
if (!$this->allowed_groups->contains($group)) return;
|
||||
$this->allowed_groups->removeElement($group);
|
||||
}
|
||||
|
||||
@ -74,7 +76,8 @@ class PrivatePresentationCategoryGroup extends PresentationCategoryGroup
|
||||
* @param int $group_id
|
||||
* @return Group|null
|
||||
*/
|
||||
public function getGroupById($group_id){
|
||||
public function getGroupById($group_id)
|
||||
{
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('id', intval($group_id)));
|
||||
$res = $this->allowed_groups->matching($criteria)->first();
|
||||
@ -85,7 +88,8 @@ class PrivatePresentationCategoryGroup extends PresentationCategoryGroup
|
||||
* @param int $group_id
|
||||
* @return bool
|
||||
*/
|
||||
public function belongsToGroup($group_id){
|
||||
public function belongsToGroup($group_id)
|
||||
{
|
||||
return $this->getGroupById($group_id) != null;
|
||||
}
|
||||
|
||||
@ -95,14 +99,13 @@ class PrivatePresentationCategoryGroup extends PresentationCategoryGroup
|
||||
public function isSubmissionOpen()
|
||||
{
|
||||
|
||||
if (empty($this->submission_begin_date) || empty($this->submission_end_date))
|
||||
{
|
||||
if (empty($this->submission_begin_date) || empty($this->submission_end_date)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$start_date = new DateTime($this->submission_begin_date->getTimestamp(), new DateTimeZone('UTC'));
|
||||
$end_date = new DateTime($this->submission_end_date->getTimestamp(), new DateTimeZone('UTC'));
|
||||
$now = new DateTime('now', new DateTimeZone('UTC'));
|
||||
$end_date = new DateTime($this->submission_end_date->getTimestamp(), new DateTimeZone('UTC'));
|
||||
$now = new DateTime('now', new DateTimeZone('UTC'));
|
||||
|
||||
return ($now >= $start_date && $now <= $end_date);
|
||||
}
|
||||
@ -110,7 +113,8 @@ class PrivatePresentationCategoryGroup extends PresentationCategoryGroup
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->allowed_groups = new ArrayCollection;
|
||||
$this->allowed_groups = new ArrayCollection;
|
||||
$this->max_submission_allowed_per_user = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -150,7 +154,75 @@ class PrivatePresentationCategoryGroup extends PresentationCategoryGroup
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName(){
|
||||
public function getClassName()
|
||||
{
|
||||
return self::ClassName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateTime $submission_begin_date
|
||||
*/
|
||||
public function setSubmissionBeginDate(DateTime $submission_begin_date)
|
||||
{
|
||||
$summit = $this->getSummit();
|
||||
if (!is_null($summit)) {
|
||||
$submission_begin_date = $summit->convertDateFromTimeZone2UTC($submission_begin_date);
|
||||
}
|
||||
$this->submission_begin_date = $submission_begin_date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateTime $submission_end_date
|
||||
*/
|
||||
public function setSubmissionEndDate(DateTime $submission_end_date)
|
||||
{
|
||||
$summit = $this->getSummit();
|
||||
if (!is_null($summit)) {
|
||||
$submission_end_date = $summit->convertDateFromTimeZone2UTC($submission_end_date);
|
||||
}
|
||||
$this->submission_end_date = $submission_end_date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $max_submission_allowed_per_user
|
||||
*/
|
||||
public function setMaxSubmissionAllowedPerUser($max_submission_allowed_per_user)
|
||||
{
|
||||
$this->max_submission_allowed_per_user = $max_submission_allowed_per_user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTime|null
|
||||
*/
|
||||
public function getLocalSubmissionBeginDate()
|
||||
{
|
||||
$res = null;
|
||||
if(!empty($this->submission_begin_date)) {
|
||||
$value = clone $this->submission_begin_date;
|
||||
$summit = $this->getSummit();
|
||||
if(!is_null($summit))
|
||||
{
|
||||
$res = $summit->convertDateFromUTC2TimeZone($value);
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTime|null
|
||||
*/
|
||||
public function getLocalSubmissionEndDate()
|
||||
{
|
||||
$res = null;
|
||||
if(!empty($this->submission_end_date)) {
|
||||
$value = clone $this->submission_end_date;
|
||||
$summit = $this->getSummit();
|
||||
if(!is_null($summit))
|
||||
{
|
||||
$res = $summit->convertDateFromUTC2TimeZone($value);
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,117 @@
|
||||
<?php namespace App\Models\Foundation\Summit\Factories;
|
||||
/**
|
||||
* Copyright 2018 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use models\exceptions\ValidationException;
|
||||
use models\summit\PresentationCategoryGroup;
|
||||
use models\summit\PrivatePresentationCategoryGroup;
|
||||
use models\summit\Summit;
|
||||
/**
|
||||
* Class PresentationCategoryGroupFactory
|
||||
* @package App\Models\Foundation\Summit\Factories
|
||||
*/
|
||||
final class PresentationCategoryGroupFactory
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param array $data
|
||||
* @return null
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public static function build(Summit $summit, array $data){
|
||||
if(!isset($data['class_name']))
|
||||
throw new ValidationException("missing class_name param");
|
||||
$track_group = null;
|
||||
switch($data['class_name']){
|
||||
case PresentationCategoryGroup::ClassName :{
|
||||
$track_group = self::populatePresentationCategoryGroup(new PresentationCategoryGroup, $data);
|
||||
}
|
||||
break;
|
||||
case PrivatePresentationCategoryGroup::ClassName :{
|
||||
$track_group = self::populatePrivatePresentationCategoryGroup($summit, new PrivatePresentationCategoryGroup, $data);
|
||||
}
|
||||
}
|
||||
return $track_group;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param PresentationCategoryGroup $track_group
|
||||
* @param array $data
|
||||
* @return PresentationCategoryGroup
|
||||
*/
|
||||
private static function populatePresentationCategoryGroup(PresentationCategoryGroup $track_group, array $data){
|
||||
if(isset($data['name']))
|
||||
$track_group->setName(trim($data['name']));
|
||||
|
||||
if(isset($data['description']))
|
||||
$track_group->setDescription(trim($data['description']));
|
||||
|
||||
if(isset($data['color']))
|
||||
$track_group->setColor(trim($data['color']));
|
||||
|
||||
return $track_group;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param PrivatePresentationCategoryGroup $track_group
|
||||
* @param array $data
|
||||
* @return PresentationCategoryGroup
|
||||
*/
|
||||
private static function populatePrivatePresentationCategoryGroup
|
||||
(
|
||||
Summit $summit,
|
||||
PrivatePresentationCategoryGroup $track_group,
|
||||
array $data
|
||||
)
|
||||
{
|
||||
|
||||
$track_group->setSummit($summit);
|
||||
|
||||
if(isset($data['submission_begin_date'])) {
|
||||
$start_datetime = intval($data['submission_begin_date']);
|
||||
$start_datetime = new \DateTime("@$start_datetime");
|
||||
$start_datetime->setTimezone($summit->getTimeZone());
|
||||
$track_group->setSubmissionBeginDate($start_datetime);
|
||||
}
|
||||
|
||||
if(isset($data['submission_end_date'])) {
|
||||
$end_datetime = intval($data['submission_end_date']);
|
||||
$end_datetime = new \DateTime("@$end_datetime");
|
||||
$end_datetime->setTimezone($summit->getTimeZone());
|
||||
$track_group->setSubmissionEndDate($end_datetime);
|
||||
}
|
||||
|
||||
if(isset($data['max_submission_allowed_per_user']))
|
||||
$track_group->setMaxSubmissionAllowedPerUser(intval($data['max_submission_allowed_per_user']));
|
||||
|
||||
return self::populatePresentationCategoryGroup($track_group, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param PresentationCategoryGroup $track_group
|
||||
* @param array $data
|
||||
* @return PresentationCategoryGroup
|
||||
*/
|
||||
public static function populate(Summit $summit, PresentationCategoryGroup $track_group, array $data){
|
||||
if($track_group instanceof PrivatePresentationCategoryGroup){
|
||||
return self::populatePrivatePresentationCategoryGroup($track_group, $data);
|
||||
}
|
||||
else if($track_group instanceof PresentationCategoryGroup){
|
||||
return self::populatePresentationCategoryGroup($summit, $track_group,$data);
|
||||
}
|
||||
return $track_group;
|
||||
}
|
||||
}
|
@ -950,7 +950,7 @@ class Summit extends SilverstripeBaseModel
|
||||
* @param int $group_id
|
||||
* @return null|PresentationCategoryGroup
|
||||
*/
|
||||
public function getCategoryGroup($group_id)
|
||||
public function getCategoryGroupById($group_id)
|
||||
{
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('id', intval($group_id)));
|
||||
@ -958,6 +958,35 @@ class Summit extends SilverstripeBaseModel
|
||||
return $group === false ? null : $group;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return null|PresentationCategoryGroup
|
||||
*/
|
||||
public function getCategoryGroupByName($name)
|
||||
{
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('name', trim($name)));
|
||||
$group = $this->category_groups->matching($criteria)->first();
|
||||
return $group === false ? null : $group;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PresentationCategoryGroup $track_group
|
||||
*/
|
||||
public function addCategoryGroup(PresentationCategoryGroup $track_group){
|
||||
if($this->category_groups->contains($track_group)) return;
|
||||
$this->category_groups->add($track_group);
|
||||
$track_group->setSummit($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PresentationCategoryGroup $track_group
|
||||
*/
|
||||
public function removeCategoryGroup(PresentationCategoryGroup $track_group){
|
||||
if(!$this->category_groups->contains($track_group)) return;
|
||||
$this->category_groups->removeElement($track_group);
|
||||
$track_group->clearSummit();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $member_id
|
||||
|
@ -36,7 +36,9 @@ use App\Factories\EntityEvents\SummitEventCreatedEntityEventFactory;
|
||||
use App\Factories\EntityEvents\SummitEventDeletedEntityEventFactory;
|
||||
use App\Factories\EntityEvents\SummitEventTypeActionEntityEventFactory;
|
||||
use App\Factories\EntityEvents\SummitEventUpdatedEntityEventFactory;
|
||||
use App\Factories\EntityEvents\SummitTicketTypeActionEntityEventFactory;
|
||||
use App\Factories\EntityEvents\TrackActionEntityEventFactory;
|
||||
use App\Factories\EntityEvents\TrackGroupActionActionEntityEventFactory;
|
||||
use App\Services\Utils\SCPFileUploader;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
@ -269,5 +271,38 @@ final class EventServiceProvider extends ServiceProvider
|
||||
EntityEventPersister::persist(LocationImageActionEntityEventFactory::build($event, 'DELETE'));
|
||||
});
|
||||
|
||||
// ticket types
|
||||
|
||||
Event::listen(\App\Events\SummitTicketTypeInserted::class, function($event)
|
||||
{
|
||||
EntityEventPersister::persist(SummitTicketTypeActionEntityEventFactory::build($event, 'INSERT'));
|
||||
});
|
||||
|
||||
Event::listen(\App\Events\SummitTicketTypeUpdated::class, function($event)
|
||||
{
|
||||
EntityEventPersister::persist(SummitTicketTypeActionEntityEventFactory::build($event, 'UPDATE'));
|
||||
});
|
||||
|
||||
Event::listen(\App\Events\SummitTicketTypeDeleted::class, function($event)
|
||||
{
|
||||
EntityEventPersister::persist(SummitTicketTypeActionEntityEventFactory::build($event, 'DELETE'));
|
||||
});
|
||||
|
||||
// track groups
|
||||
|
||||
Event::listen(\App\Events\TrackGroupInserted::class, function($event)
|
||||
{
|
||||
EntityEventPersister::persist(TrackGroupActionActionEntityEventFactory::build($event, 'INSERT'));
|
||||
});
|
||||
|
||||
Event::listen(\App\Events\TrackGroupUpdated::class, function($event)
|
||||
{
|
||||
EntityEventPersister::persist(TrackGroupActionActionEntityEventFactory::build($event, 'UPDATE'));
|
||||
});
|
||||
|
||||
Event::listen(\App\Events\TrackGroupDeleted::class, function($event)
|
||||
{
|
||||
EntityEventPersister::persist(TrackGroupActionActionEntityEventFactory::build($event, 'DELETE'));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,8 @@ final class SummitScopes
|
||||
|
||||
const WriteTracksData = '%s/tracks/write';
|
||||
|
||||
const WriteTrackGroupsData = '%s/track-groups/write';
|
||||
|
||||
const WriteLocationsData = '%s/locations/write';
|
||||
|
||||
const WriteRSVPTemplateData = '%s/rsvp-templates/write';
|
||||
|
@ -11,7 +11,82 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use models\exceptions\EntityNotFoundException;
|
||||
use models\exceptions\ValidationException;
|
||||
use models\summit\PresentationCategoryGroup;
|
||||
use models\summit\Summit;
|
||||
/**
|
||||
* Interface IPresentationCategoryGroupService
|
||||
* @package App\Services\Model
|
||||
*/
|
||||
interface IPresentationCategoryGroupService
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param array $data
|
||||
* @return PresentationCategoryGroup
|
||||
* @throws EntityNotFoundException
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function addTrackGroup(Summit $summit, array $data);
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param int $track_group_id
|
||||
* @param array $data
|
||||
* @return PresentationCategoryGroup
|
||||
* @throws EntityNotFoundException
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function updateTrackGroup(Summit $summit, $track_group_id, array $data);
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param int $track_group_id
|
||||
* @return void
|
||||
* @throws EntityNotFoundException
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function deleteTrackGroup(Summit $summit, $track_group_id);
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param int $track_group_id
|
||||
* @param int $track_id
|
||||
* @return void
|
||||
* @throws EntityNotFoundException
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function associateTrack2TrackGroup(Summit $summit, $track_group_id, $track_id);
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param int $track_group_id
|
||||
* @param int $track_id
|
||||
* @return void
|
||||
* @throws EntityNotFoundException
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function disassociateTrack2TrackGroup(Summit $summit, $track_group_id, $track_id);
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param int $track_group_id
|
||||
* @param int $group_id
|
||||
* @return void
|
||||
* @throws EntityNotFoundException
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function associateAllowedGroup2TrackGroup(Summit $summit, $track_group_id, $group_id);
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param int $track_group_id
|
||||
* @param int $group_id
|
||||
* @return void
|
||||
* @throws EntityNotFoundException
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function disassociateAllowedGroup2TrackGroup(Summit $summit, $track_group_id, $group_id);
|
||||
}
|
@ -11,7 +11,18 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use App\Events\TrackGroupDeleted;
|
||||
use App\Events\TrackGroupInserted;
|
||||
use App\Events\TrackGroupUpdated;
|
||||
use App\Models\Foundation\Summit\Factories\PresentationCategoryGroupFactory;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use libs\utils\ITransactionService;
|
||||
use models\exceptions\EntityNotFoundException;
|
||||
use models\exceptions\ValidationException;
|
||||
use models\main\IGroupRepository;
|
||||
use models\summit\PresentationCategoryGroup;
|
||||
use models\summit\PrivatePresentationCategoryGroup;
|
||||
use models\summit\Summit;
|
||||
/**
|
||||
* Class PresentationCategoryGroupService
|
||||
* @package App\Services\Model
|
||||
@ -20,5 +31,421 @@ final class PresentationCategoryGroupService
|
||||
extends AbstractService
|
||||
implements IPresentationCategoryGroupService
|
||||
{
|
||||
/**
|
||||
* @var IGroupRepository
|
||||
*/
|
||||
private $group_repository;
|
||||
|
||||
/**
|
||||
* PresentationCategoryGroupService constructor.
|
||||
* @param IGroupRepository $group_repository
|
||||
* @param ITransactionService $tx_service
|
||||
*/
|
||||
public function __construct
|
||||
(
|
||||
IGroupRepository $group_repository,
|
||||
ITransactionService $tx_service
|
||||
)
|
||||
{
|
||||
parent::__construct($tx_service);
|
||||
$this->group_repository = $group_repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param array $data
|
||||
* @return PresentationCategoryGroup
|
||||
* @throws EntityNotFoundException
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function addTrackGroup(Summit $summit, array $data)
|
||||
{
|
||||
$track_group = $this->tx_service->transaction(function () use ($summit, $data) {
|
||||
|
||||
$former_track_group = $summit->getCategoryGroupByName(trim($data['name']));
|
||||
if (!is_null($former_track_group)) {
|
||||
throw new ValidationException
|
||||
(
|
||||
trans('validation_errors.PresentationCategoryGroupService.addTrackGroup.NameAlreadyExists'),
|
||||
[
|
||||
'name' => trim($data['name']),
|
||||
'summit_id' => $summit->getId(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$track_group = PresentationCategoryGroupFactory::build($summit, $data);
|
||||
|
||||
$summit->addCategoryGroup($track_group);
|
||||
|
||||
return $track_group;
|
||||
});
|
||||
|
||||
Event::fire
|
||||
(
|
||||
new TrackGroupInserted
|
||||
(
|
||||
|
||||
$track_group->getId(),
|
||||
$track_group->getSummitId(),
|
||||
$track_group->getClassName()
|
||||
)
|
||||
);
|
||||
|
||||
return $track_group;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param int $track_group_id
|
||||
* @param array $data
|
||||
* @return PresentationCategoryGroup
|
||||
* @throws EntityNotFoundException
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function updateTrackGroup(Summit $summit, $track_group_id, array $data)
|
||||
{
|
||||
$this->tx_service->transaction(function () use ($summit, $track_group_id, $data) {
|
||||
|
||||
if (isset($data['name'])) {
|
||||
$former_track_group = $summit->getCategoryGroupByName(trim($data['name']));
|
||||
if (!is_null($former_track_group) && $former_track_group->getId() != $track_group_id) {
|
||||
throw new ValidationException
|
||||
(
|
||||
trans('validation_errors.PresentationCategoryGroupService.updateTrackGroup.NameAlreadyExists'),
|
||||
[
|
||||
'name' => trim($data['name']),
|
||||
'summit_id' => $summit->getId(),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$track_group = $summit->getCategoryGroupById($track_group_id);
|
||||
|
||||
if (is_null($track_group)) {
|
||||
throw new EntityNotFoundException
|
||||
(
|
||||
trans('not_found_errors.PresentationCategoryGroupService.updateTrackGroup.TrackGroupNotFound'),
|
||||
[
|
||||
'track_group_id' => $track_group_id,
|
||||
'summit_id' => $summit->getId(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
Event::fire
|
||||
(
|
||||
new TrackGroupInserted
|
||||
(
|
||||
|
||||
$track_group->getId(),
|
||||
$track_group->getSummitId(),
|
||||
$track_group->getClassName()
|
||||
)
|
||||
);
|
||||
|
||||
return PresentationCategoryGroupFactory::populate($summit, $track_group, $data);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param int $track_group_id
|
||||
* @return void
|
||||
* @throws EntityNotFoundException
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function deleteTrackGroup(Summit $summit, $track_group_id)
|
||||
{
|
||||
return $this->tx_service->transaction(function () use ($summit, $track_group_id) {
|
||||
|
||||
$track_group = $summit->getCategoryGroupById($track_group_id);
|
||||
|
||||
if (is_null($track_group)) {
|
||||
throw new EntityNotFoundException
|
||||
(
|
||||
trans
|
||||
(
|
||||
'not_found_errors.PresentationCategoryGroupService.deleteTrackGroup.TrackGroupNotFound',
|
||||
[
|
||||
'track_group_id' => $track_group_id,
|
||||
'summit_id' => $summit->getId()
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Event::fire
|
||||
(
|
||||
new TrackGroupDeleted
|
||||
(
|
||||
$track_group->getId(),
|
||||
$track_group->getSummitId(),
|
||||
$track_group->getClassName()
|
||||
)
|
||||
);
|
||||
|
||||
$summit->removeCategoryGroup($track_group);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param int $track_group_id
|
||||
* @param int $track_id
|
||||
* @return void
|
||||
* @throws EntityNotFoundException
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function associateTrack2TrackGroup(Summit $summit, $track_group_id, $track_id)
|
||||
{
|
||||
return $this->tx_service->transaction(function () use ($summit, $track_group_id, $track_id) {
|
||||
$track_group = $summit->getCategoryGroupById($track_group_id);
|
||||
|
||||
if (is_null($track_group)) {
|
||||
throw new EntityNotFoundException
|
||||
(
|
||||
trans
|
||||
(
|
||||
'not_found_errors.PresentationCategoryGroupService.associateTrack2TrackGroup.TrackGroupNotFound',
|
||||
[
|
||||
'track_group_id' => $track_group_id,
|
||||
'summit_id' => $summit->getId()
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$track = $summit->getPresentationCategory($track_id);
|
||||
|
||||
if (is_null($track)) {
|
||||
throw new EntityNotFoundException
|
||||
(
|
||||
trans
|
||||
(
|
||||
'not_found_errors.PresentationCategoryGroupService.associateTrack2TrackGroup.TrackNotFound',
|
||||
[
|
||||
'track_id' => $track_id,
|
||||
'summit_id' => $summit->getId()
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$track_group->addCategory($track);
|
||||
|
||||
Event::fire
|
||||
(
|
||||
new TrackGroupUpdated
|
||||
(
|
||||
$track_group->getId(),
|
||||
$track_group->getSummitId(),
|
||||
$track_group->getClassName()
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param int $track_group_id
|
||||
* @param int $track_id
|
||||
* @return void
|
||||
* @throws EntityNotFoundException
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function disassociateTrack2TrackGroup(Summit $summit, $track_group_id, $track_id)
|
||||
{
|
||||
return $this->tx_service->transaction(function () use ($summit, $track_group_id, $track_id) {
|
||||
|
||||
$track_group = $summit->getCategoryGroupById($track_group_id);
|
||||
|
||||
if (is_null($track_group)) {
|
||||
throw new EntityNotFoundException
|
||||
(
|
||||
trans
|
||||
(
|
||||
'not_found_errors.PresentationCategoryGroupService.disassociateTrack2TrackGroup.TrackGroupNotFound',
|
||||
[
|
||||
'track_group_id' => $track_group_id,
|
||||
'summit_id' => $summit->getId()
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$track = $summit->getPresentationCategory($track_id);
|
||||
|
||||
if (is_null($track)) {
|
||||
throw new EntityNotFoundException
|
||||
(
|
||||
trans
|
||||
(
|
||||
'not_found_errors.PresentationCategoryGroupService.disassociateTrack2TrackGroup.TrackNotFound',
|
||||
[
|
||||
'track_id' => $track_id,
|
||||
'summit_id' => $summit->getId()
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$track_group->removeCategory($track);
|
||||
|
||||
Event::fire
|
||||
(
|
||||
new TrackGroupUpdated
|
||||
(
|
||||
$track_group->getId(),
|
||||
$track_group->getSummitId(),
|
||||
$track_group->getClassName()
|
||||
)
|
||||
);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param int $track_group_id
|
||||
* @param int $group_id
|
||||
* @return void
|
||||
* @throws EntityNotFoundException
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function associateAllowedGroup2TrackGroup(Summit $summit, $track_group_id, $group_id)
|
||||
{
|
||||
return $this->tx_service->transaction(function () use ($summit, $track_group_id, $group_id) {
|
||||
|
||||
$track_group = $summit->getCategoryGroupById($track_group_id);
|
||||
|
||||
if (is_null($track_group)) {
|
||||
throw new EntityNotFoundException
|
||||
(
|
||||
trans
|
||||
(
|
||||
'not_found_errors.PresentationCategoryGroupService.associateAllowedGroup2TrackGroup.TrackGroupNotFound',
|
||||
[
|
||||
'track_group_id' => $track_group_id,
|
||||
'summit_id' => $summit->getId()
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (!$track_group instanceof PrivatePresentationCategoryGroup) {
|
||||
throw new EntityNotFoundException
|
||||
(
|
||||
trans
|
||||
(
|
||||
'not_found_errors.PresentationCategoryGroupService.associateAllowedGroup2TrackGroup.TrackGroupNotFound',
|
||||
[
|
||||
'track_group_id' => $track_group_id,
|
||||
'summit_id' => $summit->getId()
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$group = $this->group_repository->getById($group_id);
|
||||
|
||||
if (is_null($group)) {
|
||||
throw new EntityNotFoundException
|
||||
(
|
||||
trans
|
||||
(
|
||||
'not_found_errors.PresentationCategoryGroupService.associateAllowedGroup2TrackGroup.GroupNotFound',
|
||||
[
|
||||
'group_id' => $group_id,
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$track_group->addToGroup($group);
|
||||
|
||||
Event::fire
|
||||
(
|
||||
new TrackGroupUpdated
|
||||
(
|
||||
$track_group->getId(),
|
||||
$track_group->getSummitId(),
|
||||
$track_group->getClassName()
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param int $track_group_id
|
||||
* @param int $group_id
|
||||
* @return void
|
||||
* @throws EntityNotFoundException
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function disassociateAllowedGroup2TrackGroup(Summit $summit, $track_group_id, $group_id)
|
||||
{
|
||||
return $this->tx_service->transaction(function () use ($summit, $track_group_id, $group_id) {
|
||||
|
||||
$track_group = $summit->getCategoryGroupById($track_group_id);
|
||||
|
||||
if (is_null($track_group)) {
|
||||
throw new EntityNotFoundException
|
||||
(
|
||||
trans
|
||||
(
|
||||
'not_found_errors.PresentationCategoryGroupService.disassociateAllowedGroup2TrackGroup.TrackGroupNotFound',
|
||||
[
|
||||
'track_group_id' => $track_group_id,
|
||||
'summit_id' => $summit->getId()
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (!$track_group instanceof PrivatePresentationCategoryGroup) {
|
||||
throw new EntityNotFoundException
|
||||
(
|
||||
trans
|
||||
(
|
||||
'not_found_errors.PresentationCategoryGroupService.disassociateAllowedGroup2TrackGroup.TrackGroupNotFound',
|
||||
[
|
||||
'track_group_id' => $track_group_id,
|
||||
'summit_id' => $summit->getId()
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$group = $this->group_repository->getById($group_id);
|
||||
|
||||
if (is_null($group)) {
|
||||
throw new EntityNotFoundException
|
||||
(
|
||||
trans
|
||||
(
|
||||
'not_found_errors.PresentationCategoryGroupService.disassociateAllowedGroup2TrackGroup.GroupNotFound',
|
||||
[
|
||||
'group_id' => $group_id,
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$track_group->removeFromGroup($group);
|
||||
|
||||
Event::fire
|
||||
(
|
||||
new TrackGroupUpdated
|
||||
(
|
||||
$track_group->getId(),
|
||||
$track_group->getSummitId(),
|
||||
$track_group->getClassName()
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
@ -11,7 +11,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use App\Events\SummitTicketTypeInserted;
|
||||
use App\Events\SummitTicketTypeDeleted;
|
||||
use App\Events\SummitTicketTypeUpdated;
|
||||
use App\Models\Foundation\Summit\Factories\SummitTicketTypeFactory;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use libs\utils\ITransactionService;
|
||||
use models\exceptions\EntityNotFoundException;
|
||||
use models\exceptions\ValidationException;
|
||||
@ -19,7 +23,6 @@ use models\summit\ISummitTicketTypeRepository;
|
||||
use models\summit\Summit;
|
||||
use models\summit\SummitTicketType;
|
||||
use services\apis\IEventbriteAPI;
|
||||
|
||||
/**
|
||||
* Class SummitTicketTypeService
|
||||
* @package App\Services\Model
|
||||
@ -66,7 +69,7 @@ final class SummitTicketTypeService
|
||||
*/
|
||||
public function addTicketType(Summit $summit, array $data)
|
||||
{
|
||||
return $this->tx_service->transaction(function() use ($summit, $data){
|
||||
$ticket_type = $this->tx_service->transaction(function() use ($summit, $data){
|
||||
|
||||
$former_ticket_type = $summit->getTicketTypeByName(trim($data['name']));
|
||||
|
||||
@ -104,6 +107,18 @@ final class SummitTicketTypeService
|
||||
$summit->addTicketType($ticket_type);
|
||||
return $ticket_type;
|
||||
});
|
||||
|
||||
Event::fire
|
||||
(
|
||||
new SummitTicketTypeInserted
|
||||
(
|
||||
$ticket_type->getId(),
|
||||
$ticket_type->getSummitId()
|
||||
)
|
||||
);
|
||||
|
||||
return $ticket_type;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -171,6 +186,15 @@ final class SummitTicketTypeService
|
||||
|
||||
$ticket_type = SummitTicketTypeFactory::populate($ticket_type, $data);
|
||||
|
||||
Event::fire
|
||||
(
|
||||
new SummitTicketTypeUpdated
|
||||
(
|
||||
$ticket_type->getId(),
|
||||
$ticket_type->getSummitId()
|
||||
)
|
||||
);
|
||||
|
||||
return $ticket_type;
|
||||
});
|
||||
}
|
||||
@ -202,6 +226,15 @@ final class SummitTicketTypeService
|
||||
);
|
||||
}
|
||||
|
||||
Event::fire
|
||||
(
|
||||
new SummitTicketTypeDeleted
|
||||
(
|
||||
$ticket_type->getId(),
|
||||
$ticket_type->getSummitId()
|
||||
)
|
||||
);
|
||||
|
||||
$summit->removeTicketType($ticket_type);
|
||||
});
|
||||
}
|
||||
@ -256,6 +289,17 @@ final class SummitTicketTypeService
|
||||
$res[] = $new_ticket_type;
|
||||
}
|
||||
|
||||
foreach ($res as $ticket_type){
|
||||
Event::fire
|
||||
(
|
||||
new SummitTicketTypeInserted
|
||||
(
|
||||
$ticket_type->getId(),
|
||||
$ticket_type->getSummitId()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $res;
|
||||
});
|
||||
}
|
||||
|
@ -1196,6 +1196,51 @@ class ApiEndpointsSeeder extends Seeder
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'add-track-group',
|
||||
'route' => '/api/v1/summits/{id}/track-groups',
|
||||
'http_method' => 'POST',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WriteTrackGroupsData, $current_realm),
|
||||
sprintf(SummitScopes::WriteSummitData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'associate-track-2-track-group',
|
||||
'route' => '/api/v1/summits/{id}/track-groups/{track_group_id}/tracks/{track_id}',
|
||||
'http_method' => 'PUT',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WriteTrackGroupsData, $current_realm),
|
||||
sprintf(SummitScopes::WriteSummitData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'disassociate-track-2-track-group',
|
||||
'route' => '/api/v1/summits/{id}/track-groups/{track_group_id}/tracks/{track_id}',
|
||||
'http_method' => 'DELETE',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WriteTrackGroupsData, $current_realm),
|
||||
sprintf(SummitScopes::WriteSummitData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'associate-group-2-track-group',
|
||||
'route' => '/api/v1/summits/{id}/track-groups/{track_group_id}/allowed-groups/{group_id}',
|
||||
'http_method' => 'PUT',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WriteTrackGroupsData, $current_realm),
|
||||
sprintf(SummitScopes::WriteSummitData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'disassociate-group-2-track-group',
|
||||
'route' => '/api/v1/summits/{id}/track-groups/{track_group_id}/allowed-groups/{group_id}',
|
||||
'http_method' => 'DELETE',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WriteTrackGroupsData, $current_realm),
|
||||
sprintf(SummitScopes::WriteSummitData, $current_realm)
|
||||
],
|
||||
],
|
||||
//external orders
|
||||
array(
|
||||
'name' => 'get-external-order',
|
||||
|
@ -41,7 +41,7 @@ return [
|
||||
'LocationService.updateLocationImage.ImageNotFound' => 'image :image_id does not belongs to location :location_id',
|
||||
'LocationService.deleteLocationImage.LocationNotFound' => 'location :location_id not found on summit :summit_id',
|
||||
'LocationService.deleteLocationImage.ImageNotFound' => 'image :image_id not found on location :location_id',
|
||||
// RSVP Template Service
|
||||
// RSVPTemplateService
|
||||
'RSVPTemplateService.deleteTemplate.TemplateNotFound' => 'template :template_id not found on summit :summit_id',
|
||||
'RSVPTemplateService.addQuestion.TemplateNotFound' => 'template :template_id not found on summit :summit_id',
|
||||
'RSVPTemplateService.updateQuestion.TemplateNotFound' => 'template :template_id not found on summit :summit_id',
|
||||
@ -53,6 +53,18 @@ return [
|
||||
'RSVPTemplateService.deleteQuestionValue.TemplateNotFound' => 'template :template_id not found on summit :summit_id',
|
||||
'RSVPTemplateService.deleteQuestionValue.QuestionNotFound' => 'question :question_id not found on template :template_id',
|
||||
'RSVPTemplateService.deleteQuestionValue.ValueNotFound' => 'value :value_id not found on question :question_id',
|
||||
// SummitTicketTypeService
|
||||
'SummitTicketTypeService.updateTicketType.TicketTypeNotFound' => 'ticket type :ticket_type_id does not exists on summit :summit_id',
|
||||
'SummitTicketTypeService.deleteTicketType.TicketTypeNotFound' => 'ticket type :ticket_type_id does not exists on summit :summit_id',
|
||||
// PresentationCategoryGroupService
|
||||
'PresentationCategoryGroupService.updateTrackGroup.TrackGroupNotFound' => 'track group :track_group_id does not exists on summit :summit_id',
|
||||
'PresentationCategoryGroupService.deleteTrackGroup.TrackGroupNotFound' => 'track group :track_group_id does not exists on summit :summit_id',
|
||||
'PresentationCategoryGroupService.associateTrack2TrackGroup.TrackGroupNotFound' => 'track group :track_group_id does not exists on summit :summit_id',
|
||||
'PresentationCategoryGroupService.associateTrack2TrackGroup.TrackNotFound' => 'track :track_id does not exists on summit :summit_id',
|
||||
'PresentationCategoryGroupService.disassociateTrack2TrackGroup.TrackGroupNotFound' => 'track group :track_group_id does not exists on summit :summit_id',
|
||||
'PresentationCategoryGroupService.disassociateTrack2TrackGroup.TrackNotFound' => 'track :track_id does not exists on summit :summit_id',
|
||||
'PresentationCategoryGroupService.associateAllowedGroup2TrackGroup.TrackGroupNotFound' => 'track group :track_group_id does not exists on summit :summit_id',
|
||||
'PresentationCategoryGroupService.associateAllowedGroup2TrackGroup.GroupNotFound' => 'group :group_id does not exists.',
|
||||
'PresentationCategoryGroupService.disassociateAllowedGroup2TrackGroup.TrackGroupNotFound' => 'track group :track_group_id does not exists on summit :summit_id',
|
||||
'PresentationCategoryGroupService.disassociateAllowedGroup2TrackGroup.GroupNotFound' => 'group :group_id does not exists.',
|
||||
];
|
@ -51,13 +51,16 @@ return [
|
||||
'LocationService.addLocationImage.FileMaxSize' => 'file exceeds max_file_size (:max_file_size MB)',
|
||||
'LocationService.updateLocationImage.FileNotAllowedExtension' => 'file extension is not allowed (:allowed_extensions)',
|
||||
'LocationService.updateLocationImage.FileMaxSize' => 'file exceeds max_file_size (:max_file_size MB)',
|
||||
// RSVP Template Service
|
||||
// RSVPTemplateService
|
||||
'RSVPTemplateService.addQuestion.QuestionNameAlreadyExists' => 'question name :name already exists for template :template_id',
|
||||
'RSVPTemplateService.updateQuestion.QuestionNameAlreadyExists' => 'question name :name already exists for template :template_id',
|
||||
'RSVPTemplateService.addQuestionValue.ValueAlreadyExist' => 'value :value already exists on question :question_id',
|
||||
// SummitTicketTypeService
|
||||
'SummitTicketTypeService.addTicketType.NameAlreadyExists' => 'ticket name :name already exists on summit :summit_id',
|
||||
'SummitTicketTypeService.addTicketType.ExternalIdAlreadyExists' => 'ticket external id :external_id already exists on summit :summit_id',
|
||||
'SummitTicketTypeService.updateTicketType.NameAlreadyExists' => 'ticket name :name already exists on summit :summit_id',
|
||||
'SummitTicketTypeService.updateTicketType.ExternalIdAlreadyExists' => 'ticket external id :external_id already exists on summit :summit_id',
|
||||
'SummitTicketTypeService.seedSummitTicketTypesFromEventBrite.MissingExternalId' => 'summit :summit_is has not set external id (eventbrite)',
|
||||
// PresentationCategoryGroupService
|
||||
'PresentationCategoryGroupService.addTrackGroup.NameAlreadyExists' => 'name :name already exists for summit :summit_id',
|
||||
];
|
@ -72,4 +72,106 @@ final class OAuth2TrackGroupsApiTest extends ProtectedApiTest
|
||||
$this->assertTrue(!is_null($track_groups));
|
||||
$this->assertResponseStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $summit_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function testAddTrackGroup($summit_id = 24){
|
||||
$params = [
|
||||
'id' => $summit_id,
|
||||
];
|
||||
|
||||
$name = str_random(16).'_track_group';
|
||||
$data = [
|
||||
'name' => $name,
|
||||
'description' => 'test desc track group',
|
||||
'class_name' => \models\summit\PrivatePresentationCategoryGroup::ClassName
|
||||
];
|
||||
|
||||
$headers = [
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
];
|
||||
|
||||
$response = $this->action(
|
||||
"POST",
|
||||
"OAuth2PresentationCategoryGroupController@addTrackGroupBySummit",
|
||||
$params,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
$headers,
|
||||
json_encode($data)
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(201);
|
||||
$track_group = json_decode($content);
|
||||
$this->assertTrue(!is_null($track_group));
|
||||
return $track_group;
|
||||
}
|
||||
|
||||
public function testAssociateTrack2TrackGroup412($summit_id = 24){
|
||||
|
||||
$track_group = $this->testAddTrackGroup($summit_id);
|
||||
|
||||
$params = [
|
||||
'id' => $summit_id,
|
||||
'track_group_id' => $track_group->id,
|
||||
'track_id' => 1
|
||||
];
|
||||
|
||||
|
||||
$headers = [
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
];
|
||||
|
||||
$response = $this->action(
|
||||
"PUT",
|
||||
"OAuth2PresentationCategoryGroupController@associateTrack2TrackGroup",
|
||||
$params,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
$headers
|
||||
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(412);
|
||||
|
||||
}
|
||||
|
||||
public function testAssociateTrack2TrackGroup($summit_id = 24){
|
||||
|
||||
$track_group = $this->testAddTrackGroup($summit_id);
|
||||
|
||||
$params = [
|
||||
'id' => $summit_id,
|
||||
'track_group_id' => $track_group->id,
|
||||
'track_id' => 211
|
||||
];
|
||||
|
||||
$headers = [
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
];
|
||||
|
||||
$response = $this->action(
|
||||
"PUT",
|
||||
"OAuth2PresentationCategoryGroupController@associateTrack2TrackGroup",
|
||||
$params,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
$headers
|
||||
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(201);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user