Add Special Notes field to artwork

This commit is contained in:
Alex Cabal 2024-01-10 13:41:15 -06:00
parent 1237a65bc8
commit 60eb118524
5 changed files with 29 additions and 6 deletions

View file

@ -19,6 +19,7 @@ CREATE TABLE `Artworks` (
`EbookWwwFilesystemPath` varchar(255) NULL, `EbookWwwFilesystemPath` varchar(255) NULL,
`MimeType` varchar(64) NOT NULL, `MimeType` varchar(64) NOT NULL,
`Exception` TEXT NULL DEFAULT NULL, `Exception` TEXT NULL DEFAULT NULL,
`Notes` TEXT NULL DEFAULT NULL
PRIMARY KEY (`ArtworkId`), PRIMARY KEY (`ArtworkId`),
KEY `index1` (`Status`), KEY `index1` (`Status`),
KEY `index2` (`UrlName`) KEY `index2` (`UrlName`)

View file

@ -46,6 +46,7 @@ class Artwork extends PropertiesBase{
public ?string $ArtworkPageUrl = null; public ?string $ArtworkPageUrl = null;
public ?bool $IsPublishedInUs = null; public ?bool $IsPublishedInUs = null;
public ?string $Exception = null; public ?string $Exception = null;
public ?string $Notes = null;
protected ?string $_UrlName = null; protected ?string $_UrlName = null;
protected ?string $_Url = null; protected ?string $_Url = null;
protected $_Tags = null; protected $_Tags = null;
@ -268,6 +269,10 @@ class Artwork extends PropertiesBase{
$this->Exception = null; $this->Exception = null;
} }
if($this->Notes !== null && trim($this->Notes) == ''){
$this->Notes = null;
}
if($this->Name === null || $this->Name == ''){ if($this->Name === null || $this->Name == ''){
$error->Add(new Exceptions\ArtworkNameRequiredException()); $error->Add(new Exceptions\ArtworkNameRequiredException());
} }
@ -564,7 +569,7 @@ class Artwork extends PropertiesBase{
INSERT into INSERT into
Artworks (ArtistId, Name, UrlName, CompletedYear, CompletedYearIsCirca, Created, Status, SubmitterUserId, ReviewerUserId, MuseumUrl, Artworks (ArtistId, Name, UrlName, CompletedYear, CompletedYearIsCirca, Created, Status, SubmitterUserId, ReviewerUserId, MuseumUrl,
PublicationYear, PublicationYearPageUrl, CopyrightPageUrl, ArtworkPageUrl, IsPublishedInUs, PublicationYear, PublicationYearPageUrl, CopyrightPageUrl, ArtworkPageUrl, IsPublishedInUs,
EbookWwwFilesystemPath, MimeType, Exception) EbookWwwFilesystemPath, MimeType, Exception, Notes)
values (?, values (?,
?, ?,
?, ?,
@ -582,10 +587,11 @@ class Artwork extends PropertiesBase{
?, ?,
?, ?,
?, ?,
?,
?) ?)
', [$this->Artist->ArtistId, $this->Name, $this->UrlName, $this->CompletedYear, $this->CompletedYearIsCirca, ', [$this->Artist->ArtistId, $this->Name, $this->UrlName, $this->CompletedYear, $this->CompletedYearIsCirca,
$this->Created, $this->Status, $this->SubmitterUserId, $this->ReviewerUserId, $this->MuseumUrl, $this->PublicationYear, $this->PublicationYearPageUrl, $this->Created, $this->Status, $this->SubmitterUserId, $this->ReviewerUserId, $this->MuseumUrl, $this->PublicationYear, $this->PublicationYearPageUrl,
$this->CopyrightPageUrl, $this->ArtworkPageUrl, $this->IsPublishedInUs, $this->EbookWwwFilesystemPath, $this->MimeType->value ?? null, $this->Exception] $this->CopyrightPageUrl, $this->ArtworkPageUrl, $this->IsPublishedInUs, $this->EbookWwwFilesystemPath, $this->MimeType->value ?? null, $this->Exception, $this->Notes]
); );
$this->ArtworkId = Db::GetLastInsertedId(); $this->ArtworkId = Db::GetLastInsertedId();
@ -640,12 +646,13 @@ class Artwork extends PropertiesBase{
IsPublishedInUs = ?, IsPublishedInUs = ?,
EbookWwwFilesystemPath = ?, EbookWwwFilesystemPath = ?,
MimeType = ?, MimeType = ?,
Exception = ? Exception = ?,
Notes = ?
where where
ArtworkId = ? ArtworkId = ?
', [$this->Artist->ArtistId, $this->Name, $this->UrlName, $this->CompletedYear, $this->CompletedYearIsCirca, ', [$this->Artist->ArtistId, $this->Name, $this->UrlName, $this->CompletedYear, $this->CompletedYearIsCirca,
$this->Created, $this->Status, $this->SubmitterUserId, $this->ReviewerUserId, $this->MuseumUrl, $this->PublicationYear, $this->PublicationYearPageUrl, $this->Created, $this->Status, $this->SubmitterUserId, $this->ReviewerUserId, $this->MuseumUrl, $this->PublicationYear, $this->PublicationYearPageUrl,
$this->CopyrightPageUrl, $this->ArtworkPageUrl, $this->IsPublishedInUs, $this->EbookWwwFilesystemPath, $this->MimeType->value ?? null, $this->Exception, $this->CopyrightPageUrl, $this->ArtworkPageUrl, $this->IsPublishedInUs, $this->EbookWwwFilesystemPath, $this->MimeType->value ?? null, $this->Exception, $this->Notes,
$this->ArtworkId] $this->ArtworkId]
); );
} }

