Added endpoint to add RSVP template question
POST /api/v1/summits/{id}/rsvp-templates/{template_id}/questions payload Base Payload * class_name (string:in:RSVPMemberEmailQuestionTemplate, RSVPMemberFirstNameQuestionTemplate, RSVPMemberLastNameQuestionTemplate, RSVPTextBoxQuestionTemplate, RSVPTextAreaQuestionTemplate, RSVPCheckBoxListQuestionTemplate, RSVPRadioButtonListQuestionTemplate, RSVPDropDownQuestionTemplate, RSVPLiteralContentQuestionTemplate ) * name (required|alpha_dash|max:255) * label (required|string) * is_mandatory (sometimes|boolean) * is_read_only (sometimes|boolean) RSVPTextBoxQuestionTemplate, RSVPTextAreaQuestionTemplate * initial_value (string|sometimes) RSVPCheckBoxListQuestionTemplate,RSVPRadioButtonListQuestionTemplate * empty_string (required|string) RSVPDropDownQuestionTemplate * is_multiselect (sometimes|boolean) * is_country_selector (sometimes|boolean) * use_chosen_plugin (sometimes|boolean) RSVPLiteralContentQuestionTemplate * content (required|string) Change-Id: I16ee3aaa7d556d3e0a8d41ceca2514568098b981
This commit is contained in:
parent
c3634de784
commit
888bed528b
@ -51,6 +51,7 @@ class Kernel extends ConsoleKernel
|
||||
7, //BCN
|
||||
22, //Boston
|
||||
23, //Sydney
|
||||
24, //Vancouver BC
|
||||
];
|
||||
|
||||
foreach ($summit_ids as $summit_id)
|
||||
|
@ -53,10 +53,10 @@ final class SummitLocationValidationRulesFactory
|
||||
}
|
||||
break;
|
||||
case SummitExternalLocation::ClassName: {
|
||||
return array_merge(SummitExternalLocationValidationRulesFactory::build($data, $update));
|
||||
return array_merge($base_rules, SummitExternalLocationValidationRulesFactory::build($data, $update));
|
||||
}
|
||||
case SummitVenueRoom::ClassName: {
|
||||
return array_merge(SummitVenueRoomValidationRulesFactory::build($data, $update));
|
||||
return array_merge($base_rules, SummitVenueRoomValidationRulesFactory::build($data, $update));
|
||||
}
|
||||
break;
|
||||
default:{
|
||||
|
@ -0,0 +1,32 @@
|
||||
<?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.
|
||||
**/
|
||||
|
||||
/**
|
||||
* Class SummitRSVPLiteralContentQuestionTemplateValidationRulesFactory
|
||||
* @package App\Http\Controllers
|
||||
*/
|
||||
final class SummitRSVPLiteralContentQuestionTemplateValidationRulesFactory
|
||||
{
|
||||
/**
|
||||
* @param array $data
|
||||
* @param bool $update
|
||||
* @return array
|
||||
*/
|
||||
public static function build(array $data, $update = false){
|
||||
if($update){
|
||||
return ['content' => 'sometimes|string'];
|
||||
}
|
||||
return ['content' => 'required|string'];
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?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.
|
||||
**/
|
||||
|
||||
/**
|
||||
* Class SummitRSVPMultiValueQuestionTemplateValidationRulesFactory
|
||||
* @package App\Http\Controllers
|
||||
*/
|
||||
final class SummitRSVPMultiValueQuestionTemplateValidationRulesFactory
|
||||
{
|
||||
/**
|
||||
* @param array $data
|
||||
* @param bool $update
|
||||
* @return array
|
||||
*/
|
||||
public static function build(array $data, $update = false){
|
||||
if($update){
|
||||
return ['empty_string' => 'sometimes|string'];
|
||||
}
|
||||
return ['empty_string' => 'required|string'];
|
||||
}
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
<?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\RSVP\RSVPCheckBoxListQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPLiteralContentQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPMemberEmailQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPMemberFirstNameQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPMemberLastNameQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPRadioButtonListQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPTextAreaQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPTextBoxQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPDropDownQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\Templates\SummitRSVPTemplateQuestionConstants;
|
||||
use models\exceptions\ValidationException;
|
||||
/**
|
||||
* Class SummitRSVPTemplateQuestionValidationRulesFactory
|
||||
* @package App\Http\Controllers
|
||||
*/
|
||||
final class SummitRSVPTemplateQuestionValidationRulesFactory
|
||||
{
|
||||
/**
|
||||
* @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 is required');
|
||||
|
||||
$base_rules = [
|
||||
'class_name' => sprintf('required|in:%s', implode(",", SummitRSVPTemplateQuestionConstants::$valid_class_names))
|
||||
];
|
||||
|
||||
if($update){
|
||||
$base_rules = array_merge($base_rules, [
|
||||
'name' => 'sometimes|alpha_dash|max:255',
|
||||
'label' => 'sometimes|string',
|
||||
'is_mandatory' => 'sometimes|boolean',
|
||||
'order' => 'sometimes|int|min:1',
|
||||
'is_read_only;' => 'sometimes|boolean',
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$base_rules = array_merge($base_rules, [
|
||||
'name' => 'required|alpha_dash|max:255',
|
||||
'label' => 'required|string',
|
||||
'is_mandatory' => 'sometimes|boolean',
|
||||
'is_read_only;' => 'sometimes|boolean',
|
||||
]);
|
||||
}
|
||||
|
||||
switch($data['class_name']){
|
||||
case RSVPMemberEmailQuestionTemplate::ClassName: {
|
||||
return $base_rules;
|
||||
}
|
||||
break;
|
||||
case RSVPMemberFirstNameQuestionTemplate::ClassName: {
|
||||
return $base_rules;
|
||||
}
|
||||
break;
|
||||
case RSVPMemberLastNameQuestionTemplate::ClassName: {
|
||||
return $base_rules;
|
||||
}
|
||||
break;
|
||||
case RSVPTextBoxQuestionTemplate::ClassName: {
|
||||
return array_merge($base_rules, ['initial_value' => 'string|sometimes']);
|
||||
}
|
||||
break;
|
||||
case RSVPTextAreaQuestionTemplate::ClassName: {
|
||||
return array_merge($base_rules, ['initial_value' => 'string|sometimes']);
|
||||
}
|
||||
break;
|
||||
case RSVPCheckBoxListQuestionTemplate::ClassName: {
|
||||
return array_merge($base_rules, SummitRSVPMultiValueQuestionTemplateValidationRulesFactory::build($data, $update));
|
||||
}
|
||||
break;
|
||||
case RSVPRadioButtonListQuestionTemplate::ClassName: {
|
||||
return array_merge($base_rules, SummitRSVPMultiValueQuestionTemplateValidationRulesFactory::build($data, $update));
|
||||
}
|
||||
break;
|
||||
case RSVPDropDownQuestionTemplate::ClassName: {
|
||||
return array_merge
|
||||
(
|
||||
$base_rules,
|
||||
SummitRSVPMultiValueQuestionTemplateValidationRulesFactory::build($data, $update),
|
||||
[
|
||||
'is_multiselect' => 'sometimes|boolean',
|
||||
'is_country_selector' => 'sometimes|boolean',
|
||||
'use_chosen_plugin' => 'sometimes|boolean',
|
||||
]
|
||||
);
|
||||
}
|
||||
break;
|
||||
case RSVPLiteralContentQuestionTemplate::ClassName: {
|
||||
return array_merge($base_rules, SummitRSVPLiteralContentQuestionTemplateValidationRulesFactory::build($data, $update));
|
||||
}
|
||||
break;
|
||||
default:{
|
||||
throw new ValidationException(sprintf('invalid class_name param (%s)', implode(",", SummitRSVPTemplateQuestionConstants::$valid_class_names)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
@ -11,13 +11,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use App\Http\Utils\FilterAvailableSummitsStrategy;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use models\exceptions\EntityNotFoundException;
|
||||
use models\exceptions\ValidationException;
|
||||
use models\oauth2\IResourceServerContext;
|
||||
@ -29,7 +26,6 @@ use models\summit\ISummitRepository;
|
||||
use ModelSerializers\SerializerRegistry;
|
||||
use services\model\ISummitService;
|
||||
use utils\PagingResponse;
|
||||
|
||||
/**
|
||||
* Class OAuth2SummitApiController
|
||||
* @package App\Http\Controllers
|
||||
@ -88,7 +84,7 @@ final class OAuth2SummitApiController extends OAuth2ProtectedController
|
||||
|
||||
$summits = [];
|
||||
|
||||
foreach($this->_getSummits() as $summit){
|
||||
foreach($this->repository->getAvailables() as $summit){
|
||||
$summits[] = SerializerRegistry::getInstance()->getSerializer($summit)->serialize($expand, $fields, $relations);
|
||||
}
|
||||
|
||||
@ -110,11 +106,39 @@ final class OAuth2SummitApiController extends OAuth2ProtectedController
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \models\summit\Summit[]
|
||||
* @return mixed
|
||||
*/
|
||||
private function _getSummits(){
|
||||
return FilterAvailableSummitsStrategy::shouldReturnAllSummits($this->resource_server_context) ?
|
||||
$this->repository->getAllOrderedByBeginDate():$this->repository->getAvailables();
|
||||
public function getAllSummits(){
|
||||
try {
|
||||
|
||||
$expand = Request::input('expand', '');
|
||||
$fields = Request::input('fields', '');
|
||||
$relations = Request::input('relations', '');
|
||||
|
||||
$relations = !empty($relations) ? explode(',', $relations) : [];
|
||||
$fields = !empty($fields) ? explode(',', $fields) : [];
|
||||
|
||||
$summits = [];
|
||||
|
||||
foreach($this->repository->getAllOrderedByBeginDate()as $summit){
|
||||
$summits[] = SerializerRegistry::getInstance()->getSerializer($summit)->serialize($expand, $fields, $relations);
|
||||
}
|
||||
|
||||
$response = new PagingResponse
|
||||
(
|
||||
count($summits),
|
||||
count($summits),
|
||||
1,
|
||||
1,
|
||||
$summits
|
||||
);
|
||||
|
||||
return $this->ok($response->toArray());
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -232,4 +232,54 @@ final class OAuth2SummitRSVPTemplatesApiController extends OAuth2ProtectedContro
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Questions endpoints
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @param $template_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function addRSVPTemplateQuestion($summit_id, $template_id){
|
||||
try {
|
||||
|
||||
if(!Request::isJson()) return $this->error400();
|
||||
$payload = Input::json()->all();
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
$rules = SummitRSVPTemplateQuestionValidationRulesFactory::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
|
||||
);
|
||||
}
|
||||
|
||||
$question = $this->rsvp_template_service->addQuestion($summit, $template_id, $payload);
|
||||
|
||||
return $this->created(SerializerRegistry::getInstance()->getSerializer($question)->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);
|
||||
}
|
||||
}
|
||||
}
|
@ -161,15 +161,18 @@ Route::group([
|
||||
Route::group(array('prefix' => 'summits'), function () {
|
||||
|
||||
Route::get('', [ 'middleware' => 'cache:'.Config::get('cache_api_response.get_summits_response_lifetime', 600), 'uses' => 'OAuth2SummitApiController@getSummits']);
|
||||
|
||||
Route::group(array('prefix' => '{id}'), function () {
|
||||
Route::get('all', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2SummitApiController@getAllSummits']);
|
||||
Route::group(['prefix' => '{id}'], function () {
|
||||
|
||||
// rsvp templates
|
||||
Route::group(array('prefix' => 'rsvp-templates'), function () {
|
||||
Route::group(['prefix' => 'rsvp-templates'], function () {
|
||||
Route::get('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2SummitRSVPTemplatesApiController@getAllBySummit']);
|
||||
Route::group(array('prefix' => '{template_id}'), function () {
|
||||
Route::group(['prefix' => '{template_id}'], function () {
|
||||
Route::get('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2SummitRSVPTemplatesApiController@getRSVPTemplate']);
|
||||
Route::delete('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2SummitRSVPTemplatesApiController@deleteRSVPTemplate']);
|
||||
Route::group(['prefix' => 'questions'], function () {
|
||||
Route::post('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2SummitRSVPTemplatesApiController@addRSVPTemplateQuestion']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -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\RSVP\Templates\RSVPDropDownQuestionTemplateSerializer;
|
||||
use App\ModelSerializers\Summit\RSVP\Templates\RSVPMultiValueQuestionTemplateSerializer;
|
||||
use App\ModelSerializers\Summit\RSVP\Templates\RSVPQuestionValueTemplateSerializer;
|
||||
use App\ModelSerializers\Summit\RSVP\Templates\RSVPSingleValueTemplateQuestionSerializer;
|
||||
@ -126,6 +127,7 @@ final class SerializerRegistry
|
||||
|
||||
$this->registry['RSVPCheckBoxListQuestionTemplate'] = RSVPMultiValueQuestionTemplateSerializer::class;
|
||||
$this->registry['RSVPRadioButtonListQuestionTemplate'] = RSVPMultiValueQuestionTemplateSerializer::class;
|
||||
$this->registry['RSVPDropDownQuestionTemplate'] = RSVPDropDownQuestionTemplateSerializer::class;
|
||||
|
||||
$this->registry['SpeakerExpertise'] = SpeakerExpertiseSerializer::class;
|
||||
$this->registry['SpeakerLanguage'] = SpeakerLanguageSerializer::class;
|
||||
|
@ -0,0 +1,62 @@
|
||||
<?php namespace App\ModelSerializers\Summit\RSVP\Templates;
|
||||
/**
|
||||
* 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\Main\CountryCodes;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPDropDownQuestionTemplate;
|
||||
/**
|
||||
* Class RSVPDropDownQuestionTemplateSerializer
|
||||
* @package App\ModelSerializers\Summit\RSVP\Templates
|
||||
*/
|
||||
final class RSVPDropDownQuestionTemplateSerializer extends RSVPMultiValueQuestionTemplateSerializer
|
||||
{
|
||||
protected static $array_mappings = [
|
||||
'CountrySelector' => 'is_country_selector:json_boolean',
|
||||
'UseChosenPlugin' => 'use_chosen_plugin:json_boolean',
|
||||
'Multiselect' => 'is_multiselect: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 = [])
|
||||
{
|
||||
$question = $this->object;
|
||||
if(! $question instanceof RSVPDropDownQuestionTemplate) return [];
|
||||
$values = parent::serialize($expand, $fields, $relations, $params);
|
||||
|
||||
if($question->isCountrySelector()) {
|
||||
$question_values = [];
|
||||
$extra_options = [
|
||||
|
||||
'Worldwide' => 'Worldwide',
|
||||
'Prefer not to say' => 'Prefer not to say',
|
||||
'Too many to list' => 'Too many to list',
|
||||
];
|
||||
|
||||
$options = array_merge($extra_options, CountryCodes::$iso_3166_countryCodes);
|
||||
foreach($options as $k => $v)
|
||||
{
|
||||
$question_values[] = [
|
||||
'id' => $k,
|
||||
'value' => $v
|
||||
];
|
||||
}
|
||||
$values['values'] = $question_values;
|
||||
}
|
||||
return $values;
|
||||
}
|
||||
}
|
274
app/Models/Foundation/Main/CountryCodes.php
Normal file
274
app/Models/Foundation/Main/CountryCodes.php
Normal file
@ -0,0 +1,274 @@
|
||||
<?php namespace App\Models\Foundation\Main;
|
||||
/**
|
||||
* 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 CountryCodes
|
||||
* @package App\Models\Foundation\Main
|
||||
*/
|
||||
final class CountryCodes
|
||||
{
|
||||
|
||||
public static $iso_3166_countryCodes = [
|
||||
'AF' => "Afghanistan",
|
||||
'AX' => "Aland Islands",
|
||||
'AL' => "Albania",
|
||||
'DZ' => "Algeria",
|
||||
'AS' => "American Samoa",
|
||||
'AD' => "Andorra",
|
||||
'AO' => "Angola",
|
||||
'AI' => "Anguilla",
|
||||
'AQ' => "Antarctica",
|
||||
'AG' => "Antigua and Barbuda",
|
||||
'AR' => "Argentina",
|
||||
'AM' => "Armenia",
|
||||
'AW' => "Aruba",
|
||||
'AU' => "Australia",
|
||||
'AT' => "Austria",
|
||||
'AZ' => "Azerbaijan",
|
||||
'BS' => "Bahamas",
|
||||
'BH' => "Bahrain",
|
||||
'BD' => "Bangladesh",
|
||||
'BB' => "Barbados",
|
||||
'BY' => "Belarus",
|
||||
'BE' => "Belgium",
|
||||
'BZ' => "Belize",
|
||||
'BJ' => "Benin",
|
||||
'BM' => "Bermuda",
|
||||
'BT' => "Bhutan",
|
||||
'BO' => "Bolivia, Plurinational State of",
|
||||
'BQ' => "Bonaire, Sint Eustatius and Saba",
|
||||
'BA' => "Bosnia and Herzegovina",
|
||||
'BW' => "Botswana",
|
||||
'BV' => "Bouvet Island",
|
||||
'BR' => "Brazil",
|
||||
'IO' => "British Indian Ocean Territory",
|
||||
'BN' => "Brunei Darussalam",
|
||||
'BG' => "Bulgaria",
|
||||
'BF' => "Burkina Faso",
|
||||
'BI' => "Burundi",
|
||||
'KH' => "Cambodia",
|
||||
'CM' => "Cameroon",
|
||||
'CA' => "Canada",
|
||||
'CV' => "Cape Verde",
|
||||
'KY' => "Cayman Islands",
|
||||
'CF' => "Central African Republic",
|
||||
'TD' => "Chad",
|
||||
'CL' => "Chile",
|
||||
'CN' => "China",
|
||||
'CX' => "Christmas Island",
|
||||
'CC' => "Cocos (Keeling) Islands",
|
||||
'CO' => "Colombia",
|
||||
'KM' => "Comoros",
|
||||
'CG' => "Congo",
|
||||
'CD' => "Congo, the Democratic Republic of the",
|
||||
'CK' => "Cook Islands",
|
||||
'CR' => "Costa Rica",
|
||||
'CI' => "Côte d'Ivoire",
|
||||
'HR' => "Croatia",
|
||||
'CU' => "Cuba",
|
||||
'CW' => "Curaçao",
|
||||
'CY' => "Cyprus",
|
||||
'CZ' => "Czech Republic",
|
||||
'DK' => "Denmark",
|
||||
'DJ' => "Djibouti",
|
||||
'DM' => "Dominica",
|
||||
'DO' => "Dominican Republic",
|
||||
'EC' => "Ecuador",
|
||||
'EG' => "Egypt",
|
||||
'SV' => "El Salvador",
|
||||
'GQ' => "Equatorial Guinea",
|
||||
'ER' => "Eritrea",
|
||||
'EE' => "Estonia",
|
||||
'ET' => "Ethiopia",
|
||||
'FK' => "Falkland Islands (Malvinas)",
|
||||
'FO' => "Faroe Islands",
|
||||
'FJ' => "Fiji",
|
||||
'FI' => "Finland",
|
||||
'FR' => "France",
|
||||
'FX' => "France, Metropolitan",
|
||||
'GF' => "French Guiana",
|
||||
'PF' => "French Polynesia",
|
||||
'TF' => "French Southern Territories",
|
||||
'GA' => "Gabon",
|
||||
'GM' => "Gambia",
|
||||
'GE' => "Georgia",
|
||||
'DE' => "Germany",
|
||||
'GH' => "Ghana",
|
||||
'GI' => "Gibraltar",
|
||||
'GR' => "Greece",
|
||||
'GL' => "Greenland",
|
||||
'GD' => "Grenada",
|
||||
'GP' => "Guadeloupe",
|
||||
'GU' => "Guam",
|
||||
'GT' => "Guatemala",
|
||||
'GG' => "Guernsey",
|
||||
'GN' => "Guinea",
|
||||
'GW' => "Guinea-Bissau",
|
||||
'GY' => "Guyana",
|
||||
'HT' => "Haiti",
|
||||
'HM' => "Heard Island and McDonald Islands",
|
||||
'VA' => "Holy See (Vatican City State)",
|
||||
'HN' => "Honduras",
|
||||
'HK' => "Hong Kong",
|
||||
'HU' => "Hungary",
|
||||
'IS' => "Iceland",
|
||||
'IN' => "India",
|
||||
'ID' => "Indonesia",
|
||||
'IR' => "Iran, Islamic Republic of",
|
||||
'IQ' => "Iraq",
|
||||
'IE' => "Ireland",
|
||||
'IM' => "Isle of Man",
|
||||
'IL' => "Israel",
|
||||
'IT' => "Italy",
|
||||
'JM' => "Jamaica",
|
||||
'JP' => "Japan",
|
||||
'JE' => "Jersey",
|
||||
'JO' => "Jordan",
|
||||
'KZ' => "Kazakhstan",
|
||||
'KE' => "Kenya",
|
||||
'KI' => "Kiribati",
|
||||
'KP' => "Korea, Democratic People's Republic of",
|
||||
'KR' => "Korea, Republic of",
|
||||
'KW' => "Kuwait",
|
||||
'KG' => "Kyrgyzstan",
|
||||
'LA' => "Lao People's Democratic Republic",
|
||||
'LV' => "Latvia",
|
||||
'LB' => "Lebanon",
|
||||
'LS' => "Lesotho",
|
||||
'LR' => "Liberia",
|
||||
'LY' => "Libya",
|
||||
'LI' => "Liechtenstein",
|
||||
'LT' => "Lithuania",
|
||||
'LU' => "Luxembourg",
|
||||
'MO' => "Macao",
|
||||
'MK' => "Macedonia, the former Yugoslav Republic of",
|
||||
'MG' => "Madagascar",
|
||||
'MW' => "Malawi",
|
||||
'MY' => "Malaysia",
|
||||
'MV' => "Maldives",
|
||||
'ML' => "Mali",
|
||||
'MT' => "Malta",
|
||||
'MH' => "Marshall Islands",
|
||||
'MQ' => "Martinique",
|
||||
'MR' => "Mauritania",
|
||||
'MU' => "Mauritius",
|
||||
'YT' => "Mayotte",
|
||||
'MX' => "Mexico",
|
||||
'FM' => "Micronesia, Federated States of",
|
||||
'MD' => "Moldova, Republic of",
|
||||
'MC' => "Monaco",
|
||||
'MN' => "Mongolia",
|
||||
'ME' => "Montenegro",
|
||||
'MS' => "Montserrat",
|
||||
'MA' => "Morocco",
|
||||
'MZ' => "Mozambique",
|
||||
'MM' => "Myanmar",
|
||||
'NA' => "Namibia",
|
||||
'NR' => "Nauru",
|
||||
'NP' => "Nepal",
|
||||
'NL' => "Netherlands",
|
||||
'NC' => "New Caledonia",
|
||||
'NZ' => "New Zealand",
|
||||
'NI' => "Nicaragua",
|
||||
'NE' => "Niger",
|
||||
'NG' => "Nigeria",
|
||||
'NU' => "Niue",
|
||||
'NF' => "Norfolk Island",
|
||||
'MP' => "Northern Mariana Islands",
|
||||
'NO' => "Norway",
|
||||
'OM' => "Oman",
|
||||
'PK' => "Pakistan",
|
||||
'PW' => "Palau",
|
||||
'PS' => "Palestine",
|
||||
'PA' => "Panama",
|
||||
'PG' => "Papua New Guinea",
|
||||
'PY' => "Paraguay",
|
||||
'PE' => "Peru",
|
||||
'PH' => "Philippines",
|
||||
'PN' => "Pitcairn",
|
||||
'PL' => "Poland",
|
||||
'PT' => "Portugal",
|
||||
'PR' => "Puerto Rico",
|
||||
'QA' => "Qatar",
|
||||
'RE' => "Réunion",
|
||||
'RO' => "Romania",
|
||||
'RU' => "Russian Federation",
|
||||
'RW' => "Rwanda",
|
||||
'BL' => "Saint Barthélemy",
|
||||
'SH' => "Saint Helena, Ascension and Tristan da Cunha",
|
||||
'KN' => "Saint Kitts and Nevis",
|
||||
'LC' => "Saint Lucia",
|
||||
'MF' => "Saint Martin (French part)",
|
||||
'PM' => "Saint Pierre and Miquelon",
|
||||
'VC' => "Saint Vincent and the Grenadines",
|
||||
'WS' => "Samoa",
|
||||
'SM' => "San Marino",
|
||||
'ST' => "Sao Tome and Principe",
|
||||
'SA' => "Saudi Arabia",
|
||||
'SN' => "Senegal",
|
||||
'RS' => "Serbia",
|
||||
'SC' => "Seychelles",
|
||||
'SL' => "Sierra Leone",
|
||||
'SG' => "Singapore",
|
||||
'SX' => "Sint Maarten (Dutch part)",
|
||||
'SK' => "Slovakia",
|
||||
'SI' => "Slovenia",
|
||||
'SB' => "Solomon Islands",
|
||||
'SO' => "Somalia",
|
||||
'ZA' => "South Africa",
|
||||
'GS' => "South Georgia and the South Sandwich Islands",
|
||||
'SS' => "South Sudan",
|
||||
'ES' => "Spain",
|
||||
'LK' => "Sri Lanka",
|
||||
'SD' => "Sudan",
|
||||
'SR' => "Suriname",
|
||||
'SJ' => "Svalbard and Jan Mayen",
|
||||
'SZ' => "Swaziland",
|
||||
'SE' => "Sweden",
|
||||
'CH' => "Switzerland",
|
||||
'SY' => "Syrian Arab Republic",
|
||||
'TW' => "Taiwan",
|
||||
'TJ' => "Tajikistan",
|
||||
'TZ' => "Tanzania, United Republic of",
|
||||
'TH' => "Thailand",
|
||||
'TL' => "Timor-Leste",
|
||||
'TG' => "Togo",
|
||||
'TK' => "Tokelau",
|
||||
'TO' => "Tonga",
|
||||
'TT' => "Trinidad and Tobago",
|
||||
'TN' => "Tunisia",
|
||||
'TR' => "Turkey",
|
||||
'TM' => "Turkmenistan",
|
||||
'TC' => "Turks and Caicos Islands",
|
||||
'TV' => "Tuvalu",
|
||||
'UG' => "Uganda",
|
||||
'UA' => "Ukraine",
|
||||
'AE' => "United Arab Emirates",
|
||||
'GB' => "United Kingdom",
|
||||
'US' => "United States",
|
||||
'UM' => "United States Minor Outlying Islands",
|
||||
'UY' => "Uruguay",
|
||||
'UZ' => "Uzbekistan",
|
||||
'VU' => "Vanuatu",
|
||||
'VE' => "Venezuela, Bolivarian Republic of",
|
||||
'VN' => "Viet Nam",
|
||||
'VG' => "Virgin Islands, British",
|
||||
'VI' => "Virgin Islands, U.S.",
|
||||
'WF' => "Wallis and Futuna",
|
||||
'EH' => "Western Sahara",
|
||||
'YE' => "Yemen",
|
||||
'ZM' => "Zambia",
|
||||
'ZW' => "Zimbabwe"
|
||||
];
|
||||
}
|
@ -20,10 +20,11 @@ use Doctrine\ORM\Mapping AS ORM;
|
||||
*/
|
||||
class RSVPCheckBoxListQuestionTemplate extends RSVPMultiValueQuestionTemplate
|
||||
{
|
||||
const ClassName = 'RSVPCheckBoxListQuestionTemplate';
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName(){
|
||||
return 'RSVPCheckBoxListQuestionTemplate';
|
||||
return self::ClassName;
|
||||
}
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
<?php namespace App\Models\Foundation\Summit\Events\RSVP;
|
||||
/**
|
||||
* 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\RSVP\RSVPMultiValueQuestionTemplate;
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
/**
|
||||
* @ORM\Table(name="RSVPDropDownQuestionTemplate")
|
||||
* @ORM\Entity
|
||||
* Class RSVPDropDownQuestionTemplate
|
||||
* @package App\Models\Foundation\Summit\Events\RSVP
|
||||
*/
|
||||
class RSVPDropDownQuestionTemplate extends RSVPMultiValueQuestionTemplate
|
||||
{
|
||||
const ClassName = 'RSVPDropDownQuestionTemplate';
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName(){
|
||||
return self::ClassName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="IsMultiSelect", type="boolean")
|
||||
* @var bool
|
||||
*/
|
||||
protected $is_multiselect;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="IsCountrySelector", type="boolean")
|
||||
* @var bool
|
||||
*/
|
||||
protected $is_country_selector;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="UseChosenPlugin", type="boolean")
|
||||
* @var bool
|
||||
*/
|
||||
protected $use_chosen_plugin;
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isMultiselect()
|
||||
{
|
||||
return $this->is_multiselect;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $is_multiselect
|
||||
*/
|
||||
public function setIsMultiselect($is_multiselect)
|
||||
{
|
||||
$this->is_multiselect = $is_multiselect;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isCountrySelector()
|
||||
{
|
||||
return $this->is_country_selector;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $is_country_selector
|
||||
*/
|
||||
public function setIsCountrySelector($is_country_selector)
|
||||
{
|
||||
$this->is_country_selector = $is_country_selector;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getUseChosenPlugin()
|
||||
{
|
||||
return $this->use_chosen_plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $use_chosen_plugin
|
||||
*/
|
||||
public function setUseChosenPlugin($use_chosen_plugin)
|
||||
{
|
||||
$this->use_chosen_plugin = $use_chosen_plugin;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->use_chosen_plugin = false;
|
||||
$this->is_multiselect = false;
|
||||
$this->is_country_selector = false;
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ use Doctrine\ORM\Mapping AS ORM;
|
||||
*/
|
||||
class RSVPLiteralContentQuestionTemplate extends RSVPQuestionTemplate
|
||||
{
|
||||
const ClassName = 'RSVPLiteralContentQuestionTemplate';
|
||||
/**
|
||||
* @ORM\Column(name="Content", type="string")
|
||||
* @var string
|
||||
@ -30,7 +31,7 @@ class RSVPLiteralContentQuestionTemplate extends RSVPQuestionTemplate
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName(){
|
||||
return 'RSVPLiteralContentQuestionTemplate';
|
||||
return self::ClassName;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,10 +20,11 @@ use Doctrine\ORM\Mapping AS ORM;
|
||||
*/
|
||||
class RSVPMemberEmailQuestionTemplate extends RSVPTextBoxQuestionTemplate
|
||||
{
|
||||
const ClassName = 'RSVPMemberEmailQuestionTemplate';
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName(){
|
||||
return 'RSVPMemberEmailQuestionTemplate';
|
||||
return self::ClassName;
|
||||
}
|
||||
}
|
@ -20,10 +20,11 @@ use Doctrine\ORM\Mapping AS ORM;
|
||||
*/
|
||||
class RSVPMemberFirstNameQuestionTemplate extends RSVPTextBoxQuestionTemplate
|
||||
{
|
||||
const ClassName = 'RSVPMemberFirstNameQuestionTemplate';
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName(){
|
||||
return 'RSVPMemberFirstNameQuestionTemplate';
|
||||
return self::ClassName;
|
||||
}
|
||||
}
|
@ -20,10 +20,11 @@ use Doctrine\ORM\Mapping AS ORM;
|
||||
*/
|
||||
class RSVPMemberLastNameQuestionTemplate extends RSVPTextBoxQuestionTemplate
|
||||
{
|
||||
const ClassName = 'RSVPMemberLastNameQuestionTemplate';
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName(){
|
||||
return 'RSVPMemberLastNameQuestionTemplate';
|
||||
return self::ClassName;
|
||||
}
|
||||
}
|
@ -29,7 +29,8 @@ use models\utils\SilverstripeBaseModel;
|
||||
* "RSVPMemberFirstNameQuestionTemplate" = "RSVPMemberFirstNameQuestionTemplate",
|
||||
* "RSVPMemberLastNameQuestionTemplate" = "RSVPMemberLastNameQuestionTemplate",
|
||||
* "RSVPCheckBoxListQuestionTemplate" = "RSVPCheckBoxListQuestionTemplate",
|
||||
* "RSVPRadioButtonListQuestionTemplate" = "RSVPRadioButtonListQuestionTemplate"
|
||||
* "RSVPRadioButtonListQuestionTemplate" = "RSVPRadioButtonListQuestionTemplate",
|
||||
* "RSVPDropDownQuestionTemplate" = "RSVPDropDownQuestionTemplate"
|
||||
* })
|
||||
* Class RSVPQuestionTemplate
|
||||
* @package App\Models\Foundation\Summit\Events\RSVP
|
||||
@ -183,4 +184,16 @@ class RSVPQuestionTemplate extends SilverstripeBaseModel
|
||||
return 'RSVPQuestionTemplate';
|
||||
}
|
||||
|
||||
public function clearTemplate(){
|
||||
$this->template = null;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->is_mandatory = false;
|
||||
$this->is_read_only = false;
|
||||
$this->order = 0;
|
||||
}
|
||||
|
||||
}
|
@ -20,10 +20,11 @@ use Doctrine\ORM\Mapping AS ORM;
|
||||
*/
|
||||
class RSVPRadioButtonListQuestionTemplate extends RSVPMultiValueQuestionTemplate
|
||||
{
|
||||
const ClassName = 'RSVPRadioButtonListQuestionTemplate';
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName(){
|
||||
return 'RSVPRadioButtonListQuestionTemplate';
|
||||
return self::ClassName;
|
||||
}
|
||||
}
|
@ -143,4 +143,48 @@ class RSVPTemplate extends SilverstripeBaseModel
|
||||
$this->questions = $questions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return RSVPQuestionTemplate
|
||||
*/
|
||||
public function getQuestionByName($name){
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('name', trim($name)));
|
||||
$res = $this->questions->matching($criteria)->first();
|
||||
return $res ? $res : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return RSVPQuestionTemplate
|
||||
*/
|
||||
public function getQuestionById($id){
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('id', intval($id)));
|
||||
$res = $this->questions->matching($criteria)->first();
|
||||
return $res ? $res : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RSVPQuestionTemplate $question
|
||||
* @return $this
|
||||
*/
|
||||
public function addQuestion(RSVPQuestionTemplate $question){
|
||||
$questions = $this->getQuestions();
|
||||
$this->questions->add($question);
|
||||
$question->setTemplate($this);
|
||||
$question->setOrder(count($questions) + 1);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RSVPQuestionTemplate $question
|
||||
* @return $this
|
||||
*/
|
||||
public function removeQuestion(RSVPQuestionTemplate $question){
|
||||
$this->questions->removeElement($question);
|
||||
$question->clearTemplate();
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
@ -20,10 +20,11 @@ use Doctrine\ORM\Mapping AS ORM;
|
||||
*/
|
||||
class RSVPTextAreaQuestionTemplate extends RSVPSingleValueTemplateQuestion
|
||||
{
|
||||
const ClassName = 'RSVPTextAreaQuestionTemplate';
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName(){
|
||||
return 'RSVPTextAreaQuestionTemplate';
|
||||
return self::ClassName;
|
||||
}
|
||||
}
|
@ -20,10 +20,11 @@ use Doctrine\ORM\Mapping AS ORM;
|
||||
*/
|
||||
class RSVPTextBoxQuestionTemplate extends RSVPSingleValueTemplateQuestion
|
||||
{
|
||||
const ClassName = 'RSVPTextBoxQuestionTemplate';
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName(){
|
||||
return 'RSVPTextBoxQuestionTemplate';
|
||||
return self::ClassName;
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
<?php namespace App\Models\Foundation\Summit\Events\RSVP\Templates;
|
||||
/**
|
||||
* 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\RSVP\RSVPCheckBoxListQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPDropDownQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPLiteralContentQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPMemberEmailQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPMemberFirstNameQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPMemberLastNameQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPRadioButtonListQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPTextAreaQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPTextBoxQuestionTemplate;
|
||||
/**
|
||||
* Class SummitRSVPTemplateQuestionConstants
|
||||
* @package App\Models\Foundation\Summit\Events\RSVP\Templates
|
||||
*/
|
||||
final class SummitRSVPTemplateQuestionConstants
|
||||
{
|
||||
public static $valid_class_names = [
|
||||
RSVPMemberEmailQuestionTemplate::ClassName,
|
||||
RSVPMemberFirstNameQuestionTemplate::ClassName,
|
||||
RSVPMemberLastNameQuestionTemplate::ClassName,
|
||||
RSVPTextBoxQuestionTemplate::ClassName,
|
||||
RSVPTextAreaQuestionTemplate::ClassName,
|
||||
RSVPCheckBoxListQuestionTemplate::ClassName,
|
||||
RSVPRadioButtonListQuestionTemplate::ClassName,
|
||||
RSVPDropDownQuestionTemplate::ClassName,
|
||||
RSVPLiteralContentQuestionTemplate::ClassName,
|
||||
];
|
||||
}
|
@ -0,0 +1,206 @@
|
||||
<?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 App\Models\Foundation\Summit\Events\RSVP\RSVPCheckBoxListQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPLiteralContentQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPMemberEmailQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPMemberFirstNameQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPMemberLastNameQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPMultiValueQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPRadioButtonListQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPSingleValueTemplateQuestion;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPTextAreaQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPTextBoxQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPDropDownQuestionTemplate;
|
||||
use models\exceptions\ValidationException;
|
||||
/**
|
||||
* Class SummitRSVPTemplateQuestionFactory
|
||||
* @package App\Models\Foundation\Summit\Factories
|
||||
*/
|
||||
final class SummitRSVPTemplateQuestionFactory
|
||||
{
|
||||
/**
|
||||
* @param array $data
|
||||
* @return RSVPQuestionTemplate|null
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public static function build(array $data){
|
||||
if(!isset($data['class_name'])) throw new ValidationException("missing class_name param");
|
||||
$location = null;
|
||||
switch($data['class_name']){
|
||||
case RSVPMemberEmailQuestionTemplate::ClassName :{
|
||||
$location = self::populateRSVPSingleValueTemplateQuestion(new RSVPMemberEmailQuestionTemplate, $data);
|
||||
}
|
||||
break;
|
||||
case RSVPMemberFirstNameQuestionTemplate::ClassName :{
|
||||
$location = self::populateRSVPSingleValueTemplateQuestion(new RSVPMemberFirstNameQuestionTemplate, $data);
|
||||
}
|
||||
break;
|
||||
case RSVPMemberLastNameQuestionTemplate::ClassName :{
|
||||
$location = self::populateRSVPSingleValueTemplateQuestion(new RSVPMemberLastNameQuestionTemplate, $data);
|
||||
}
|
||||
break;
|
||||
case RSVPTextBoxQuestionTemplate::ClassName :{
|
||||
$location = self::populateRSVPSingleValueTemplateQuestion(new RSVPTextBoxQuestionTemplate, $data);
|
||||
}
|
||||
break;
|
||||
case RSVPTextAreaQuestionTemplate::ClassName :{
|
||||
$location = self::populateRSVPSingleValueTemplateQuestion(new RSVPTextAreaQuestionTemplate, $data);
|
||||
}
|
||||
break;
|
||||
case RSVPCheckBoxListQuestionTemplate::ClassName :{
|
||||
$location = self::populateRSVPMultiValueQuestionTemplate(new RSVPCheckBoxListQuestionTemplate, $data);
|
||||
}
|
||||
break;
|
||||
case RSVPRadioButtonListQuestionTemplate::ClassName :{
|
||||
$location = self::populateRSVPMultiValueQuestionTemplate(new RSVPRadioButtonListQuestionTemplate, $data);
|
||||
}
|
||||
break;
|
||||
case RSVPDropDownQuestionTemplate::ClassName :{
|
||||
$location = self::populateRSVPDropDownQuestionTemplate(new RSVPDropDownQuestionTemplate, $data);
|
||||
}
|
||||
break;
|
||||
case RSVPLiteralContentQuestionTemplate::ClassName :{
|
||||
$location = self::populateRSVPLiteralContentQuestionTemplate(new RSVPLiteralContentQuestionTemplate, $data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $location;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RSVPSingleValueTemplateQuestion $question
|
||||
* @param array $data
|
||||
* @return RSVPQuestionTemplate
|
||||
*/
|
||||
private static function populateRSVPSingleValueTemplateQuestion(RSVPSingleValueTemplateQuestion $question, array $data){
|
||||
if(isset($data['initial_value']))
|
||||
$question->setInitialValue(trim($data['initial_value']));
|
||||
|
||||
$question = self::populateRSVPQuestionTemplate($question, $data);
|
||||
|
||||
return $question;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RSVPQuestionTemplate $question
|
||||
* @param array $data
|
||||
* @return RSVPQuestionTemplate
|
||||
*/
|
||||
private static function populateRSVPQuestionTemplate(RSVPQuestionTemplate $question, array $data){
|
||||
|
||||
if(isset($data['name']))
|
||||
$question->setName(trim($data['name']));
|
||||
|
||||
if(isset($data['label']))
|
||||
$question->setLabel(trim($data['label']));
|
||||
|
||||
if(isset($data['is_mandatory']))
|
||||
$question->setIsMandatory(boolval($data['is_mandatory']));
|
||||
|
||||
if(isset($data['is_read_only']))
|
||||
$question->setIsReadOnly(boolval($data['is_read_only']));
|
||||
|
||||
return $question;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RSVPMultiValueQuestionTemplate $question
|
||||
* @param array $data
|
||||
* @return RSVPMultiValueQuestionTemplate
|
||||
*/
|
||||
private static function populateRSVPMultiValueQuestionTemplate(RSVPMultiValueQuestionTemplate $question, array $data){
|
||||
|
||||
if(isset($data['empty_string']))
|
||||
$question->setEmptyString(trim($data['empty_string']));
|
||||
|
||||
return $question;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RSVPDropDownQuestionTemplate $question
|
||||
* @param array $data
|
||||
* @return RSVPDropDownQuestionTemplate
|
||||
*/
|
||||
private static function populateRSVPDropDownQuestionTemplate(RSVPDropDownQuestionTemplate $question, array $data){
|
||||
|
||||
if(isset($data['is_multiselect']))
|
||||
$question->setIsMultiselect(boolval($data['is_multiselect']));
|
||||
|
||||
if(isset($data['is_country_selector']))
|
||||
$question->setIsCountrySelector(boolval($data['is_country_selector']));
|
||||
|
||||
if(isset($data['use_chosen_plugin']))
|
||||
$question->setUseChosenPlugin(boolval($data['use_chosen_plugin']));
|
||||
|
||||
return $question;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RSVPLiteralContentQuestionTemplate $question
|
||||
* @param array $data
|
||||
* @return RSVPLiteralContentQuestionTemplate
|
||||
*/
|
||||
private static function populateRSVPLiteralContentQuestionTemplate(RSVPLiteralContentQuestionTemplate $question, array $data){
|
||||
if(isset($data['content']))
|
||||
$question->setContent(trim($data['content']));
|
||||
return $question;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RSVPQuestionTemplate $question
|
||||
* @param array $data
|
||||
* @return RSVPQuestionTemplate
|
||||
*/
|
||||
public static function populate(RSVPQuestionTemplate $question, array $data){
|
||||
|
||||
if($question instanceof RSVPMemberEmailQuestionTemplate){
|
||||
return self::populateRSVPSingleValueTemplateQuestion($question, $data);
|
||||
}
|
||||
|
||||
if($question instanceof RSVPMemberFirstNameQuestionTemplate){
|
||||
return self::populateRSVPSingleValueTemplateQuestion($question, $data);
|
||||
}
|
||||
|
||||
if($question instanceof RSVPMemberLastNameQuestionTemplate){
|
||||
return self::populateRSVPSingleValueTemplateQuestion($question, $data);
|
||||
}
|
||||
|
||||
if($question instanceof RSVPTextBoxQuestionTemplate){
|
||||
return self::populateRSVPSingleValueTemplateQuestion($question, $data);
|
||||
}
|
||||
|
||||
if($question instanceof RSVPTextAreaQuestionTemplate){
|
||||
return self::populateRSVPSingleValueTemplateQuestion($question, $data);
|
||||
}
|
||||
|
||||
if($question instanceof RSVPCheckBoxListQuestionTemplate){
|
||||
return self::populateRSVPMultiValueQuestionTemplate($question, $data);
|
||||
}
|
||||
|
||||
if($question instanceof RSVPRadioButtonListQuestionTemplate){
|
||||
return self::populateRSVPMultiValueQuestionTemplate($question, $data);
|
||||
}
|
||||
|
||||
if($question instanceof RSVPDropDownQuestionTemplate){
|
||||
return self::populateRSVPDropDownQuestionTemplate($question, $data);
|
||||
}
|
||||
|
||||
if($question instanceof RSVPLiteralContentQuestionTemplate){
|
||||
return self::populateRSVPLiteralContentQuestionTemplate($question, $data);
|
||||
}
|
||||
|
||||
return $question;
|
||||
}
|
||||
}
|
@ -148,34 +148,34 @@ class Summit extends SilverstripeBaseModel
|
||||
private $time_zone_id;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="SummitAbstractLocation", mappedBy="summit", cascade={"persist"}, orphanRemoval=true)
|
||||
* @ORM\OneToMany(targetEntity="SummitAbstractLocation", mappedBy="summit", cascade={"persist"}, orphanRemoval=true, fetch="EXTRA_LAZY")
|
||||
*/
|
||||
private $locations;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="SummitEvent", mappedBy="summit", cascade={"persist"}, orphanRemoval=true)
|
||||
* @ORM\OneToMany(targetEntity="SummitEvent", mappedBy="summit", cascade={"persist"}, orphanRemoval=true, fetch="EXTRA_LAZY")
|
||||
*/
|
||||
private $events;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="App\Models\Foundation\Summit\Events\RSVP\RSVPTemplate", mappedBy="summit", cascade={"persist"}, orphanRemoval=true)
|
||||
* @ORM\OneToMany(targetEntity="App\Models\Foundation\Summit\Events\RSVP\RSVPTemplate", mappedBy="summit", cascade={"persist"}, orphanRemoval=true, fetch="EXTRA_LAZY")
|
||||
*/
|
||||
private $rsvp_templates;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="SummitWIFIConnection", mappedBy="summit", cascade={"persist"}, orphanRemoval=true)
|
||||
* @ORM\OneToMany(targetEntity="SummitWIFIConnection", mappedBy="summit", cascade={"persist"}, orphanRemoval=true, fetch="EXTRA_LAZY")
|
||||
* @var SummitWIFIConnection[]
|
||||
*/
|
||||
private $wifi_connections;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="SummitRegistrationPromoCode", mappedBy="summit", cascade={"persist"}, orphanRemoval=true)
|
||||
* @ORM\OneToMany(targetEntity="SummitRegistrationPromoCode", mappedBy="summit", cascade={"persist"}, orphanRemoval=true, fetch="EXTRA_LAZY")
|
||||
* @var SummitRegistrationPromoCode[]
|
||||
*/
|
||||
private $promo_codes;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="PresentationSpeakerSummitAssistanceConfirmationRequest", mappedBy="summit")
|
||||
* @ORM\OneToMany(targetEntity="PresentationSpeakerSummitAssistanceConfirmationRequest", mappedBy="summit", fetch="EXTRA_LAZY")
|
||||
* @var PresentationSpeakerSummitAssistanceConfirmationRequest[]
|
||||
*/
|
||||
private $speaker_assistances;
|
||||
@ -188,30 +188,30 @@ class Summit extends SilverstripeBaseModel
|
||||
private $logo;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="models\summit\SummitEventType", mappedBy="summit", cascade={"persist"}, orphanRemoval=true)
|
||||
* @ORM\OneToMany(targetEntity="models\summit\SummitEventType", mappedBy="summit", cascade={"persist"}, orphanRemoval=true, fetch="EXTRA_LAZY")
|
||||
*/
|
||||
private $event_types;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="models\summit\PresentationCategory", mappedBy="summit", cascade={"persist"}, orphanRemoval=true)
|
||||
* @ORM\OneToMany(targetEntity="models\summit\PresentationCategory", mappedBy="summit", cascade={"persist"}, orphanRemoval=true, fetch="EXTRA_LAZY")
|
||||
* @var PresentationCategory[]
|
||||
*/
|
||||
private $presentation_categories;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="models\summit\SummitAttendee", mappedBy="summit", cascade={"persist"}, orphanRemoval=true)
|
||||
* @ORM\OneToMany(targetEntity="models\summit\SummitAttendee", mappedBy="summit", cascade={"persist"}, orphanRemoval=true, fetch="EXTRA_LAZY")
|
||||
* @var SummitAttendee[]
|
||||
*/
|
||||
private $attendees;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="models\summit\PresentationCategoryGroup", mappedBy="summit", cascade={"persist"}, orphanRemoval=true)
|
||||
* @ORM\OneToMany(targetEntity="models\summit\PresentationCategoryGroup", mappedBy="summit", cascade={"persist"}, orphanRemoval=true, fetch="EXTRA_LAZY")
|
||||
* @var PresentationCategoryGroup[]
|
||||
*/
|
||||
private $category_groups;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="models\summit\SummitTicketType", mappedBy="summit", cascade={"persist"}, orphanRemoval=true)
|
||||
* @ORM\OneToMany(targetEntity="models\summit\SummitTicketType", mappedBy="summit", cascade={"persist"}, orphanRemoval=true, fetch="EXTRA_LAZY")
|
||||
*/
|
||||
private $ticket_types;
|
||||
|
||||
|
@ -41,6 +41,8 @@ final class SummitScopes
|
||||
|
||||
const WriteLocationsData = '%s/locations/write';
|
||||
|
||||
const WriteRSVPTemplateData = '%s/rsvp-templates/write';
|
||||
|
||||
const WriteLocationBannersData = '%s/locations/banners/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\Events\RSVP\RSVPQuestionTemplate;
|
||||
use models\exceptions\EntityNotFoundException;
|
||||
use models\exceptions\ValidationException;
|
||||
use models\summit\Summit;
|
||||
@ -28,4 +29,14 @@ interface IRSVPTemplateService
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function deleteTemplate(Summit $summit, $template_id);
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param $template_id
|
||||
* @param array $payload
|
||||
* @return RSVPQuestionTemplate
|
||||
* @throws EntityNotFoundException
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function addQuestion(Summit $summit, $template_id, array $payload);
|
||||
}
|
@ -11,6 +11,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Factories\SummitRSVPTemplateQuestionFactory;
|
||||
use App\Models\Foundation\Summit\Repositories\IRSVPTemplateRepository;
|
||||
use libs\utils\ITransactionService;
|
||||
use models\exceptions\EntityNotFoundException;
|
||||
@ -65,4 +67,54 @@ final class RSVPTemplateService implements IRSVPTemplateService
|
||||
$summit->removeRSVPTemplate($template);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param $template_id
|
||||
* @param array $data
|
||||
* @return RSVPQuestionTemplate
|
||||
* @throws EntityNotFoundException
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function addQuestion(Summit $summit, $template_id, array $data)
|
||||
{
|
||||
return $this->tx_service->transaction(function() use($summit, $template_id, $data){
|
||||
|
||||
$template = $summit->getRSVPTemplateById($template_id);
|
||||
|
||||
if(is_null($template))
|
||||
throw new EntityNotFoundException
|
||||
(
|
||||
trans
|
||||
(
|
||||
'',
|
||||
[
|
||||
'summit_id' => $summit->getId(),
|
||||
'template_id' => $template_id,
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
$former_question = $template->getQuestionByName($data['name']);
|
||||
if(!is_null($former_question)){
|
||||
throw new ValidationException
|
||||
(
|
||||
trans
|
||||
(
|
||||
'',
|
||||
[
|
||||
'template_id' => $template_id,
|
||||
'name' => $data['name']
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$question = SummitRSVPTemplateQuestionFactory::build($data);
|
||||
|
||||
$template->addQuestion($question);
|
||||
|
||||
return $question;
|
||||
});
|
||||
}
|
||||
}
|
@ -48,10 +48,10 @@ use models\summit\SummitVenue;
|
||||
use models\summit\SummitVenueFloor;
|
||||
use models\summit\SummitVenueRoom;
|
||||
/**
|
||||
* Class LocationService
|
||||
* Class SummitLocationService
|
||||
* @package App\Services\Model
|
||||
*/
|
||||
final class LocationService implements ILocationService
|
||||
final class SummitLocationService implements ILocationService
|
||||
{
|
||||
/**
|
||||
* @var ISummitLocationRepository
|
@ -22,7 +22,7 @@ use App\Services\Model\IMemberService;
|
||||
use App\Services\Model\IRSVPTemplateService;
|
||||
use App\Services\Model\ISummitEventTypeService;
|
||||
use App\Services\Model\ISummitTrackService;
|
||||
use App\Services\Model\LocationService;
|
||||
use App\Services\Model\SummitLocationService;
|
||||
use App\Services\Model\MemberService;
|
||||
use App\Services\Model\RSVPTemplateService;
|
||||
use App\Services\Model\SummitPromoCodeService;
|
||||
@ -174,7 +174,7 @@ final class ServicesProvider extends ServiceProvider
|
||||
App::singleton
|
||||
(
|
||||
ILocationService::class,
|
||||
LocationService::class
|
||||
SummitLocationService::class
|
||||
);
|
||||
|
||||
App::singleton
|
||||
|
@ -73,16 +73,23 @@ class ApiEndpointsSeeder extends Seeder
|
||||
|
||||
$this->seedApiEndpoints('summits', [
|
||||
// summits
|
||||
array(
|
||||
[
|
||||
'name' => 'get-summits',
|
||||
'route' => '/api/v1/summits',
|
||||
'http_method' => 'GET',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::ReadSummitData, $current_realm),
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'get-summits-all',
|
||||
'route' => '/api/v1/summits/all',
|
||||
'http_method' => 'GET',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'get-summit',
|
||||
'route' => '/api/v1/summits/{id}',
|
||||
'http_method' => 'GET',
|
||||
@ -90,8 +97,8 @@ class ApiEndpointsSeeder extends Seeder
|
||||
sprintf(SummitScopes::ReadSummitData, $current_realm),
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'get-summit-entity-events',
|
||||
'route' => '/api/v1/summits/{id}/entity-events',
|
||||
'http_method' => 'GET',
|
||||
@ -99,9 +106,9 @@ class ApiEndpointsSeeder extends Seeder
|
||||
sprintf(SummitScopes::ReadSummitData, $current_realm),
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
),
|
||||
],
|
||||
// attendees
|
||||
array(
|
||||
[
|
||||
'name' => 'get-attendees',
|
||||
'route' => '/api/v1/summits/{id}/attendees',
|
||||
'http_method' => 'GET',
|
||||
@ -109,8 +116,8 @@ class ApiEndpointsSeeder extends Seeder
|
||||
sprintf(SummitScopes::ReadSummitData, $current_realm),
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'get-own-attendee',
|
||||
'route' => '/api/v1/summits/{id}/attendees/me',
|
||||
'http_method' => 'GET',
|
||||
@ -118,8 +125,8 @@ class ApiEndpointsSeeder extends Seeder
|
||||
sprintf(SummitScopes::ReadSummitData, $current_realm),
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'get-attendee',
|
||||
'route' => '/api/v1/summits/{id}/attendees/{attendee_id}',
|
||||
'http_method' => 'GET',
|
||||
@ -127,23 +134,23 @@ class ApiEndpointsSeeder extends Seeder
|
||||
sprintf(SummitScopes::ReadSummitData, $current_realm),
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'delete-attendee',
|
||||
'route' => '/api/v1/summits/{id}/attendees/{attendee_id}',
|
||||
'http_method' => 'DELETE',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WriteAttendeesData, $current_realm),
|
||||
],
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'update-attendee',
|
||||
'route' => '/api/v1/summits/{id}/attendees/{attendee_id}',
|
||||
'http_method' => 'PUT',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WriteAttendeesData, $current_realm),
|
||||
],
|
||||
),
|
||||
],
|
||||
array(
|
||||
'name' => 'get-attendee-schedule',
|
||||
'route' => '/api/v1/summits/{id}/attendees/{attendee_id}/schedule',
|
||||
@ -705,13 +712,103 @@ class ApiEndpointsSeeder extends Seeder
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'add-rsvp-template',
|
||||
'route' => '/api/v1/summits/{id}/rsvp-templates',
|
||||
'http_method' => 'POST',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WriteSummitData, $current_realm),
|
||||
sprintf(SummitScopes::WriteRSVPTemplateData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'update-rsvp-template',
|
||||
'route' => '/api/v1/summits/{id}/rsvp-templates/{template_id}',
|
||||
'http_method' => 'PUT',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WriteSummitData, $current_realm),
|
||||
sprintf(SummitScopes::WriteRSVPTemplateData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'delete-rsvp-template',
|
||||
'route' => '/api/v1/summits/{id}/rsvp-templates/{template_id}',
|
||||
'http_method' => 'DELETE',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WriteSummitData, $current_realm),
|
||||
sprintf(SummitScopes::WriteLocationsData, $current_realm)
|
||||
sprintf(SummitScopes::WriteRSVPTemplateData, $current_realm)
|
||||
],
|
||||
],
|
||||
// rsvp template questions
|
||||
[
|
||||
'name' => 'get-rsvp-template-question',
|
||||
'route' => '/api/v1/summits/{id}/rsvp-templates/{template_id}/questions/{question_id}',
|
||||
'http_method' => 'GET',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'add-rsvp-template-question',
|
||||
'route' => '/api/v1/summits/{id}/rsvp-templates/{template_id}/questions',
|
||||
'http_method' => 'POST',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WriteSummitData, $current_realm),
|
||||
sprintf(SummitScopes::WriteRSVPTemplateData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'update-rsvp-template-question',
|
||||
'route' => '/api/v1/summits/{id}/rsvp-templates/{template_id}/questions/{question_id}',
|
||||
'http_method' => 'PUT',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WriteSummitData, $current_realm),
|
||||
sprintf(SummitScopes::WriteRSVPTemplateData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'delete-rsvp-template-question',
|
||||
'route' => '/api/v1/summits/{id}/rsvp-templates/{template_id}/questions/{question_id}',
|
||||
'http_method' => 'DELETE',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WriteSummitData, $current_realm),
|
||||
sprintf(SummitScopes::WriteRSVPTemplateData, $current_realm)
|
||||
],
|
||||
],
|
||||
// multi value questions
|
||||
[
|
||||
'name' => 'add-rsvp-template-question-value',
|
||||
'route' => '/api/v1/summits/{id}/rsvp-templates/{template_id}/questions/{question_id}/values',
|
||||
'http_method' => 'POST',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WriteSummitData, $current_realm),
|
||||
sprintf(SummitScopes::WriteRSVPTemplateData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'get-rsvp-template-question-value',
|
||||
'route' => '/api/v1/summits/{id}/rsvp-templates/{template_id}/questions/{question_id}/values/{value_id}',
|
||||
'http_method' => 'GET',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'update-rsvp-template-question-value',
|
||||
'route' => '/api/v1/summits/{id}/rsvp-templates/{template_id}/questions/{question_id}/values/{value_id}',
|
||||
'http_method' => 'PUT',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WriteSummitData, $current_realm),
|
||||
sprintf(SummitScopes::WriteRSVPTemplateData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'delete-rsvp-template-question-value',
|
||||
'route' => '/api/v1/summits/{id}/rsvp-templates/{template_id}/questions/{question_id}/values/{value_id}',
|
||||
'http_method' => 'DELETE',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WriteSummitData, $current_realm),
|
||||
sprintf(SummitScopes::WriteRSVPTemplateData, $current_realm)
|
||||
],
|
||||
],
|
||||
// rooms
|
||||
|
@ -45,6 +45,35 @@ final class OAuth2SummitApiTest extends ProtectedApiTest
|
||||
$this->assertResponseStatus(200);
|
||||
}
|
||||
|
||||
public function testGetAllSummits()
|
||||
{
|
||||
|
||||
$start = time();
|
||||
$params = [
|
||||
'relations'=>'none',
|
||||
'expand' => 'none',
|
||||
];
|
||||
|
||||
$headers = ["HTTP_Authorization" => " Bearer " . $this->access_token];
|
||||
$response = $this->action(
|
||||
"GET",
|
||||
"OAuth2SummitApiController@getAllSummits",
|
||||
$params,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$summits = json_decode($content);
|
||||
$end = time();
|
||||
$delta = $end - $start;
|
||||
echo "execution call " . $delta . " seconds ...";
|
||||
$this->assertTrue(!is_null($summits));
|
||||
$this->assertResponseStatus(200);
|
||||
}
|
||||
|
||||
public function testGetSummit($summit_id = 22)
|
||||
{
|
||||
|
||||
|
@ -113,4 +113,92 @@ final class OAuth2SummitRSVPTemplateApiTest extends ProtectedApiTest
|
||||
$this->assertResponseStatus(204);
|
||||
|
||||
}
|
||||
|
||||
public function testAddRSVPTemplateQuestionRSVPTextBoxQuestionTemplate($summit_id = 24){
|
||||
|
||||
$templates_response = $this->testGetSummitRSVPTemplates($summit_id);
|
||||
$templates = $templates_response->data;
|
||||
|
||||
$params = [
|
||||
'id' => $summit_id,
|
||||
'template_id' => $templates[0]->id
|
||||
];
|
||||
|
||||
$name = str_random(16).'_rsvp_question';
|
||||
$data = [
|
||||
'name' => $name,
|
||||
'label' => 'test label',
|
||||
'initial_value' => 'test initial value',
|
||||
'is_mandatory' => true,
|
||||
'class_name' => \App\Models\Foundation\Summit\Events\RSVP\RSVPTextBoxQuestionTemplate::ClassName,
|
||||
];
|
||||
|
||||
$headers = [
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
];
|
||||
|
||||
$response = $this->action(
|
||||
"POST",
|
||||
"OAuth2SummitRSVPTemplatesApiController@addRSVPTemplateQuestion",
|
||||
$params,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
$headers,
|
||||
json_encode($data)
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(201);
|
||||
|
||||
$question = json_decode($content);
|
||||
$this->assertTrue(!is_null($question));
|
||||
$this->assertTrue($question->initial_value == 'test initial value');
|
||||
return $question;
|
||||
}
|
||||
|
||||
public function testAddRSVPTemplateQuestionRSVPDropDownQuestionTemplate($summit_id = 24){
|
||||
|
||||
$templates_response = $this->testGetSummitRSVPTemplates($summit_id);
|
||||
$templates = $templates_response->data;
|
||||
|
||||
$params = [
|
||||
'id' => $summit_id,
|
||||
'template_id' => $templates[0]->id
|
||||
];
|
||||
|
||||
$name = str_random(16).'_rsvp_question';
|
||||
$data = [
|
||||
'name' => $name,
|
||||
'label' => 'test dropdown',
|
||||
'is_mandatory' => true,
|
||||
'is_country_selector' => true,
|
||||
'empty_string' => '--select a value',
|
||||
'class_name' => \App\Models\Foundation\Summit\Events\RSVP\RSVPDropDownQuestionTemplate::ClassName,
|
||||
];
|
||||
|
||||
$headers = [
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
];
|
||||
|
||||
$response = $this->action(
|
||||
"POST",
|
||||
"OAuth2SummitRSVPTemplatesApiController@addRSVPTemplateQuestion",
|
||||
$params,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
$headers,
|
||||
json_encode($data)
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(201);
|
||||
|
||||
$question = json_decode($content);
|
||||
$this->assertTrue(!is_null($question));
|
||||
return $question;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user