Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhiltri committed Apr 21, 2022
2 parents 5a72694 + a43933a commit 0869ef0
Show file tree
Hide file tree
Showing 15 changed files with 210 additions and 35 deletions.
29 changes: 0 additions & 29 deletions app/Http/Controllers/LinkedArtController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public function showObject(Request $request, $id)
$this->getProduction($artwork),
$this->getDimensions($artwork),
$this->getMaterial($artwork),
$this->getSupportMaterial($artwork),
$this->getMaterialStatement($artwork),
$this->getDimensionStatement($artwork),
$this->getSubject($artwork),
Expand Down Expand Up @@ -280,34 +279,6 @@ private function getMaterial($artwork): array
];
}

private function getSupportMaterial($artwork): array
{
if (empty($artwork->support_aat_id)) {
return [];
}

return [
'part' => [
[
'type' => 'HumanMadeObject',
'classified_as' => [
[
'id' => 'http://vocab.getty.edu/aat/300014844',
'type' => 'Type',
'_label' => 'Support',
],
],
'made_of' => [
[
'id' => 'http://vocab.getty.edu/aat/' . $artwork->support_aat_id,
'type' => 'Material',
],
],
],
],
];
}

private function getMaterialStatement($artwork): array
{
if (empty($artwork->medium_display)) {
Expand Down
3 changes: 2 additions & 1 deletion app/Models/Transformable.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ protected function transformMapping()
{
$transformerClass = app('Resources')->getTransformerForModel(get_called_class());

$fields = (new $transformerClass())->getMappedFields();
// include `is_restricted` fields
$fields = (new $transformerClass(null, null, false))->getMappedFields();

// TODO: Fix references to transformMapping to use keys instead of 'name'
foreach ($fields as $fieldName => $fieldMapping) {
Expand Down
1 change: 1 addition & 0 deletions app/Models/Web/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ class Article extends WebModel
'publish_start_date' => 'datetime',
'publish_end_date' => 'datetime',
'agent_ids' => 'array',
'is_unlisted' => 'boolean',
];
}
1 change: 1 addition & 0 deletions app/Models/Web/Experience.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ class Experience extends WebModel
'archived' => 'boolean',
'kiosk_only' => 'boolean',
'published' => 'boolean',
'is_unlisted' => 'boolean',
];
}
1 change: 1 addition & 0 deletions app/Models/Web/Highlight.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ class Highlight extends WebModel
'published' => 'boolean',
'publish_start_date' => 'datetime',
'publish_end_date' => 'datetime',
'is_unlisted' => 'boolean',
];
}
12 changes: 9 additions & 3 deletions app/Models/Web/PressRelease.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@

namespace App\Models\Web;

use App\Models\WebModel;

