Model Update
Added track to all events ( moved from Presentation to Summit events) also moved away summit types from Summit Events. Change-Id: Ie3a56613635d3b88376fa5a4b631081b0eb00a46
This commit is contained in:
@@ -289,7 +289,7 @@ final class OAuth2SummitEventsApiController extends OAuth2ProtectedController
|
||||
'end_date' => 'sometimes|required_with:start_date|date_format:U|after:start_date',
|
||||
'allow_feedback' => 'sometimes|required|boolean',
|
||||
'type_id' => 'required|integer',
|
||||
'summit_types_id' => 'required|int_array',
|
||||
'track_id' => 'required|integer',
|
||||
'tags' => 'sometimes|required|string_array',
|
||||
);
|
||||
|
||||
@@ -353,7 +353,7 @@ final class OAuth2SummitEventsApiController extends OAuth2ProtectedController
|
||||
'end_date' => 'sometimes|required_with:start_date|date_format:U|after:start_date',
|
||||
'allow_feedback' => 'sometimes|required|boolean',
|
||||
'type_id' => 'sometimes|required|integer',
|
||||
'summit_types_id' => 'sometimes|required|int_array',
|
||||
'track_id' => 'sometimes|required|integer',
|
||||
'tags' => 'sometimes|required|string_array',
|
||||
);
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ class PresentationSerializer extends SummitEventSerializer
|
||||
protected static $array_mappings = array
|
||||
(
|
||||
'Level' => 'level',
|
||||
'CategoryId' => 'track_id:json_int',
|
||||
'ModeratorId' => 'moderator_speaker_id:json_int',
|
||||
'ProblemAddressed' => 'problem_addressed:json_string',
|
||||
'AttendeesExpectedLearnt' => 'attendees_expected_learnt:json_string',
|
||||
|
||||
@@ -35,6 +35,7 @@ class SummitEventSerializer extends SilverStripeSerializer
|
||||
'Published' => 'is_published:json_boolean',
|
||||
'HeadCount' => 'head_count:json_int',
|
||||
'RSVPLink' => 'rsvp_link:json_string',
|
||||
'CategoryId' => 'track_id:json_int',
|
||||
);
|
||||
|
||||
protected static $allowed_fields = array
|
||||
@@ -53,11 +54,11 @@ class SummitEventSerializer extends SilverStripeSerializer
|
||||
'is_published',
|
||||
'head_count',
|
||||
'rsvp_link',
|
||||
'track_id',
|
||||
);
|
||||
|
||||
protected static $allowed_relations = array
|
||||
(
|
||||
'summit_types',
|
||||
'sponsors',
|
||||
'tags',
|
||||
);
|
||||
@@ -85,9 +86,6 @@ class SummitEventSerializer extends SilverStripeSerializer
|
||||
$values['description'] = JsonUtils::toJsonString($event->getShortDescription());
|
||||
}
|
||||
|
||||
if(in_array('summit_types', $relations))
|
||||
$values['summit_types'] = $event->getSummitTypesIds();
|
||||
|
||||
if(in_array('sponsors', $relations))
|
||||
$values['sponsors'] = $event->getSponsorsIds();
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ final class SummitSerializer extends SilverStripeSerializer
|
||||
'StartShowingVenuesDate' => 'start_showing_venues_date:datetime_epoch',
|
||||
'Active' => 'active:json_boolean',
|
||||
'ScheduleDefaultStartDate' => 'schedule_start_date:datetime_epoch',
|
||||
'TypeId' => 'type_id:json_int' ,
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -68,12 +69,6 @@ final class SummitSerializer extends SilverStripeSerializer
|
||||
$values['schedule_page_url'] = sprintf("%ssummit/%s/%s", Config::get("server.assets_base_url", 'https://www.openstack.org/'), $main_page, $schedule_page);
|
||||
$values['schedule_event_detail_url'] = sprintf("%ssummit/%s/%s/%s", Config::get("server.assets_base_url", 'https://www.openstack.org/'), $main_page, $schedule_page, 'events/:event_id/:event_title');
|
||||
|
||||
// summit types
|
||||
$summit_types = array();
|
||||
foreach ($summit->getSummitTypes() as $type) {
|
||||
$summit_types[] = SerializerRegistry::getInstance()->getSerializer($type)->serialize();
|
||||
}
|
||||
$values['summit_types'] = $summit_types;
|
||||
// tickets
|
||||
$ticket_types = array();
|
||||
foreach ($summit->getTicketTypes() as $ticket) {
|
||||
|
||||
@@ -35,7 +35,6 @@ class SummitTicketTypeSerializer extends SilverStripeSerializer
|
||||
{
|
||||
$values = parent::serialize($expand, $fields, $relations, $params);
|
||||
$ticket_type = $this->object;
|
||||
$values['allowed_summit_types'] = $ticket_type->getAllowedSummitTypeIds();
|
||||
return $values;
|
||||
}
|
||||
}
|
||||
@@ -114,9 +114,11 @@ class Presentation extends SummitEvent
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName(){
|
||||
return "Presentation";
|
||||
return self::ClassNamePresentation;
|
||||
}
|
||||
|
||||
const ClassNamePresentation = 'Presentation';
|
||||
|
||||
/**
|
||||
* @return PresentationSpeaker[]
|
||||
*/
|
||||
@@ -247,42 +249,6 @@ class Presentation extends SummitEvent
|
||||
$link->setPresentation($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCategoryId(){
|
||||
try {
|
||||
return !is_null($this->category)? $this->category->getId():0;
|
||||
}
|
||||
catch(\Exception $ex){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="PresentationCategory", fetch="EXTRA_LAZY")
|
||||
* @ORM\JoinColumn(name="CategoryID", referencedColumnName="ID")
|
||||
* @var PresentationCategory
|
||||
*/
|
||||
private $category = null;
|
||||
|
||||
/**
|
||||
* @param PresentationCategory $category
|
||||
* @return $this
|
||||
*/
|
||||
public function setCategory(PresentationCategory $category)
|
||||
{
|
||||
$this->category = $category;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PresentationCategory
|
||||
*/
|
||||
public function getCategory(){
|
||||
return $this->category;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
@@ -318,7 +284,6 @@ class Presentation extends SummitEvent
|
||||
$this->moderator = $moderator;
|
||||
}
|
||||
|
||||
|
||||
public function unsetModerator(){
|
||||
$this->moderator = null;
|
||||
}
|
||||
|
||||
@@ -87,13 +87,48 @@ class SummitEvent extends SilverstripeBaseModel
|
||||
$this->avg_feedback = 0;
|
||||
$this->head_count = 0;
|
||||
$this->tags = new ArrayCollection();
|
||||
$this->summit_types = new ArrayCollection();
|
||||
$this->feedback = new ArrayCollection();
|
||||
$this->attendees = new ArrayCollection();
|
||||
$this->sponsors = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="PresentationCategory", fetch="EXTRA_LAZY")
|
||||
* @ORM\JoinColumn(name="CategoryID", referencedColumnName="ID")
|
||||
* @var PresentationCategory
|
||||
*/
|
||||
private $category = null;
|
||||
|
||||
/**
|
||||
* @param PresentationCategory $category
|
||||
* @return $this
|
||||
*/
|
||||
public function setCategory(PresentationCategory $category)
|
||||
{
|
||||
$this->category = $category;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PresentationCategory
|
||||
*/
|
||||
public function getCategory(){
|
||||
return $this->category;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCategoryId(){
|
||||
try {
|
||||
return !is_null($this->category)? $this->category->getId():0;
|
||||
}
|
||||
catch(\Exception $ex){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Title", type="string")
|
||||
* @var string
|
||||
*/
|
||||
@@ -484,35 +519,6 @@ class SummitEvent extends SilverstripeBaseModel
|
||||
})->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="models\summit\SummitType", fetch="EXTRA_LAZY")
|
||||
* @ORM\JoinTable(name="SummitEvent_AllowedSummitTypes",
|
||||
* joinColumns={@ORM\JoinColumn(name="SummitEventID", referencedColumnName="ID")},
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="SummitTypeID", referencedColumnName="ID")}
|
||||
* )
|
||||
*/
|
||||
protected $summit_types;
|
||||
|
||||
/**
|
||||
* @return ArrayCollection
|
||||
*/
|
||||
public function getSummitTypes(){
|
||||
return $this->summit_types;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SummitType $summit_type
|
||||
*/
|
||||
public function addSummitType(SummitType $summit_type)
|
||||
{
|
||||
$this->summit_types->add($summit_type);
|
||||
}
|
||||
|
||||
public function clearSummitTypes()
|
||||
{
|
||||
$this->summit_types->clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="models\main\Company", inversedBy="sponsorships", fetch="EXTRA_LAZY")
|
||||
* @ORM\JoinTable(name="SummitEvent_Sponsors",
|
||||
|
||||
@@ -181,6 +181,41 @@ class Summit extends SilverstripeBaseModel
|
||||
*/
|
||||
private $schedule_default_start_date;
|
||||
|
||||
/**
|
||||
* @return SummitType
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SummitType $type
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTypeId(){
|
||||
try {
|
||||
return !is_null($this->type)? $this->type->getId():0;
|
||||
}
|
||||
catch(\Exception $ex){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="SummitType", fetch="EXTRA_LAZY")
|
||||
* @ORM\JoinColumn(name="TypeID", referencedColumnName="ID")
|
||||
* @var SummitType
|
||||
*/
|
||||
private $type = null;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@@ -240,7 +275,6 @@ class Summit extends SilverstripeBaseModel
|
||||
$this->locations = new ArrayCollection();
|
||||
$this->events = new ArrayCollection();
|
||||
$this->event_types = new ArrayCollection();
|
||||
$this->summit_types = new ArrayCollection();
|
||||
$this->ticket_types = new ArrayCollection();
|
||||
$this->presentation_categories = new ArrayCollection();
|
||||
$this->category_groups = new ArrayCollection();
|
||||
@@ -445,30 +479,6 @@ class Summit extends SilverstripeBaseModel
|
||||
return $event_type === false ? null:$event_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="models\summit\SummitType", mappedBy="summit", cascade={"persist"})
|
||||
*/
|
||||
private $summit_types;
|
||||
|
||||
/**
|
||||
* @return SummitType[]
|
||||
*/
|
||||
public function getSummitTypes()
|
||||
{
|
||||
return $this->summit_types;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $summit_type_id
|
||||
* @return SummitType
|
||||
*/
|
||||
public function getSummitType($summit_type_id)
|
||||
{
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('id', intval($summit_type_id)));
|
||||
$summit_type = $this->summit_types->matching($criteria)->first();
|
||||
return $summit_type === false ? null:$summit_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="models\summit\SummitTicketType", mappedBy="summit", cascade={"persist"})
|
||||
|
||||
@@ -86,35 +86,6 @@ class SummitTicketType extends SilverstripeBaseModel
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->allowed_summit_types = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="models\summit\SummitType")
|
||||
* @ORM\JoinTable(name="SummitTicketType_AllowedSummitTypes",
|
||||
* joinColumns={@ORM\JoinColumn(name="SummitTicketTypeID", referencedColumnName="ID")},
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="SummitTypeID", referencedColumnName="ID")}
|
||||
* )
|
||||
* @var SummitType[]
|
||||
*/
|
||||
private $allowed_summit_types;
|
||||
|
||||
/**
|
||||
* @return SummitType[]
|
||||
*/
|
||||
public function getAllowedSummitTypes()
|
||||
{
|
||||
return $this->allowed_summit_types;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int[]
|
||||
*/
|
||||
public function getAllowedSummitTypeIds()
|
||||
{
|
||||
return $this->allowed_summit_types->map(function($entity) {
|
||||
return $entity->getId();
|
||||
})->toArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,32 +24,25 @@ use Doctrine\ORM\Mapping AS ORM;
|
||||
*/
|
||||
class SummitType extends SilverstripeBaseModel
|
||||
{
|
||||
use SummitOwned;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Title", type="string")
|
||||
* @ORM\Column(name="FriendlyName", type="string")
|
||||
*/
|
||||
private $title;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Color", type="string")
|
||||
*/
|
||||
private $color;
|
||||
private $friendly_name;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTitle()
|
||||
public function getFriendlyName()
|
||||
{
|
||||
return $this->title;
|
||||
return $this->friendly_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $title
|
||||
* @param mixed $friendly_name
|
||||
*/
|
||||
public function setTitle($title)
|
||||
public function setFriendlyName($friendly_name)
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->friendly_name = $friendly_name;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,8 +77,55 @@ class SummitType extends SilverstripeBaseModel
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $description
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAudience()
|
||||
{
|
||||
return $this->audience;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $audience
|
||||
*/
|
||||
public function setAudience($audience)
|
||||
{
|
||||
$this->audience = $audience;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Color", type="string")
|
||||
*/
|
||||
private $color;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Type", type="string")
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Description", type="string")
|
||||
*/
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Audience", type="string")
|
||||
*/
|
||||
private $audience;
|
||||
}
|
||||
@@ -67,9 +67,13 @@ final class PresentationService implements IPresentationService
|
||||
|
||||
$presentation = $this->presentation_repository->getById($presentation_id);
|
||||
|
||||
|
||||
if(is_null($presentation))
|
||||
throw new EntityNotFoundException('presentation not found!');
|
||||
|
||||
if(!$presentation instanceof Presentation)
|
||||
throw new EntityNotFoundException('presentation not found!');
|
||||
|
||||
if($presentation->hasVideos())
|
||||
throw new ValidationException(sprintf('presentation %s already has a video!', $presentation_id));
|
||||
|
||||
@@ -100,6 +104,9 @@ final class PresentationService implements IPresentationService
|
||||
if(is_null($presentation))
|
||||
throw new EntityNotFoundException('presentation not found!');
|
||||
|
||||
if(!$presentation instanceof Presentation)
|
||||
throw new EntityNotFoundException('presentation not found!');
|
||||
|
||||
$video = $presentation->getVideoBy($video_id);
|
||||
|
||||
if(is_null($video))
|
||||
|
||||
@@ -366,6 +366,15 @@ final class SummitService implements ISummitService
|
||||
}
|
||||
}
|
||||
|
||||
$track = null;
|
||||
|
||||
if(isset($data['track_id'])){
|
||||
$track = $summit->getPresentationCategory(intval($data['track_id']));
|
||||
if(is_null($track)){
|
||||
throw new EntityNotFoundException(sprintf("track id %s does not exists!", $data['track_id']));
|
||||
}
|
||||
}
|
||||
|
||||
$location = null;
|
||||
if (isset($data['location_id'])) {
|
||||
$location = $summit->getLocation(intval($data['location_id']));
|
||||
@@ -374,17 +383,6 @@ final class SummitService implements ISummitService
|
||||
}
|
||||
}
|
||||
|
||||
$summit_types = array();
|
||||
if (isset($data['summit_types_id'])) {
|
||||
foreach ($data['summit_types_id'] as $summit_type_id) {
|
||||
$summit_type = $summit->getSummitType($summit_type_id);
|
||||
if (is_null($summit_type)) {
|
||||
throw new ValidationException(sprintf("summit type id %s does not exists!", $summit_type_id));
|
||||
}
|
||||
array_push($summit_types, $summit_type);
|
||||
}
|
||||
}
|
||||
|
||||
if (is_null($event_id)) {
|
||||
$event = SummitEventFactory::build($event_type);
|
||||
} else {
|
||||
@@ -411,6 +409,11 @@ final class SummitService implements ISummitService
|
||||
throw new ValidationException('type_id is mandatory!');
|
||||
}
|
||||
|
||||
if(!is_null($track))
|
||||
{
|
||||
$event->setCategory($track);
|
||||
}
|
||||
|
||||
// is event is new and we dont provide speakers ...
|
||||
if(is_null($event_id) && !is_null($event_type) && $event_type->isPresentationType() && !isset($data['speakers']))
|
||||
throw new ValidationException('speakers data is required for presentations!');
|
||||
@@ -440,13 +443,6 @@ final class SummitService implements ISummitService
|
||||
);
|
||||
}
|
||||
|
||||
if (count($summit_types) > 0) {
|
||||
$event->clearSummitTypes();
|
||||
foreach ($summit_types as $summit_type) {
|
||||
$event->addSummitType($summit_type);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['tags']) && count($data['tags']) > 0) {
|
||||
$event->clearTags();
|
||||
foreach ($data['tags'] as $str_tag) {
|
||||
|
||||
Reference in New Issue
Block a user