Added add new track by summit endpoint
POST /api/v1/summits/{id}/tracks Payload * title (required|string|max:50) * description (required|string|max:500) * code (sometimes|string|max:5) * session_count (sometimes|integer) * alternate_count (sometimes|integer) * lightning_count (sometimes|integer) * lightning_alternate_count (sometimes|integer) * voting_visible (sometimes|boolean) * chair_visible (sometimes|boolean) Change-Id: I2ddbe0bfa54e67a8662d418596714cb97c8a3523
This commit is contained in:
parent
f3938b1d96
commit
e602510d37
@ -283,4 +283,58 @@ final class OAuth2SummitTracksApiController extends OAuth2ProtectedController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function addTrackBySummit($summit_id){
|
||||
try {
|
||||
if(!Request::isJson()) return $this->error403();
|
||||
$data = Input::json();
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
$rules = [
|
||||
'title' => 'required|string|max:50',
|
||||
'description' => 'required|string|max:500',
|
||||
'code' => 'sometimes|string|max:5',
|
||||
'session_count' => 'sometimes|integer',
|
||||
'alternate_count' => 'sometimes|integer',
|
||||
'lightning_count' => 'sometimes|integer',
|
||||
'lightning_alternate_count' => 'sometimes|integer',
|
||||
'voting_visible' => 'sometimes|boolean',
|
||||
'chair_visible' => 'sometimes|boolean',
|
||||
];
|
||||
|
||||
// Creates a Validator instance and validates the data.
|
||||
$validation = Validator::make($data->all(), $rules);
|
||||
|
||||
if ($validation->fails()) {
|
||||
$messages = $validation->messages()->toArray();
|
||||
|
||||
return $this->error412
|
||||
(
|
||||
$messages
|
||||
);
|
||||
}
|
||||
|
||||
$track = $this->track_service->addTrack($summit, $data->all());
|
||||
|
||||
return $this->created(SerializerRegistry::getInstance()->getSerializer($track)->serialize());
|
||||
}
|
||||
catch (ValidationException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error412(array($ex1->getMessage()));
|
||||
}
|
||||
catch(EntityNotFoundException $ex2)
|
||||
{
|
||||
Log::warning($ex2);
|
||||
return $this->error404(array('message'=> $ex2->getMessage()));
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
}
|
@ -343,16 +343,17 @@ Route::group([
|
||||
});
|
||||
|
||||
// tracks
|
||||
Route::group(array('prefix' => 'tracks'), function () {
|
||||
Route::group(['prefix' => 'tracks'], function () {
|
||||
Route::get('', 'OAuth2SummitTracksApiController@getAllBySummit');
|
||||
Route::get('csv', 'OAuth2SummitTracksApiController@getAllBySummitCSV');
|
||||
Route::post('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2SummitTracksApiController@addTrackBySummit']);
|
||||
Route::group(['prefix' => '{track_id}'], function () {
|
||||
Route::get('', 'OAuth2SummitTracksApiController@getTrackBySummit');
|
||||
});
|
||||
});
|
||||
|
||||
// track groups
|
||||
Route::group(array('prefix' => 'track-groups'), function () {
|
||||
Route::group(['prefix' => 'track-groups'], function () {
|
||||
Route::get('', 'OAuth2SummitTracksApiController@getTracksGroups');
|
||||
Route::get('{track_group_id}', 'OAuth2SummitApiController@getTrackGroup');
|
||||
});
|
||||
|
@ -36,6 +36,7 @@ use App\ModelSerializers\Marketplace\SpokenLanguageSerializer;
|
||||
use App\ModelSerializers\Marketplace\SupportChannelTypeSerializer;
|
||||
use App\ModelSerializers\Software\OpenStackComponentSerializer;
|
||||
use App\ModelSerializers\Software\OpenStackReleaseSerializer;
|
||||
use App\ModelSerializers\Summit\Presentation\PresentationCategoryAllowedTagSerializer;
|
||||
use Libs\ModelSerializers\IModelSerializer;
|
||||
use models\summit\SummitRegistrationPromoCode;
|
||||
use ModelSerializers\ChatTeams\ChatTeamInvitationSerializer;
|
||||
@ -89,6 +90,7 @@ final class SerializerRegistry
|
||||
$this->registry['PresentationType'] = PresentationTypeSerializer::class;
|
||||
$this->registry['SummitTicketType'] = SummitTicketTypeSerializer::class;
|
||||
$this->registry['PresentationCategory'] = PresentationCategorySerializer::class;
|
||||
$this->registry['PresentationCategoryAllowedTag'] = PresentationCategoryAllowedTagSerializer::class;
|
||||
$this->registry['PresentationCategoryGroup'] = PresentationCategoryGroupSerializer::class;
|
||||
$this->registry['PrivatePresentationCategoryGroup'] = PrivatePresentationCategoryGroupSerializer::class;
|
||||
$this->registry['Tag'] = TagSerializer::class;
|
||||
|
@ -0,0 +1,42 @@
|
||||
<?php namespace App\ModelSerializers\Summit\Presentation;
|
||||
/**
|
||||
* 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\PresentationCategoryAllowedTag;
|
||||
use ModelSerializers\SilverStripeSerializer;
|
||||
/**
|
||||
* Class PresentationCategoryAllowedTagSerializer
|
||||
* @package App\ModelSerializers\Summit\Presentation
|
||||
*/
|
||||
final class PresentationCategoryAllowedTagSerializer extends SilverStripeSerializer
|
||||
{
|
||||
protected static $array_mappings = [
|
||||
'Default' => 'is_default:json_boolean',
|
||||
];
|
||||
|
||||
/**
|
||||
* @param null $expand
|
||||
* @param array $fields
|
||||
* @param array $relations
|
||||
* @param array $params
|
||||
* @return array
|
||||
*/
|
||||
public function serialize($expand = null, array $fields = [], array $relations = [], array $params = [] )
|
||||
{
|
||||
$values = parent::serialize($expand, $fields, $relations, $params);
|
||||
$allowed_tag = $this->object;
|
||||
if(!$allowed_tag instanceof PresentationCategoryAllowedTag) return [];
|
||||
$values['tag'] = $allowed_tag->getTag()->getTag();
|
||||
$values['id'] = $allowed_tag->getTag()->getId();
|
||||
return $values;
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use models\summit\PresentationCategory;
|
||||
/**
|
||||
* Class PresentationCategorySerializer
|
||||
* @package ModelSerializers
|
||||
@ -23,6 +23,7 @@ final class PresentationCategorySerializer extends SilverStripeSerializer
|
||||
'Title' => 'name:json_string',
|
||||
'Description' => 'description:json_string',
|
||||
'Code' => 'code:json_string',
|
||||
'Slug' => 'slug:json_string',
|
||||
'SessionCount' => 'session_count:json_int',
|
||||
'AlternateCount' => 'alternate_count:json_int',
|
||||
'LightningCount' => 'lightning_count:json_int',
|
||||
@ -42,14 +43,23 @@ final class PresentationCategorySerializer extends SilverStripeSerializer
|
||||
public function serialize($expand = null, array $fields = [], array $relations = [], array $params = [] )
|
||||
{
|
||||
$category = $this->object;
|
||||
if(!$category instanceof PresentationCategory) return [];
|
||||
$values = parent::serialize($expand, $fields, $relations, $params);
|
||||
$groups = [];
|
||||
$allowed_tag = [];
|
||||
|
||||
foreach($category->getGroups() as $group){
|
||||
$groups[] = intval($group->getId());
|
||||
}
|
||||
$values['track_groups'] = $groups;
|
||||
|
||||
foreach($category->getAllowedTags() as $allowed_tag){
|
||||
$allowed_tag[] = intval($allowed_tag->getTag()->getId());
|
||||
}
|
||||
|
||||
$values['track_groups'] = $groups;
|
||||
$values['allowed_tag'] = $allowed_tag;
|
||||
|
||||
if (!empty($expand)) {
|
||||
$exp_expand = explode(',', $expand);
|
||||
foreach ($exp_expand as $relation) {
|
||||
@ -64,6 +74,17 @@ final class PresentationCategorySerializer extends SilverStripeSerializer
|
||||
}
|
||||
break;
|
||||
}
|
||||
switch (trim($relation)) {
|
||||
case 'allowed_tags': {
|
||||
$allowed_tag = [];
|
||||
unset($values['allowed_tags']);
|
||||
foreach ($category->getAllowedTags() as $allowed_tag) {
|
||||
$allowed_tag[] = SerializerRegistry::getInstance()->getSerializer($allowed_tag)->serialize(null, [], ['none']);
|
||||
}
|
||||
$values['allowed_tags'] = $allowed_tag;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
final class PresentationTypeSerializer extends SummitEventTypeSerializer
|
||||
{
|
||||
protected static $array_mappings = [
|
||||
|
||||
'MaxSpeakers' => 'max_speakers:json_int',
|
||||
'MinSpeakers' => 'min_speakers:json_int',
|
||||
'MaxModerators' => 'max_moderators:json_int',
|
||||
@ -29,7 +28,7 @@ final class PresentationTypeSerializer extends SummitEventTypeSerializer
|
||||
'UseModerator' => 'use_moderator:json_boolean',
|
||||
'ModeratorMandatory' => 'is_moderator_mandatory:json_boolean',
|
||||
'ModeratorLabel' => 'moderator_label:json_string',
|
||||
'isShouldBeAvailableOnCfp' => 'should_be_available_on_cfp:json_boolean',
|
||||
'ShouldBeAvailableOnCfp' => 'should_be_available_on_cfp:json_boolean',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,7 @@ class SummitEventTypeSerializer extends SilverStripeSerializer
|
||||
'UseSponsors' => 'use_sponsors:json_boolean',
|
||||
'AreSponsorsMandatory' => 'are_sponsors_mandatory:json_boolean',
|
||||
'AllowsAttachment' => 'allows_attachment:json_boolean',
|
||||
'IsDefault' => 'is_default:json_boolean',
|
||||
'Default' => 'is_default:json_boolean',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -11,8 +11,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use models\utils\SilverstripeBaseModel;
|
||||
use App\Models\Foundation\Summit\Events\Presentations\PresentationCategoryAllowedTag;
|
||||
use Doctrine\ORM\Event\PreUpdateEventArgs;
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
use models\utils\SilverstripeBaseModel;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
/**
|
||||
* Class PresentationCategory
|
||||
@ -43,6 +45,12 @@ class PresentationCategory extends SilverstripeBaseModel
|
||||
*/
|
||||
private $code;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Slug", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $slug;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="SessionCount", type="integer")
|
||||
* @var int
|
||||
@ -133,20 +141,49 @@ class PresentationCategory extends SilverstripeBaseModel
|
||||
*/
|
||||
private $groups;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="App\Models\Foundation\Summit\Events\Presentations\PresentationCategoryAllowedTag", mappedBy="track", cascade={"persist"}, orphanRemoval=true)
|
||||
* @var PresentationCategoryAllowedTag[]
|
||||
*/
|
||||
protected $allowed_tags;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->groups = new ArrayCollection();
|
||||
$this->allowed_tags = new ArrayCollection();
|
||||
$this->session_count = 0;
|
||||
$this->alternate_count = 0;
|
||||
$this->lightning_alternate_count = 0;
|
||||
$this->lightning_count = 0;
|
||||
$this->chair_visible = false;
|
||||
$this->voting_visible = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSlug()
|
||||
{
|
||||
return $this->slug;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PresentationCategoryGroup[]
|
||||
*/
|
||||
public function getGroups()
|
||||
{
|
||||
public function getGroups(){
|
||||
return $this->groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PresentationCategoryAllowedTag[]
|
||||
*/
|
||||
public function getAllowedTags(){
|
||||
return $this->allowed_tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
@ -243,4 +280,13 @@ class PresentationCategory extends SilverstripeBaseModel
|
||||
$this->chair_visible = $chair_visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function calculateSlug(){
|
||||
if(empty($this->title)) return $this;
|
||||
$clean_title = preg_replace ("/[^a-zA-Z0-9 ]/", "", $this->title);
|
||||
$this->slug = preg_replace('/\s+/', '-', strtolower($clean_title));
|
||||
return $this;
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
<?php namespace App\Models\Foundation\Summit\Events\Presentations;
|
||||
/**
|
||||
* 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\main\Tag;
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
use models\summit\PresentationCategory;
|
||||
use models\utils\SilverstripeBaseModel;
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
* @ORM\Table(name="PresentationCategory_AllowedTags")
|
||||
* Class PresentationCategoryAllowedTag
|
||||
* @package App\Models\Foundation\Summit\Events\Presentations
|
||||
*/
|
||||
class PresentationCategoryAllowedTag extends SilverstripeBaseModel
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\main\Tag")
|
||||
* @ORM\JoinColumn(name="TagID", referencedColumnName="ID")
|
||||
* @var Tag
|
||||
*/
|
||||
private $tag;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\summit\PresentationCategory", inversedBy="allowed_tags")
|
||||
* @ORM\JoinColumn(name="PresentationCategoryID", referencedColumnName="ID")
|
||||
* @var PresentationCategory
|
||||
*/
|
||||
private $track;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="IsDefault", type="boolean")
|
||||
* @var boolean
|
||||
*/
|
||||
private $is_default;
|
||||
|
||||
/**
|
||||
* @return Tag
|
||||
*/
|
||||
public function getTag()
|
||||
{
|
||||
return $this->tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Tag $tag
|
||||
*/
|
||||
public function setTag($tag)
|
||||
{
|
||||
$this->tag = $tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PresentationCategory
|
||||
*/
|
||||
public function getTrack()
|
||||
{
|
||||
return $this->track;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PresentationCategory $track
|
||||
*/
|
||||
public function setTrack($track)
|
||||
{
|
||||
$this->track = $track;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isDefault()
|
||||
{
|
||||
return $this->is_default;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $is_default
|
||||
*/
|
||||
public function setIsDefault($is_default)
|
||||
{
|
||||
$this->is_default = $is_default;
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
<?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\summit\PresentationCategory;
|
||||
use models\summit\Summit;
|
||||
/**
|
||||
* Class PresentationCategoryFactory
|
||||
* @package App\Models\Foundation\Summit\Factories
|
||||
*/
|
||||
final class PresentationCategoryFactory
|
||||
{
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param array $data
|
||||
* @return PresentationCategory
|
||||
*/
|
||||
public static function build(Summit $summit, array $data){
|
||||
$track = new PresentationCategory();
|
||||
self::populate($track, $data);
|
||||
$summit->addPresentationCategory($track);
|
||||
return $track;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PresentationCategory $track
|
||||
* @param array $data
|
||||
* @return PresentationCategory
|
||||
*/
|
||||
public static function populate(PresentationCategory $track, array $data){
|
||||
if(isset($data['title']))
|
||||
$track->setTitle(trim($data['title']));
|
||||
|
||||
if(isset($data['code']))
|
||||
$track->setCode(trim($data['code']));
|
||||
|
||||
if(isset($data['description']))
|
||||
$track->setDescription(trim($data['description']));
|
||||
|
||||
$track->calculateSlug();
|
||||
|
||||
if(isset($data['session_count']))
|
||||
$track->setSessionCount(intval($data['session_count']));
|
||||
|
||||
if(isset($data['alternate_count']))
|
||||
$track->setSessionCount(intval($data['alternate_count']));
|
||||
|
||||
if(isset($data['lightning_count']))
|
||||
$track->setSessionCount(intval($data['lightning_count']));
|
||||
|
||||
if(isset($data['lightning_alternate_count']))
|
||||
$track->setSessionCount(intval($data['lightning_alternate_count']));
|
||||
|
||||
if(isset($data['voting_visible']))
|
||||
$track->setVotingVisible(boolval($data['voting_visible']));
|
||||
|
||||
if(isset($data['chair_visible']))
|
||||
$track->setChairVisible(boolval($data['chair_visible']));
|
||||
|
||||
return $track;
|
||||
}
|
||||
|
||||
}
|
@ -836,6 +836,16 @@ class Summit extends SilverstripeBaseModel
|
||||
return $this->presentation_categories;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PresentationCategory $track
|
||||
* @return $this
|
||||
*/
|
||||
public function addPresentationCategory(PresentationCategory $track){
|
||||
$this->presentation_categories->add($track);
|
||||
$track->setSummit($this);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $category_id
|
||||
* @return PresentationCategory
|
||||
@ -847,6 +857,28 @@ class Summit extends SilverstripeBaseModel
|
||||
return $category === false ? null:$category;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $category_title
|
||||
* @return PresentationCategory
|
||||
*/
|
||||
public function getPresentationCategoryByTitle($category_title){
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('title', intval($category_title)));
|
||||
$category = $this->presentation_categories->matching($criteria)->first();
|
||||
return $category === false ? null:$category;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $category_code
|
||||
* @return PresentationCategory
|
||||
*/
|
||||
public function getPresentationCategoryByCode($category_code){
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('code', intval($category_code)));
|
||||
$category = $this->presentation_categories->matching($criteria)->first();
|
||||
return $category === false ? null:$category;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PresentationCategoryGroup[]
|
||||
*/
|
||||
|
@ -37,5 +37,7 @@ final class SummitScopes
|
||||
|
||||
const WriteEventTypeData = '%s/event-types/write';
|
||||
|
||||
const WriteTracksData = '%s/tracks/write';
|
||||
|
||||
const WriteSummitSpeakerAssistanceData = '%s/summit-speaker-assistance/write';
|
||||
}
|
@ -11,6 +11,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use App\Models\Foundation\Summit\Factories\PresentationCategoryFactory;
|
||||
use App\Models\Foundation\Summit\Repositories\ISummitTrackRepository;
|
||||
use libs\utils\ITransactionService;
|
||||
use models\exceptions\EntityNotFoundException;
|
||||
@ -53,7 +54,21 @@ final class SummitTrackService implements ISummitTrackService
|
||||
*/
|
||||
public function addTrack(Summit $summit, array $data)
|
||||
{
|
||||
// TODO: Implement addTrack() method.
|
||||
return $this->tx_service->transaction(function() use($summit, $data){
|
||||
|
||||
$former_track = $summit->getPresentationCategoryByCode($data['code']);
|
||||
if(!is_null($former_track))
|
||||
throw new ValidationException(sprintf("track id %s already has code %s assigned on summit id %s", $former_track->getId(), $data['code'], $summit->getId()));
|
||||
|
||||
$former_track = $summit->getPresentationCategoryByTitle($data['title']);
|
||||
if(!is_null($former_track))
|
||||
throw new ValidationException(sprintf("track id %s already has title %s assigned on summit id %s", $former_track->getId(), $data['title'], $summit->getId()));
|
||||
|
||||
$track = PresentationCategoryFactory::build($summit, $data);
|
||||
|
||||
return $track;
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -610,7 +610,6 @@ class ApiEndpointsSeeder extends Seeder
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
],
|
||||
|
||||
[
|
||||
'name' => 'get-tracks-csv',
|
||||
'route' => '/api/v1/summits/{id}/tracks/csv',
|
||||
@ -629,6 +628,15 @@ class ApiEndpointsSeeder extends Seeder
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'add-tracks',
|
||||
'route' => '/api/v1/summits/{id}/tracks',
|
||||
'http_method' => 'POST',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WriteTracksData, $current_realm),
|
||||
sprintf(SummitScopes::WriteSummitData, $current_realm)
|
||||
],
|
||||
],
|
||||
// track groups
|
||||
array(
|
||||
'name' => 'get-track-groups',
|
||||
@ -945,7 +953,7 @@ class ApiEndpointsSeeder extends Seeder
|
||||
|
||||
$this->seedApiEndpoints('tags', [
|
||||
// members
|
||||
array(
|
||||
[
|
||||
'name' => 'get-tags',
|
||||
'route' => '/api/v1/tags',
|
||||
'http_method' => 'GET',
|
||||
@ -954,7 +962,7 @@ class ApiEndpointsSeeder extends Seeder
|
||||
sprintf(SummitScopes::ReadSummitData, $current_realm),
|
||||
sprintf('%s/tags/read', $current_realm)
|
||||
],
|
||||
)
|
||||
]
|
||||
]
|
||||
);
|
||||
}
|
||||
@ -964,7 +972,7 @@ class ApiEndpointsSeeder extends Seeder
|
||||
|
||||
$this->seedApiEndpoints('companies', [
|
||||
// members
|
||||
array(
|
||||
[
|
||||
'name' => 'get-companies',
|
||||
'route' => '/api/v1/companies',
|
||||
'http_method' => 'GET',
|
||||
@ -973,7 +981,7 @@ class ApiEndpointsSeeder extends Seeder
|
||||
sprintf(SummitScopes::ReadSummitData, $current_realm),
|
||||
sprintf('%s/companies/read', $current_realm)
|
||||
],
|
||||
)
|
||||
]
|
||||
]
|
||||
);
|
||||
}
|
||||
@ -983,7 +991,7 @@ class ApiEndpointsSeeder extends Seeder
|
||||
|
||||
$this->seedApiEndpoints('groups', [
|
||||
// members
|
||||
array(
|
||||
[
|
||||
'name' => 'get-groups',
|
||||
'route' => '/api/v1/groups',
|
||||
'http_method' => 'GET',
|
||||
@ -992,7 +1000,7 @@ class ApiEndpointsSeeder extends Seeder
|
||||
sprintf(SummitScopes::ReadSummitData, $current_realm),
|
||||
sprintf('%s/groups/read', $current_realm)
|
||||
],
|
||||
)
|
||||
]
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -143,6 +143,36 @@ final class OAuth2EventTypesApiTest extends ProtectedApiTest
|
||||
return $event_types;
|
||||
}
|
||||
|
||||
public function testGetEventTypeAll(){
|
||||
$params = [
|
||||
'id' => 23,
|
||||
'page' => 1,
|
||||
'per_page' => 10,
|
||||
'order' => '+name'
|
||||
];
|
||||
|
||||
$headers = [
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
];
|
||||
|
||||
$response = $this->action(
|
||||
"GET",
|
||||
"OAuth2SummitsEventTypesApiController@getAllBySummit",
|
||||
$params,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(200);
|
||||
$event_types = json_decode($content);
|
||||
$this->assertTrue(!is_null($event_types));
|
||||
return $event_types;
|
||||
}
|
||||
|
||||
public function testGetEventTypesByClassNamePresentationType(){
|
||||
$params = [
|
||||
|
||||
|
@ -108,4 +108,39 @@ final class OAuth2TracksApiTest extends ProtectedApiTest
|
||||
$this->assertResponseStatus(200);
|
||||
$this->assertTrue(!empty($csv));
|
||||
}
|
||||
|
||||
public function testAddTrack($summit_id = 23){
|
||||
$params = [
|
||||
'id' => $summit_id,
|
||||
];
|
||||
|
||||
$name = str_random(16).'_track';
|
||||
$data = [
|
||||
'title' => $name,
|
||||
'description' => 'test desc',
|
||||
'code' => 'SM',
|
||||
];
|
||||
|
||||
$headers = [
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
];
|
||||
|
||||
$response = $this->action(
|
||||
"POST",
|
||||
"OAuth2SummitTracksApiController@addTrackBySummit",
|
||||
$params,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
$headers,
|
||||
json_encode($data)
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(201);
|
||||
$track = json_decode($content);
|
||||
$this->assertTrue(!is_null($track));
|
||||
return $track;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user