
** Get all presentations from selection Plan GET /api/v1/summits/{id}/selection-plans/{selection_plan_id}/presentations filtering 'title' => ['=@', '=='], 'abstract' => ['=@', '=='], 'social_summary' => ['=@', '=='], 'tags' => ['=@', '=='], 'level' => ['=@', '=='], 'summit_type_id' => ['=='], 'event_type_id' => ['=='], 'track_id' => ['=='], 'speaker_id' => ['=='], 'speaker' => ['=@', '=='], 'speaker_email' => ['=@', '=='], 'selection_status' => ['=='], 'id' => ['=='], 'selection_plan_id' => ['=='], 'status' => ['=='], 'is_chair_visible' => ['=='], 'is_voting_visible' => ['=='], ** for track chairs app use 'filter' => 'status==Received,is_chair_visible==1', ordering track Scopes REALM_BASE_URL/summits/read AUTHZ super-admins administrators track-chairs track-chairs-admins ** Get individual Selection List GET /api/v1/summits/{id}/tracks/{track_id}/selection-lists/individual/owner/{owner_id} Scopes REALM_BASE_URL/summits/read AUTHZ super-admins administrators track-chairs track-chairs-admins ** Add to my individual Selection List POST /api/v1/summits/{id}/tracks/{track_id}/selection-lists/individual/presentation-selections/{collection}/presentations/{presentation_id} where {collection} should be one of following: * selected * maybe * pass Scopes REALM_BASE_URL/summits/write AUTHZ super-admins administrators track-chairs track-chairs-admins ** Remove From my individual selection list DELETE /api/v1/summits/{id}/tracks/{track_id}/selection-lists/individual/presentation-selections/{collection}/presentations/{presentation_id} where {collection} should be one of following: * selected * maybe * pass Scopes REALM_BASE_URL/summits/write AUTHZ super-admins administrators track-chairs track-chairs-admins ** Get Team Selection List GET /api/v1/summits/{id}/tracks/{track_id}/selection-lists/team Scopes REALM_BASE_URL/summits/read AUTHZ super-admins administrators track-chairs track-chairs-admins ** Create team selection list POST /api/v1/summits/{id}/tracks/{track_id}/selection-lists/team Scopes REALM_BASE_URL/summits/write AUTHZ super-admins administrators track-chairs track-chairs-admins ** Reorder list PUT /api/v1/summits/{id}/tracks/{track_id}/selection-lists/{list_id}/reorder payload hash => 'required|string' collection => 'required|string|in:selected,maybe' presentations => 'required|int_array' ( presentations ids) Scopes REALM_BASE_URL/summits/write AUTHZ super-admins administrators track-chairs track-chairs-admins ** Get track chairs per Summit GET /api/v1/summits/{id}/track-chairs fitering 'member_first_name' => ['=@', '=='], 'member_last_name' => ['=@', '=='], 'member_full_name' => ['=@', '=='], 'member_email' => ['=@', '=='], 'member_id' => ['=='], 'track_id' => ['=='], 'summit_id' => ['=='] Scopes REALM_BASE_URL/summits/read AUTHZ super-admins administrators track-chairs track-chairs-admins ** Mark Presentation as viewed PUT /api/v1/summits/{id}/selection-plans/{selection_plan_id}/presentations/{presentation_id}/view Scopes REALM_BASE_URL/summits/write AUTHZ super-admins administrators track-chairs track-chairs-admins ** Add Presentation Comment POST /api/v1/summits/{id}/selection-plans/{selection_plan_id}/presentations/{presentation_id}/comments Payload 'body' => 'required|string', 'is_public' => 'required|boolean', Scopes REALM_BASE_URL/summits/write AUTHZ super-admins administrators track-chairs track-chairs-admins ** Get all Presention Category Change Request GET /api/v1/summits/{id}/selection-plans/{selection_plan_id}/presentations/all/category-change-requests filtering 'selection_plan_id' => ['=='], 'summit_id' => ['=='], 'new_category_id' => ['=='], 'old_category_id' => ['=='], 'new_category_title' => ['=@', '=='], 'old_category_title' => ['=@', '=='], 'requester_fullname' => ['=@', '=='], 'requester_email' => ['=@', '=='], 'aprover_fullname' => ['=@', '=='], 'aprover_email' => ['=@', '=='] ordering 'id', 'approval_date', 'status' Scopes REALM_BASE_URL/summits/read REALM_BASE_URL/summits/read/all AUTHZ super-admins administrators track-chairs track-chairs-admins ** Add Presentation Category change Request POST /api/v1/summits/{id}/selection-plans/{selection_plan_id}/presentations/{presentation_id}/category-change-requests payload 'new_category_id' => 'required|integer', Scopes REALM_BASE_URL/summits/write AUTHZ super-admins administrators track-chairs track-chairs-admins ** Resolve Presentation Category change Request PUT /api/v1/summits/{id}/selection-plans/{selection_plan_id}/presentations/{presentation_id}/category-change-requests/{category_change_request_id} payload 'approved' => 'required|bool', 'reason' => 'sometimes|string', Scopes REALM_BASE_URL/summits/write AUTHZ super-admins administrators track-chairs track-chairs-admins ** Add track chair POST /api/v1/summits/{id}/track-chairs Payload 'member_id' => 'required|int', 'categories' => 'required|int_array', scopes REALM_BASE_URL/summits/write AUTHZ super-admins administrators track-chairs-admins ** Update track chair PUT /api/v1/summits/{id}/track-chairs/{track_chair_id} Payload 'categories' => 'required|int_array', scopes REALM_BASE_URL/summits/write AUTHZ super-admins administrators track-chairs-admins ** Delete track chairs DELETE /api/v1/summits/{id}/track-chairs/{track_chair_id} scopes REALM_BASE_URL/summits/write AUTHZ super-admins administrators track-chairs-admins ** Get Track Chair by Id GET /api/v1/summits/{id}/track-chairs/{track_chair_id} scopes REALM_BASE_URL/summits/read AUTHZ super-admins administrators track-chairs-admins Change-Id: Iab0d77a6337a0db27c649dcafb1d90f09923df8a Signed-off-by: smarcet <smarcet@gmail.com>
434 lines
11 KiB
PHP
434 lines
11 KiB
PHP
<?php namespace App\Models\Foundation\Summit;
|
|
/**
|
|
* Copyright 2018 OpenStack Foundation
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
**/
|
|
|
|
use Doctrine\Common\Collections\Criteria;
|
|
use Doctrine\ORM\Mapping AS ORM;
|
|
use App\Models\Utils\TimeZoneEntity;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use models\summit\Presentation;
|
|
use models\summit\PresentationCategory;
|
|
use models\summit\PresentationCategoryGroup;
|
|
use models\summit\Summit;
|
|
use models\summit\SummitOwned;
|
|
use models\utils\SilverstripeBaseModel;
|
|
use DateTime;
|
|
/**
|
|
* @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineSelectionPlanRepository")
|
|
* @ORM\AssociationOverrides({
|
|
* @ORM\AssociationOverride(
|
|
* name="summit",
|
|
* inversedBy="selection_plans"
|
|
* )
|
|
* })
|
|
* @ORM\Table(name="SelectionPlan")
|
|
* Class SelectionPlan
|
|
* @package App\Models\Foundation\Summit
|
|
*/
|
|
class SelectionPlan extends SilverstripeBaseModel
|
|
{
|
|
use SummitOwned;
|
|
|
|
use TimeZoneEntity;
|
|
|
|
const STATUS_SUBMISSION = 'SUBMISSION';
|
|
const STATUS_SELECTION = 'SELECTION';
|
|
const STATUS_VOTING = 'VOTING';
|
|
|
|
/**
|
|
* @ORM\Column(name="Name", type="string")
|
|
* @var String
|
|
*/
|
|
private $name;
|
|
|
|
/**
|
|
* @ORM\Column(name="MaxSubmissionAllowedPerUser", type="integer")
|
|
* @var int
|
|
*/
|
|
private $max_submission_allowed_per_user;
|
|
|
|
/**
|
|
* @ORM\Column(name="Enabled", type="boolean")
|
|
* @var bool
|
|
*/
|
|
private $is_enabled;
|
|
|
|
/**
|
|
* @ORM\Column(name="AllowNewPresentations", type="boolean")
|
|
* @var bool
|
|
*/
|
|
private $allow_new_presentations;
|
|
|
|
/**
|
|
* @ORM\Column(name="SubmissionBeginDate", type="datetime")
|
|
* @var \DateTime
|
|
*/
|
|
private $submission_begin_date;
|
|
|
|
/**
|
|
* @ORM\Column(name="SubmissionEndDate", type="datetime")
|
|
* @var \DateTime
|
|
*/
|
|
private $submission_end_date;
|
|
|
|
/**
|
|
* @ORM\Column(name="VotingBeginDate", type="datetime")
|
|
* @var \DateTime
|
|
*/
|
|
private $voting_begin_date;
|
|
|
|
/**
|
|
* @ORM\Column(name="VotingEndDate", type="datetime")
|
|
* @var \DateTime
|
|
*/
|
|
private $voting_end_date;
|
|
|
|
/**
|
|
* @ORM\Column(name="SelectionBeginDate", type="datetime")
|
|
* @var \DateTime
|
|
*/
|
|
private $selection_begin_date;
|
|
|
|
/**
|
|
* @ORM\Column(name="SelectionEndDate", type="datetime")
|
|
* @var \DateTime
|
|
*/
|
|
private $selection_end_date;
|
|
|
|
/**
|
|
* @ORM\ManyToMany(targetEntity="models\summit\PresentationCategoryGroup")
|
|
* @ORM\JoinTable(name="SelectionPlan_CategoryGroups",
|
|
* joinColumns={@ORM\JoinColumn(name="SelectionPlanID", referencedColumnName="ID")},
|
|
* inverseJoinColumns={@ORM\JoinColumn(name="PresentationCategoryGroupID", referencedColumnName="ID")}
|
|
* )
|
|
* @var PresentationCategoryGroup[]
|
|
*/
|
|
private $category_groups;
|
|
|
|
/**
|
|
* @ORM\OneToMany(targetEntity="models\summit\Presentation", mappedBy="selection_plan", cascade={"persist"})
|
|
* @var Presentation[]
|
|
*/
|
|
private $presentations;
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getTimeZoneId()
|
|
{
|
|
return $this->summit->getTimeZoneId();
|
|
}
|
|
|
|
/**
|
|
* @return DateTime
|
|
*/
|
|
public function getSubmissionBeginDate()
|
|
{
|
|
return $this->submission_begin_date;
|
|
}
|
|
|
|
/**
|
|
* @param DateTime $submission_begin_date
|
|
*/
|
|
public function setSubmissionBeginDate(DateTime $submission_begin_date){
|
|
$this->submission_begin_date = $this->convertDateFromTimeZone2UTC($submission_begin_date);
|
|
}
|
|
|
|
/**
|
|
* @return $this
|
|
*/
|
|
public function clearSubmissionDates(){
|
|
$this->submission_begin_date = $this->submission_end_date = null;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return DateTime
|
|
*/
|
|
public function getSubmissionEndDate()
|
|
{
|
|
return $this->submission_end_date;
|
|
}
|
|
|
|
/**
|
|
* @param DateTime $submission_end_date
|
|
*/
|
|
public function setSubmissionEndDate(DateTime $submission_end_date){
|
|
$this->submission_end_date = $this->convertDateFromTimeZone2UTC($submission_end_date);
|
|
}
|
|
|
|
/**
|
|
* @return DateTime
|
|
*/
|
|
public function getVotingBeginDate()
|
|
{
|
|
return $this->voting_begin_date;
|
|
}
|
|
|
|
/**
|
|
* @param DateTime $voting_begin_date
|
|
*/
|
|
public function setVotingBeginDate(DateTime $voting_begin_date){
|
|
$this->voting_begin_date = $this->convertDateFromTimeZone2UTC($voting_begin_date);
|
|
}
|
|
|
|
/**
|
|
* @return $this
|
|
*/
|
|
public function clearVotingDates(){
|
|
$this->voting_begin_date = $this->voting_end_date = null;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return DateTime
|
|
*/
|
|
public function getVotingEndDate()
|
|
{
|
|
return $this->voting_end_date;
|
|
}
|
|
|
|
/**
|
|
* @param DateTime $voting_end_date
|
|
*/
|
|
public function setVotingEndDate(DateTime $voting_end_date){
|
|
$this->voting_end_date = $this->convertDateFromTimeZone2UTC($voting_end_date);
|
|
}
|
|
|
|
/**
|
|
* @return DateTime
|
|
*/
|
|
public function getSelectionBeginDate()
|
|
{
|
|
return $this->selection_begin_date;
|
|
}
|
|
|
|
/**
|
|
* @param DateTime $selection_begin_date
|
|
*/
|
|
public function setSelectionBeginDate(DateTime $selection_begin_date){
|
|
$this->selection_begin_date = $this->convertDateFromTimeZone2UTC($selection_begin_date);
|
|
}
|
|
|
|
/**
|
|
* @return $this
|
|
*/
|
|
public function clearSelectionDates(){
|
|
$this->selection_begin_date = $this->selection_end_date = null;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return DateTime
|
|
*/
|
|
public function getSelectionEndDate()
|
|
{
|
|
return $this->selection_end_date;
|
|
}
|
|
|
|
/**
|
|
* @param DateTime $selection_end_date
|
|
*/
|
|
public function setSelectionEndDate(DateTime $selection_end_date){
|
|
$this->selection_end_date = $this->convertDateFromTimeZone2UTC($selection_end_date);
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getName()
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
/**
|
|
* @param string $name
|
|
*/
|
|
public function setName($name)
|
|
{
|
|
$this->name = $name;
|
|
}
|
|
|
|
/**
|
|
* @return bool
|
|
*/
|
|
public function IsEnabled()
|
|
{
|
|
return $this->is_enabled;
|
|
}
|
|
|
|
/**
|
|
* @param bool $is_enabled
|
|
*/
|
|
public function setIsEnabled($is_enabled)
|
|
{
|
|
$this->is_enabled = $is_enabled;
|
|
}
|
|
|
|
/**
|
|
* SelectionPlan constructor.
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->is_enabled = false;
|
|
$this->allow_new_presentations = true;
|
|
$this->category_groups = new ArrayCollection;
|
|
$this->presentations = new ArrayCollection;
|
|
$this->max_submission_allowed_per_user = Summit::DefaultMaxSubmissionAllowedPerUser;
|
|
}
|
|
|
|
/**
|
|
* @return PresentationCategoryGroup[]
|
|
*/
|
|
public function getCategoryGroups()
|
|
{
|
|
return $this->category_groups;
|
|
}
|
|
|
|
/**
|
|
* @param PresentationCategoryGroup $track_group
|
|
*/
|
|
public function addTrackGroup(PresentationCategoryGroup $track_group){
|
|
if($this->category_groups->contains($track_group)) return;
|
|
$this->category_groups->add($track_group);
|
|
}
|
|
|
|
/**
|
|
* @param PresentationCategoryGroup $track_group
|
|
*/
|
|
public function removeTrackGroup(PresentationCategoryGroup $track_group){
|
|
if(!$this->category_groups->contains($track_group)) return;
|
|
$this->category_groups->removeElement($track_group);
|
|
}
|
|
|
|
/**
|
|
* @return int
|
|
*/
|
|
public function getMaxSubmissionAllowedPerUser()
|
|
{
|
|
return $this->max_submission_allowed_per_user;
|
|
}
|
|
|
|
/**
|
|
* @param int $max_submission_allowed_per_user
|
|
*/
|
|
public function setMaxSubmissionAllowedPerUser($max_submission_allowed_per_user)
|
|
{
|
|
$this->max_submission_allowed_per_user = $max_submission_allowed_per_user;
|
|
}
|
|
|
|
/**
|
|
* @return Presentation[]
|
|
*/
|
|
public function getPresentations()
|
|
{
|
|
return $this->presentations;
|
|
}
|
|
|
|
/**
|
|
* @param Presentation $presentation
|
|
*/
|
|
public function addPresentation(Presentation $presentation){
|
|
if($this->presentations->contains($presentation)) return;
|
|
$this->presentations->add($presentation);
|
|
$presentation->setSelectionPlan($this);
|
|
}
|
|
|
|
public function getStageStatus($stage) {
|
|
|
|
$getStartDate = "get{$stage}BeginDate";
|
|
$getEndDate = "get{$stage}EndDate";
|
|
$start_date = $this->$getStartDate();
|
|
$end_date = $this->$getEndDate();
|
|
|
|
if (empty($start_date) || empty($end_date)) {
|
|
return null;
|
|
}
|
|
|
|
$utc_time_zone = new \DateTimeZone('UTC');
|
|
$start_date->setTimeZone($utc_time_zone);
|
|
$end_date->setTimeZone($utc_time_zone);
|
|
$now = new \DateTime('now', new \DateTimeZone( 'UTC'));
|
|
|
|
if ($now > $end_date) {
|
|
return Summit::STAGE_FINISHED;
|
|
} else if ($now < $start_date) {
|
|
return Summit::STAGE_UNSTARTED;
|
|
} else {
|
|
return Summit::STAGE_OPEN;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param PresentationCategory $track
|
|
* @return bool
|
|
*/
|
|
public function hasTrack(PresentationCategory $track){
|
|
foreach($this->category_groups as $track_group){
|
|
if($track_group->hasCategory($track->getIdentifier())) return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* @return bool
|
|
*/
|
|
public function isVotingOpen()
|
|
{
|
|
return $this->getStageStatus('Voting') === Summit::STAGE_OPEN;
|
|
}
|
|
|
|
/**
|
|
* @return bool
|
|
*/
|
|
public function isSubmissionOpen()
|
|
{
|
|
return $this->getStageStatus('Submission') === Summit::STAGE_OPEN;
|
|
}
|
|
|
|
/**
|
|
* @return bool
|
|
*/
|
|
public function isSelectionOpen()
|
|
{
|
|
return $this->getStageStatus('Selection') === Summit::STAGE_OPEN;
|
|
}
|
|
|
|
/**
|
|
* @return bool
|
|
*/
|
|
public function isAllowNewPresentations(): bool
|
|
{
|
|
return $this->allow_new_presentations;
|
|
}
|
|
|
|
/**
|
|
* @param bool $allow_new_presentations
|
|
*/
|
|
public function setAllowNewPresentations(bool $allow_new_presentations): void
|
|
{
|
|
$this->allow_new_presentations = $allow_new_presentations;
|
|
}
|
|
|
|
/**
|
|
* @param int $id
|
|
* @return Presentation|null
|
|
*/
|
|
public function getPresentation(int $id):?Presentation{
|
|
$criteria = Criteria::create();
|
|
$criteria->where(Criteria::expr()->eq('id', intval($id)));
|
|
$presentation = $this->presentations->matching($criteria)->first();
|
|
return $presentation === false ? null : $presentation;
|
|
}
|
|
} |