Fixed CFP state transitions

Change-Id: If054fd822d85301d2d3fe85e7cf6d4c26aa4b381
This commit is contained in:
smarcet 2019-06-04 19:53:32 -03:00
parent 41f6a421c2
commit fa90b07484
4 changed files with 16 additions and 18 deletions

View File

@ -566,6 +566,13 @@ class Presentation extends SummitEvent
return $this->progress; return $this->progress;
} }
/**
* @return bool
*/
public function isCompleted():bool {
return $this->progress == Presentation::PHASE_COMPLETE;
}
/** /**
* @param int $progress * @param int $progress
*/ */

View File

@ -61,6 +61,7 @@ class SpeakerEditPermissionRequest extends SilverstripeBaseModel
{ {
parent::__construct(); parent::__construct();
$this->approved = false; $this->approved = false;
$this->hash = "";
} }
/** /**

View File

@ -281,8 +281,8 @@ final class PresentationService
$presentation->setSelectionPlan($current_selection_plan); $presentation->setSelectionPlan($current_selection_plan);
$summit->addEvent($presentation); $summit->addEvent($presentation);
if(!$presentation->isCompleted())
$presentation->setProgress(Presentation::PHASE_SUMMARY); $presentation->setProgress(Presentation::PHASE_SUMMARY);
$presentation = $this->saveOrUpdatePresentation $presentation = $this->saveOrUpdatePresentation
( (
@ -447,7 +447,7 @@ final class PresentationService
$presentation->clearTags(); $presentation->clearTags();
if (count($data['tags']) > 0) { if (count($data['tags']) > 0) {
if ($presentation->getProgress() == Presentation::PHASE_SUMMARY) if(!$presentation->isCompleted())
$presentation->setProgress(Presentation::PHASE_TAGS); $presentation->setProgress(Presentation::PHASE_TAGS);
} }
@ -596,12 +596,6 @@ final class PresentationService
$presentation_id $presentation_id
)); ));
if ($presentation->getProgress() != Presentation::PHASE_SPEAKERS) {
throw new ValidationException
(
sprintf("presentation %s is not allowed to mark as completed", $presentation_id)
);
}
if (!$presentation->fulfilSpeakersConditions()) { if (!$presentation->fulfilSpeakersConditions()) {
throw new ValidationException throw new ValidationException

View File

@ -1697,9 +1697,8 @@ final class SummitService extends AbstractService implements ISummitService
$speaker = $this->speaker_repository->getById(intval($speaker_id)); $speaker = $this->speaker_repository->getById(intval($speaker_id));
if (is_null($speaker)) if (is_null($speaker))
throw new EntityNotFoundException(sprintf('speaker %s not found', $speaker_id)); throw new EntityNotFoundException(sprintf('speaker %s not found', $speaker_id));
if(!$presentation->isCompleted())
if($presentation->getProgress() == Presentation::PHASE_TAGS) $presentation->setProgress(Presentation::PHASE_SPEAKERS);
$presentation->setProgress(Presentation::PHASE_SPEAKERS);
$presentation->addSpeaker($speaker); $presentation->addSpeaker($speaker);
}); });
@ -1741,8 +1740,7 @@ final class SummitService extends AbstractService implements ISummitService
$speaker = $this->speaker_repository->getById(intval($speaker_id)); $speaker = $this->speaker_repository->getById(intval($speaker_id));
if (is_null($speaker)) if (is_null($speaker))
throw new EntityNotFoundException(sprintf('speaker %s not found', $speaker_id)); throw new EntityNotFoundException(sprintf('speaker %s not found', $speaker_id));
if(!$presentation->isCompleted())
if($presentation->getProgress() == Presentation::PHASE_TAGS)
$presentation->setProgress(Presentation::PHASE_SPEAKERS); $presentation->setProgress(Presentation::PHASE_SPEAKERS);
$presentation->removeSpeaker($speaker); $presentation->removeSpeaker($speaker);
@ -1784,8 +1782,7 @@ final class SummitService extends AbstractService implements ISummitService
$speaker = $this->speaker_repository->getById(intval($speaker_id)); $speaker = $this->speaker_repository->getById(intval($speaker_id));
if (is_null($speaker)) if (is_null($speaker))
throw new EntityNotFoundException(sprintf('speaker %s not found', $speaker_id)); throw new EntityNotFoundException(sprintf('speaker %s not found', $speaker_id));
if(!$presentation->isCompleted())
if($presentation->getProgress() == Presentation::PHASE_TAGS)
$presentation->setProgress(Presentation::PHASE_SPEAKERS); $presentation->setProgress(Presentation::PHASE_SPEAKERS);
$presentation->setModerator($speaker); $presentation->setModerator($speaker);
@ -1828,8 +1825,7 @@ final class SummitService extends AbstractService implements ISummitService
$speaker = $this->speaker_repository->getById(intval($speaker_id)); $speaker = $this->speaker_repository->getById(intval($speaker_id));
if (is_null($speaker)) if (is_null($speaker))
throw new EntityNotFoundException(sprintf('speaker %s not found', $speaker_id)); throw new EntityNotFoundException(sprintf('speaker %s not found', $speaker_id));
if(!$presentation->isCompleted())
if($presentation->getProgress() == Presentation::PHASE_TAGS)
$presentation->setProgress(Presentation::PHASE_SPEAKERS); $presentation->setProgress(Presentation::PHASE_SPEAKERS);
$presentation->unsetModerator(); $presentation->unsetModerator();