Updated speaker other_presentation_links collection
for PUT/POST actions Change-Id: Ife5da99f0877afd0803ea395ebace0e895f28113
This commit is contained in:
parent
65bc82b760
commit
68b7548ba4
|
@ -549,7 +549,7 @@ final class OAuth2SummitSpeakersApiController extends OAuth2ProtectedController
|
|||
// collections
|
||||
'languages' => 'sometimes|int_array',
|
||||
'areas_of_expertise' => 'sometimes|string_array',
|
||||
'other_presentation_links' => 'sometimes|string_array',
|
||||
'other_presentation_links' => 'sometimes|link_array',
|
||||
'travel_preferences' => 'sometimes|string_array',
|
||||
'organizational_roles' => 'sometimes|int_array',
|
||||
'other_organizational_rol' => 'sometimes|string|max:255',
|
||||
|
@ -628,7 +628,7 @@ final class OAuth2SummitSpeakersApiController extends OAuth2ProtectedController
|
|||
// collections
|
||||
'languages' => 'sometimes|int_array',
|
||||
'areas_of_expertise' => 'sometimes|string_array',
|
||||
'other_presentation_links' => 'sometimes|string_array',
|
||||
'other_presentation_links' => 'sometimes|link_array',
|
||||
'travel_preferences' => 'sometimes|string_array',
|
||||
'organizational_roles' => 'sometimes|int_array',
|
||||
'other_organizational_rol' => 'sometimes|string|max:255',
|
||||
|
@ -787,7 +787,7 @@ final class OAuth2SummitSpeakersApiController extends OAuth2ProtectedController
|
|||
// collections
|
||||
'languages' => 'sometimes|int_array',
|
||||
'areas_of_expertise' => 'sometimes|string_array',
|
||||
'other_presentation_links' => 'sometimes|string_array',
|
||||
'other_presentation_links' => 'sometimes|link_array',
|
||||
'travel_preferences' => 'sometimes|string_array',
|
||||
'organizational_roles' => 'sometimes|int_array',
|
||||
'other_organizational_rol' => 'sometimes|string|max:255',
|
||||
|
@ -860,7 +860,7 @@ final class OAuth2SummitSpeakersApiController extends OAuth2ProtectedController
|
|||
// collections
|
||||
'languages' => 'sometimes|int_array',
|
||||
'areas_of_expertise' => 'sometimes|string_array',
|
||||
'other_presentation_links' => 'sometimes|string_array',
|
||||
'other_presentation_links' => 'sometimes|link_array',
|
||||
'travel_preferences' => 'sometimes|string_array',
|
||||
'organizational_roles' => 'sometimes|int_array',
|
||||
'other_organizational_rol' => 'sometimes|string|max:255',
|
||||
|
|
|
@ -225,6 +225,26 @@ class AppServiceProvider extends ServiceProvider
|
|||
return true;
|
||||
});
|
||||
|
||||
Validator::extend('link_array', function($attribute, $value, $parameters, $validator)
|
||||
{
|
||||
$validator->addReplacer('link_array', function($message, $attribute, $rule, $parameters) use ($validator) {
|
||||
return sprintf("%s should be an array of {title,link} tuple", $attribute);
|
||||
});
|
||||
|
||||
if(!is_array($value)) return false;
|
||||
foreach($value as $element)
|
||||
{
|
||||
// Creates a Validator instance and validates the data.
|
||||
$validation = Validator::make($element, [
|
||||
'title' => 'required|string|max:255',
|
||||
'link' => 'required|url',
|
||||
]);
|
||||
|
||||
if($validation->fails()) return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
Validator::extend('team_permission', function($attribute, $value, $parameters, $validator)
|
||||
{
|
||||
$validator->addReplacer('team_permission', function($message, $attribute, $rule, $parameters) use ($validator) {
|
||||
|
|
|
@ -454,7 +454,7 @@ final class SpeakerService
|
|||
if (isset($data['other_presentation_links']) && is_array($data['other_presentation_links'])) {
|
||||
$speaker->clearOtherPresentationLinks();
|
||||
foreach ($data['other_presentation_links'] as $link) {
|
||||
$speaker->addOtherPresentationLink(new SpeakerPresentationLink($link));
|
||||
$speaker->addOtherPresentationLink(new SpeakerPresentationLink(trim($link['link']), trim($link['title'])));
|
||||
}
|
||||
}
|
||||
// languages
|
||||
|
|
|
@ -28,17 +28,20 @@ final class OAuth2SpeakersApiTest extends ProtectedApiTest
|
|||
$suffix = str_random(16);
|
||||
|
||||
$data = [
|
||||
|
||||
'title' => 'Developer!',
|
||||
'first_name' => 'Sebastian',
|
||||
'last_name' => 'Marcet',
|
||||
'email' => "smarcet.{$suffix}@gmail.com",
|
||||
'languages' => [1,2],
|
||||
'other_presentation_links' => ["https://www.openstack.org"],
|
||||
'languages' => [1,2,3],
|
||||
'other_presentation_links' => [
|
||||
[
|
||||
'link' => 'https://www.openstack.org',
|
||||
]
|
||||
],
|
||||
'travel_preferences' => ["AF"],
|
||||
"areas_of_expertise" => ["testing"],
|
||||
"active_involvements" => [1],
|
||||
"organizational_roles" => [1],
|
||||
"active_involvements" => [],
|
||||
"organizational_roles" => [],
|
||||
"other_organizational_rol" => "no se",
|
||||
];
|
||||
|
||||
|
|
Loading…
Reference in New Issue