Fixed method getPresentationsBySummitAndRole

Added Selection Plan to Presentation Serializer

Change-Id: Id1cf1025a4e19d0280edb0d8af2083f9166a1fd1
This commit is contained in:
smarcet 2018-11-23 14:18:18 -03:00
parent 51a67b1782
commit b77c451b45
3 changed files with 36 additions and 16 deletions

View File

@ -23,6 +23,7 @@ class PresentationSerializer extends SummitEventSerializer
'Level' => 'level',
'CreatorId' => 'creator_id:json_int',
'ModeratorId' => 'moderator_speaker_id:json_int',
'SelectionPlanId' => 'selection_plan_id:json_int',
'ProblemAddressed' => 'problem_addressed:json_string',
'AttendeesExpectedLearnt' => 'attendees_expected_learnt:json_string',
'ToRecord' => 'to_record:json_boolean',
@ -35,6 +36,7 @@ class PresentationSerializer extends SummitEventSerializer
'track_id',
'creator_id',
'moderator_speaker_id',
'selection_plan_id',
'level',
'problem_addressed',
'attendees_expected_learnt',
@ -135,6 +137,13 @@ class PresentationSerializer extends SummitEventSerializer
}
}
break;
case 'selection_plan':{
if($presentation->getSelectionPlanId() > 0) {
unset($values['selection_plan_id']);
$values['selection_plan'] = SerializerRegistry::getInstance()->getSerializer($presentation->getSelectionPlan())->serialize();
}
}
break;
}
}
}

View File

@ -418,6 +418,19 @@ class Presentation extends SummitEvent
}
}
/**
* @return int
*/
public function getSelectionPlanId(){
try {
return !is_null($this->selection_plan)? $this->selection_plan->getId():0;
}
catch(\Exception $ex){
return 0;
}
}
/**
* @return PresentationSpeaker
*/
@ -700,20 +713,6 @@ class Presentation extends SummitEvent
}
}
/**
* @return int
*/
public function getSelectionPlanId()
{
try{
if(is_null($this->selection_plan)) return 0;
return $this->selection_plan->getId();
}
catch(\Exception $ex){
return 0;
}
}
/**
* @param PresentationSpeaker $speaker
* @return bool

View File

@ -857,11 +857,16 @@ class Summit extends SilverstripeBaseModel
* @return array
*/
public function getModeratedPresentationsBy(PresentationSpeaker $speaker, SelectionPlan $selectionPlan = null){
$selection_plan_cond = "";
if(!is_null($selectionPlan)){
$selection_plan_cond = " and sp.id = :selection_plan_id";
}
$query = $this->createQuery("SELECT p from models\summit\Presentation p
JOIN p.summit s
JOIN p.moderator m
JOIN p.selection_plan sp
WHERE s.id = :summit_id and m.id = :moderator_id and sp.id = :selection_plan_id");
WHERE s.id = :summit_id and m.id = :moderator_id".$selection_plan_cond);
$query = $query
->setParameter('summit_id', $this->getIdentifier())
@ -879,11 +884,18 @@ class Summit extends SilverstripeBaseModel
* @return array
*/
public function getCreatedPresentations(PresentationSpeaker $speaker, SelectionPlan $selectionPlan = null){
$selection_plan_cond = "";
if(!is_null($selectionPlan)){
$selection_plan_cond = " and sp.id = :selection_plan_id";
}
$query = $this->createQuery("SELECT p from models\summit\Presentation p
JOIN p.summit s
JOIN p.creator c
JOIN p.selection_plan sp
WHERE s.id = :summit_id and c.id = :creator_id and sp.id = :selection_plan_id");
WHERE s.id = :summit_id and c.id = :creator_id".$selection_plan_cond);
$query = $query
->setParameter('summit_id', $this->getIdentifier())
->setParameter('creator_id', $speaker->getMemberId());