/**
* A press release on the website
*/
class PressRelease extends Page
class PressRelease extends WebModel
{

protected $table = 'press_releases';
protected $casts = [
'publish_start_date' => 'datetime',
'publish_end_date' => 'datetime',
'is_published' => 'boolean',
'is_unlisted' => 'boolean',
];
}
1 change: 0 additions & 1 deletion app/Transformers/Inbound/Enhancer/Artwork.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class Artwork extends BaseTransformer
protected function getExtraFields(Datum $datum)
{
return [
'support_aat_id' => $datum->support_aat_id,
'dimension_width' => $datum->width,
'dimension_height' => $datum->height,
'linked_art_json' => $datum->linked_art_json,
Expand Down
1 change: 1 addition & 0 deletions app/Transformers/Outbound/Collections/Artwork.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ protected function getFields()
'type' => 'string',
'elasticsearch' => [
'default' => true,
'mapping' => $this->getDefaultStringMapping(true),
],
// API-235: Pull this from related place? For now, leaving as-is for performance.
// API-204: Eventually, this should be an array of all ancestor place names.
Expand Down
9 changes: 9 additions & 0 deletions app/Transformers/Outbound/Web/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ protected function getFields()
},
'is_restricted' => true,
],
'is_unlisted' => [
'doc' => 'Whether the article is unlisted',
'type' => 'boolean',
'elasticsearch' => 'boolean',
'value' => function ($item) {
return $item->is_unlisted;
},
'is_restricted' => true,
],
// TODO: Is this different from the CMS publish date?
'date' => [
'doc' => 'The date the article was published',
Expand Down
9 changes: 9 additions & 0 deletions app/Transformers/Outbound/Web/Experience.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ protected function getFields()
},
'is_restricted' => true,
],
'is_unlisted' => [
'doc' => 'Whether the experience is unlisted',
'type' => 'boolean',
'elasticsearch' => 'boolean',
'value' => function ($item) {
return $item->is_unlisted;
},
'is_restricted' => true,
],
'is_archived' => [
'doc' => 'Whether the experience has been archived',
'type' => 'boolean',
Expand Down
9 changes: 9 additions & 0 deletions app/Transformers/Outbound/Web/Highlight.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ protected function getFields()
'elasticsearch' => 'boolean',
'is_restricted' => true,
],
'is_unlisted' => [
'doc' => 'Whether the highlight is unlisted',
'type' => 'boolean',
'elasticsearch' => 'boolean',
'value' => function ($item) {
return $item->is_unlisted;
},
'is_restricted' => true,
],
'short_copy' => [
'doc' => 'A brief summary of what is contained in the highlight',
'type' => 'string',
Expand Down
97 changes: 97 additions & 0 deletions app/Transformers/Outbound/Web/PressRelease.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?php

namespace App\Transformers\Outbound\Web;

use App\Transformers\Outbound\Web\Traits\HasPublishDates;

use App\Transformers\Outbound\AbstractTransformer as BaseTransformer;

class PressRelease extends BaseTransformer
{

use HasPublishDates;

protected function getFields()
{
$sharedFields = [
// TODO: Ensure consistent naming and move to HasPublishDates
'is_published' => [
'doc' => 'Whether the page has been published',
'type' => 'boolean',
'elasticsearch' => 'boolean',
'value' => function ($item) {
return $item->published;
},
'is_restricted' => true,
],
'is_unlisted' => [
'doc' => 'Whether the press release is unlisted',
'type' => 'boolean',
'elasticsearch' => 'boolean',
'value' => function ($item) {
return $item->is_unlisted;
},
'is_restricted' => true,
],
// TODO: This seems to always be null. Remove?
'type' => [
'doc' => 'The type of page this record represents',
'type' => 'string',
'elasticsearch' => 'keyword',
],

'web_url' => [
'doc' => 'The URL to this page on our website',
'type' => 'string',
'elasticsearch' => 'keyword',
],
'slug' => [
'doc' => 'A human-readable string used in the URL',
'type' => 'string',
'elasticsearch' => 'keyword',
],

// TODO: This also seems to always be null. Audit?
'image_url' => [
'doc' => 'The URL of an image representing this page',
'type' => 'string',
'elasticsearch' => 'keyword',
],

// TODO: Give option to put long fields last?
// TODO: Combine `listing_description` and `short_description`?
'listing_description' => [
'doc' => 'A brief description of the page used in listings',
'type' => 'string',
'elasticsearch' => 'text',
],
'short_description' => [
'doc' => 'A brief description of the page used in mobile and meta tags',
'type' => 'string',
'elasticsearch' => 'text',
],
'copy' => [
'doc' => 'The text of the page',
'type' => 'string',
'elasticsearch' => [
'default' => true,
],
],
];

return array_merge(
$sharedFields,
$this->getPageFields()
);
}

/**
* Provide a way for child classes to add fields to the transformation.
*
* @return array
*/
protected function getPageFields()
{
return [];
}
}
2 changes: 1 addition & 1 deletion config/resources/outbound.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@
[
'endpoint' => 'press-releases',
'model' => \App\Models\Web\PressRelease::class,
'transformer' => \App\Transformers\Outbound\Web\Page::class,
'transformer' => \App\Transformers\Outbound\Web\PressRelease::class,
'is_searchable' => true,
],
[
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class DropSupportAatIdFromArtworks extends Migration
{
public function up()
{
Schema::table('artworks', function (Blueprint $table) {
$table->dropColumn([
'support_aat_id',
]);
});
}

public function down()
{
Schema::table('artworks', function (Blueprint $table) {
$table->integer('support_aat_id')->signed()->nullable()->after('medium_display');
});
}
}
46 changes: 46 additions & 0 deletions database/migrations/2022_04_18_130811_add_is_unlisted_columns.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddIsUnlistedColumns extends Migration
{
public function up()
{
Schema::table('articles', function (Blueprint $table) {
$table->boolean('is_unlisted')->default(false);
});

Schema::table('experiences', function (Blueprint $table) {
$table->boolean('is_unlisted')->default(false);
});

Schema::table('highlights', function (Blueprint $table) {
$table->boolean('is_unlisted')->default(false);
});

Schema::table('press_releases', function (Blueprint $table) {
$table->boolean('is_unlisted')->default(false);
});
}

public function down()
{
Schema::table('articles', function (Blueprint $table) {
$table->dropColumn('is_unlisted');
});

Schema::table('experiences', function (Blueprint $table) {
$table->dropColumn('is_unlisted');
});

Schema::table('highlights', function (Blueprint $table) {
$table->dropColumn('is_unlisted');
});

Schema::table('press_releases', function (Blueprint $table) {
$table->dropColumn('is_unlisted');
});
}
}

0 comments on commit 0869ef0

Please sign in to comment.