Updated summit document
added show_always field Change-Id: I1f77c1d796d80adf6e94a9e220c4bb89be6cfc57 Signed-off-by: smarcet <smarcet@gmail.com>
This commit is contained in:
parent
2dd658c778
commit
39fcfb3dd6
@ -88,6 +88,7 @@ class OAuth2SummitDocumentsApiController extends OAuth2ProtectedController
|
||||
'label' => 'required|string:512',
|
||||
'description' => 'nullable|string',
|
||||
'event_types' => 'sometimes|int_array',
|
||||
'show_always' => 'sometimes|boolean',
|
||||
];
|
||||
|
||||
// Creates a Validator instance and validates the data.
|
||||
@ -150,6 +151,7 @@ class OAuth2SummitDocumentsApiController extends OAuth2ProtectedController
|
||||
'label' => 'nullable|string:512',
|
||||
'description' => 'nullable|string',
|
||||
'event_types' => 'sometimes|int_array',
|
||||
'show_always' => 'sometimes|boolean',
|
||||
];
|
||||
|
||||
// Creates a Validator instance and validates the data.
|
||||
@ -173,6 +175,7 @@ class OAuth2SummitDocumentsApiController extends OAuth2ProtectedController
|
||||
$document_id,
|
||||
HTMLCleaner::cleanData($payload, $fields)
|
||||
);
|
||||
|
||||
return $this->updated(SerializerRegistry::getInstance()->getSerializer($document)->serialize());
|
||||
}
|
||||
catch (EntityNotFoundException $ex1)
|
||||
|
@ -23,6 +23,7 @@ class SummitDocumentSerializer extends SilverStripeSerializer
|
||||
protected static $array_mappings = [
|
||||
'Name' => 'name:json_string',
|
||||
'Description' => 'description:json_string',
|
||||
'ShowAlways' => 'show_always:json_boolean',
|
||||
'Label' => 'label:json_string',
|
||||
'SummitId' => 'summit_id:json_int',
|
||||
'FileUrl' => 'file:json_url',
|
||||
|
@ -37,10 +37,16 @@ final class SummitDocumentFactory
|
||||
public static function populate(Summit $summit, SummitDocument $document, array $payload):SummitDocument {
|
||||
if(isset($payload['name']))
|
||||
$document->setName(trim($payload['name']));
|
||||
|
||||
if(isset($payload['label']))
|
||||
$document->setLabel(trim($payload['label']));
|
||||
|
||||
if(isset($payload['show_always']))
|
||||
$document->setShowAlways(boolval($payload['show_always']));
|
||||
|
||||
if(isset($payload['description']))
|
||||
$document->setDescription(trim($payload['description']));
|
||||
|
||||
return $document;
|
||||
}
|
||||
}
|
@ -49,6 +49,12 @@ class SummitDocument extends SilverstripeBaseModel
|
||||
*/
|
||||
private $label;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="ShowAlways", type="boolean")
|
||||
* @var bool
|
||||
*/
|
||||
private $show_always;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\main\File", cascade={"persist","remove"})
|
||||
* @ORM\JoinColumn(name="FileID", referencedColumnName="ID")
|
||||
@ -77,6 +83,7 @@ class SummitDocument extends SilverstripeBaseModel
|
||||
$this->label = '';
|
||||
$this->description = '';
|
||||
$this->name = '';
|
||||
$this->show_always = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -195,4 +202,21 @@ class SummitDocument extends SilverstripeBaseModel
|
||||
return $fileUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isShowAlways(): bool
|
||||
{
|
||||
return $this->show_always;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $show_always
|
||||
*/
|
||||
public function setShowAlways(bool $show_always): void
|
||||
{
|
||||
$this->show_always = $show_always;
|
||||
}
|
||||
|
||||
|
||||
}
|
49
database/migrations/model/Version20210419181056.php
Normal file
49
database/migrations/model/Version20210419181056.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php namespace Database\Migrations\Model;
|
||||
/**
|
||||
* Copyright 2019 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\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema as Schema;
|
||||
use LaravelDoctrine\Migrations\Schema\Builder;
|
||||
use LaravelDoctrine\Migrations\Schema\Table;
|
||||
/**
|
||||
* Class Version20210419181056
|
||||
* @package Database\Migrations\Model
|
||||
*/
|
||||
class Version20210419181056 extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function up(Schema $schema):void
|
||||
{
|
||||
$builder = new Builder($schema);
|
||||
if($schema->hasTable("SummitDocument")) {
|
||||
$builder->table('SummitDocument', function (Table $table) {
|
||||
$table->boolean("ShowAlways")->setDefault(false)->setNotnull(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function down(Schema $schema):void
|
||||
{
|
||||
$builder = new Builder($schema);
|
||||
if($schema->hasTable("SummitDocument")) {
|
||||
$builder->table('SummitDocument', function (Table $table) {
|
||||
$table->dropColumn("ShowAlways");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user