Updated Member/Speaker Serializer
Updated PIC url generation Change-Id: I2eb47f39d92379fa9dc289490ee269e901ecb6e7
This commit is contained in:
parent
9ab47a68d6
commit
84df8f2923
|
@ -73,7 +73,8 @@ SCP_REMOTE_BASE_PATH=/tmp
|
|||
GOOGLE_GEO_CODING_API_KEY=
|
||||
|
||||
CLOUD_STORAGE_BASE_URL=
|
||||
CLOUD_STORAGE_CONTAINER=
|
||||
CLOUD_STORAGE_ASSETS_CONTAINER=
|
||||
CLOUD_STORAGE_IMAGES_CONTAINER=
|
||||
CLOUD_STORAGE_AUTH_URL=
|
||||
CLOUD_STORAGE_USERNAME=
|
||||
CLOUD_STORAGE_APIKEY=
|
||||
|
|
|
@ -58,7 +58,7 @@ class AbstractMemberSerializer extends SilverStripeSerializer
|
|||
if(!count($relations)) $relations = $this->getAllowedRelations();
|
||||
|
||||
$values = parent::serialize($expand, $fields, $relations, $params);
|
||||
$values['pic'] = Config::get("server.assets_base_url", 'https://www.openstack.org/'). 'profile_images/members/'. $member->getId();
|
||||
$values['pic'] = $member->getProfilePhotoUrl();
|
||||
|
||||
if(in_array('groups', $relations))
|
||||
$values['groups'] = $member->getGroupsIds();
|
||||
|
|
|
@ -21,14 +21,14 @@ use models\summit\PresentationSpeaker;
|
|||
class PresentationSpeakerSerializer extends SilverStripeSerializer
|
||||
{
|
||||
protected static $array_mappings = [
|
||||
'FirstName' => 'first_name:json_string',
|
||||
'LastName' => 'last_name:json_string',
|
||||
'Title' => 'title:json_string',
|
||||
'Bio' => 'bio:json_string',
|
||||
'IRCHandle' => 'irc:json_string',
|
||||
'TwitterName' => 'twitter:json_string',
|
||||
'OrgHasCloud' => 'org_has_cloud:json_boolean',
|
||||
'Country' => 'country:json_string',
|
||||
'FirstName' => 'first_name:json_string',
|
||||
'LastName' => 'last_name:json_string',
|
||||
'Title' => 'title:json_string',
|
||||
'Bio' => 'bio:json_string',
|
||||
'IRCHandle' => 'irc:json_string',
|
||||
'TwitterName' => 'twitter:json_string',
|
||||
'OrgHasCloud' => 'org_has_cloud:json_boolean',
|
||||
'Country' => 'country:json_string',
|
||||
'AvailableForBureau' => 'available_for_bureau:json_boolean',
|
||||
'FundedTravel' => 'funded_travel:json_boolean',
|
||||
'WillingToTravel' => 'willing_to_travel:json_boolean',
|
||||
|
@ -76,7 +76,7 @@ class PresentationSpeakerSerializer extends SilverStripeSerializer
|
|||
$values['moderated_presentations'] = $speaker->getModeratedPresentationIds($summit_id, $published);
|
||||
}
|
||||
|
||||
$values['pic'] = Config::get("server.assets_base_url", 'https://www.openstack.org/') . 'profile_images/speakers/' . $speaker->getId();
|
||||
$values['pic'] = $speaker->getProfilePhotoUrl();
|
||||
|
||||
if (in_array('member', $relations) && $speaker->hasMember())
|
||||
{
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use models\utils\SilverstripeBaseModel;
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
use models\utils\SilverstripeBaseModel;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="repositories\main\DoctrineFolderRepository")
|
||||
|
@ -272,7 +272,24 @@ class File extends SilverstripeBaseModel
|
|||
*/
|
||||
public function getCloudLink()
|
||||
{
|
||||
return Config::get("cloudstorage.base_url") . $this->getRelativeLinkFor();
|
||||
return
|
||||
sprintf("%s/%s/%s",
|
||||
Config::get("cloudstorage.base_url") ,
|
||||
Config::get("cloudstorage.assets_container"),
|
||||
$this->getRelativeLinkFor());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $imageRelativePath
|
||||
* @return string
|
||||
*/
|
||||
public static function getCloudLinkForImages(string $imageRelativePath):string {
|
||||
return
|
||||
sprintf("%s/%s/%s",
|
||||
Config::get("cloudstorage.base_url") ,
|
||||
Config::get("cloudstorage.images_container"),
|
||||
$imageRelativePath
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1083,4 +1083,22 @@ SQL;
|
|||
}
|
||||
return $fullname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProfilePhotoUrl():string{
|
||||
$photoUrl = null;
|
||||
if($photo = $this->getPhoto()){
|
||||
$photoUrl = $photo->getUrl();
|
||||
}
|
||||
if(empty($photo_url) && !empty($this->getTwitterHandle()) ){
|
||||
$twitterName = $this->getTwitterHandle();
|
||||
$photoUrl = 'https://twitter.com/' . trim(trim($twitterName, '@')) . '/profile_image?size=original';
|
||||
}
|
||||
if(empty($photoUrl)){
|
||||
$photoUrl = File::getCloudLinkForImages("generic-profile-photo.png");
|
||||
}
|
||||
return $photoUrl;
|
||||
}
|
||||
}
|
|
@ -1578,4 +1578,25 @@ SQL;
|
|||
|
||||
return $email ? $email->getType() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProfilePhotoUrl():string{
|
||||
$photoUrl = null;
|
||||
if($photo = $this->getPhoto()){
|
||||
$photoUrl = $photo->getUrl();
|
||||
}
|
||||
if(empty($photo_url) && $this->hasMember() && $photo = $this->member->getPhoto()){
|
||||
$photoUrl = $photo->getUrl();
|
||||
}
|
||||
if(empty($photo_url) && !empty($this->getTwitterName()) ){
|
||||
$twitterName = $this->getTwitterName();
|
||||
$photoUrl = 'https://twitter.com/' . trim(trim($twitterName, '@')) . '/profile_image?size=original';
|
||||
}
|
||||
if(empty($photoUrl)){
|
||||
$photoUrl = File::getCloudLinkForImages("generic-speaker-icon.png");
|
||||
}
|
||||
return $photoUrl;
|
||||
}
|
||||
}
|
|
@ -14,7 +14,8 @@
|
|||
|
||||
return [
|
||||
'base_url' => env('CLOUD_STORAGE_BASE_URL', null),
|
||||
'container' => env('CLOUD_STORAGE_CONTAINER', null),
|
||||
'assets_container' => env('CLOUD_STORAGE_ASSETS_CONTAINER', null),
|
||||
'images_container' => env('CLOUD_STORAGE_IMAGES_CONTAINER', null),
|
||||
'auth_url' => env('CLOUD_STORAGE_AUTH_URL', null),
|
||||
'user_name' => env('CLOUD_STORAGE_USERNAME', null),
|
||||
'api_key' => env('CLOUD_STORAGE_APIKEY', null),
|
||||
|
|
Loading…
Reference in New Issue