View file

@ -119,10 +119,15 @@ catch(Exceptions\ArtworkNotFoundException){
<? } ?> <? } ?>
<? if($artwork->Exception !== null){ ?> <? if($artwork->Exception !== null){ ?>
<h3>Special public domain exception</h3> <h3>Public domain status exception reason</h3>
<?= Formatter::EscapeMarkdown($artwork->Exception) ?> <?= Formatter::EscapeMarkdown($artwork->Exception) ?>
<? } ?> <? } ?>
<? if($artwork->Notes !== null){ ?>
<h2>Special notes</h2>
<?= Formatter::EscapeMarkdown($artwork->Notes) ?>
<? } ?>
<? if($isAdminView){ ?> <? if($isAdminView){ ?>
<h2>Reviewer options</h2> <h2>Reviewer options</h2>
<p>Review the metadata and PD proof for this artwork submission. Approve to make it available for future producers.</p> <p>Review the metadata and PD proof for this artwork submission. Approve to make it available for future producers.</p>

View file

@ -217,12 +217,20 @@ catch(Exceptions\InvalidPermissionsException){
<p><strong>or</strong> a reason for a special exception:</p> <p><strong>or</strong> a reason for a special exception:</p>
<fieldset> <fieldset>
<label> <label>
<span>Exception reason</span> <span>Public domain status exception reason</span>
<span>Markdown accepted.</span> <span>Markdown accepted.</span>
<textarea maxlength="1024" name="artwork-exception"><?= Formatter::ToPlainText($artwork->Exception) ?></textarea> <textarea maxlength="1024" name="artwork-exception"><?= Formatter::ToPlainText($artwork->Exception) ?></textarea>
</label> </label>
</fieldset> </fieldset>
</fieldset> </fieldset>
<fieldset>
<legend>Other details</legend>
<label>
<span>Special notes</span>
<span>Any notes to remember about this artwork. Markdown accepted.</span>
<textarea maxlength="1024" name="artwork-notes"><?= Formatter::ToPlainText($artwork->Notes) ?></textarea>
</label>
</fieldset>
<? if($GLOBALS['User']->Benefits->CanReviewArtwork){ ?> <? if($GLOBALS['User']->Benefits->CanReviewArtwork){ ?>
<fieldset> <fieldset>
<legend>Reviewer options</legend> <legend>Reviewer options</legend>

View file

@ -42,6 +42,7 @@ try{
$artwork->MuseumUrl = HttpInput::Str(POST, 'artwork-museum-url', false); $artwork->MuseumUrl = HttpInput::Str(POST, 'artwork-museum-url', false);
$artwork->MimeType = ImageMimeType::FromFile($_FILES['artwork-image']['tmp_name'] ?? null); $artwork->MimeType = ImageMimeType::FromFile($_FILES['artwork-image']['tmp_name'] ?? null);
$artwork->Exception = HttpInput::Str(POST, 'artwork-exception', false); $artwork->Exception = HttpInput::Str(POST, 'artwork-exception', false);
$artwork->Notes = HttpInput::Str(POST, 'artwork-notes', false);
// Only approved reviewers can set the status to anything but unverified when uploading // Only approved reviewers can set the status to anything but unverified when uploading
if($artwork->Status != COVER_ARTWORK_STATUS_UNVERIFIED && !$GLOBALS['User']->Benefits->CanReviewArtwork){ if($artwork->Status != COVER_ARTWORK_STATUS_UNVERIFIED && !$GLOBALS['User']->Benefits->CanReviewArtwork){
@ -86,6 +87,7 @@ try{
$artwork->ArtworkPageUrl = HttpInput::Str(POST, 'artwork-artwork-page-url', false) ?? $artwork->ArtworkPageUrl; $artwork->ArtworkPageUrl = HttpInput::Str(POST, 'artwork-artwork-page-url', false) ?? $artwork->ArtworkPageUrl;
$artwork->MuseumUrl = HttpInput::Str(POST, 'artwork-museum-url', false) ?? $artwork->MuseumUrl; $artwork->MuseumUrl = HttpInput::Str(POST, 'artwork-museum-url', false) ?? $artwork->MuseumUrl;
$artwork->Exception = HttpInput::Str(POST, 'artwork-exception', false) ?? $artwork->Exception; $artwork->Exception = HttpInput::Str(POST, 'artwork-exception', false) ?? $artwork->Exception;
$artwork->Notes = HttpInput::Str(POST, 'artwork-notes', false) ?? $artwork->Notes;
$artwork->ReviewerUserId = $GLOBALS['User']->UserId; $artwork->ReviewerUserId = $GLOBALS['User']->UserId;