Updates for CFP

* mark presentation as complete only
  if fulfil speakers requirements

Change-Id: Ie50c3f931ff28cea019e5a5645d0bcacfb62f90b
This commit is contained in:
smarcet 2019-03-06 09:56:55 -03:00
parent ba56571773
commit a8986736ba
2 changed files with 34 additions and 1 deletions

View File

@ -724,4 +724,30 @@ class Presentation extends SummitEvent
return false;
}
/**
* @return bool
*/
public function fulfilSpeakersConditions(): bool {
$type = $this->type;
if(!$type instanceof PresentationType) return false;
if($type->isUseModerator()){
$count = $this->getModeratorId() > 0 ? 1 : 0;
$max = $type->getMaxModerators();
$min = $type->getMinModerators();
if($type->isModeratorMandatory() && $min > $count) return false;
if( $count > $max ) return false;
}
if($type->isUseSpeakers()){
$count = $this->speakers->count();
$max = $type->getMaxSpeakers();
$min = $type->getMinSpeakers();
if($type->isAreSpeakersMandatory() && $min > $count) return false;
if( $count > $max ) return false;
}
return true;
}
}

View File

@ -410,7 +410,7 @@ final class PresentationService
$presentation->setType($event_type);
$presentation->setCategory($track);
// add me as speaker
$presentation->addSpeaker($current_speaker);
//$presentation->addSpeaker($current_speaker);
if (isset($data['tags'])) {
$presentation->clearTags();
@ -565,6 +565,13 @@ final class PresentationService
);
}
if (!$presentation->fulfilSpeakersConditions()) {
throw new ValidationException
(
sprintf("presentation %s is not allowed to mark as completed because does not fulfil speakers conditions", $presentation_id)
);
}
$title = $presentation->getTitle();
$abtract = $presentation->getAbstract();
$level = $presentation->getLevel();