From 1d0b328c69264b0ee69936130d8a03088bd50288 Mon Sep 17 00:00:00 2001 From: Thanasis Mpalatsoukas Date: Sat, 17 Jun 2023 17:23:23 +0300 Subject: [PATCH 01/14] feat: added copyright on base_album Bringing the data of copyright to the frontend and adding a new route on api.php to edit the copyright value. --- app/Contracts/Http/Requests/HasCopyright.php | 11 ++++++ .../Http/Requests/RequestAttribute.php | 2 + app/Http/Controllers/AlbumController.php | 16 ++++++++ .../Album/SetAlbumCopyrightRequest.php | 38 +++++++++++++++++++ .../Requests/Traits/HasCopyrightTrait.php | 16 ++++++++ app/Http/Resources/Models/AlbumResource.php | 1 + .../Album/SetAlbumCopyrightRuleSet.php | 25 ++++++++++++ app/Rules/CopyrightRule.php | 11 ++++++ .../2021_12_04_181200_refactor_models.php | 1 + routes/api.php | 1 + 10 files changed, 122 insertions(+) create mode 100644 app/Contracts/Http/Requests/HasCopyright.php create mode 100644 app/Http/Requests/Album/SetAlbumCopyrightRequest.php create mode 100644 app/Http/Requests/Traits/HasCopyrightTrait.php create mode 100644 app/Http/RuleSets/Album/SetAlbumCopyrightRuleSet.php create mode 100644 app/Rules/CopyrightRule.php diff --git a/app/Contracts/Http/Requests/HasCopyright.php b/app/Contracts/Http/Requests/HasCopyright.php new file mode 100644 index 0000000000..c6eb4d601f --- /dev/null +++ b/app/Contracts/Http/Requests/HasCopyright.php @@ -0,0 +1,11 @@ +album()->save(); } + /** + * Change the description of the album. + * + * @param SetAlbumDescriptionRequest $request + * + * @return void + * + * @throws ModelDBException + */ + public function setCopyright(SetAlbumCopyrightRequest $request): void + { + $request->album()->copyright = $request->copyright(); + $request->album()->save(); + } + /** * Change show tags of the tag album. * diff --git a/app/Http/Requests/Album/SetAlbumCopyrightRequest.php b/app/Http/Requests/Album/SetAlbumCopyrightRequest.php new file mode 100644 index 0000000000..d4c5192558 --- /dev/null +++ b/app/Http/Requests/Album/SetAlbumCopyrightRequest.php @@ -0,0 +1,38 @@ +album = $this->albumFactory->findBaseAlbumsOrFail( + $values[RequestAttribute::ALBUM_IDS_ATTRIBUTE], false + ); + $this->copyright = $values[RequestAttribute::COPYRIGHT_ATTRIBUTE]; + } +} diff --git a/app/Http/Requests/Traits/HasCopyrightTrait.php b/app/Http/Requests/Traits/HasCopyrightTrait.php new file mode 100644 index 0000000000..ab903ed344 --- /dev/null +++ b/app/Http/Requests/Traits/HasCopyrightTrait.php @@ -0,0 +1,16 @@ +copyright; + } +} diff --git a/app/Http/Resources/Models/AlbumResource.php b/app/Http/Resources/Models/AlbumResource.php index 76fd35b4b7..6613f94795 100644 --- a/app/Http/Resources/Models/AlbumResource.php +++ b/app/Http/Resources/Models/AlbumResource.php @@ -36,6 +36,7 @@ public function toArray($request) 'id' => $this->resource->id, 'title' => $this->resource->title, 'owner_name' => $this->when(Auth::check(), $this->resource->owner->name), + 'copyright' => $this->resource->copyright, // attributes 'description' => $this->resource->description, diff --git a/app/Http/RuleSets/Album/SetAlbumCopyrightRuleSet.php b/app/Http/RuleSets/Album/SetAlbumCopyrightRuleSet.php new file mode 100644 index 0000000000..2a024e2de4 --- /dev/null +++ b/app/Http/RuleSets/Album/SetAlbumCopyrightRuleSet.php @@ -0,0 +1,25 @@ + ['required', new RandomIDRule(false)], + RequestAttribute::COPYRIGHT_ATTRIBUTE => ['required', new CopyrightRule()], + ]; + } +} diff --git a/app/Rules/CopyrightRule.php b/app/Rules/CopyrightRule.php new file mode 100644 index 0000000000..7db79cb9f3 --- /dev/null +++ b/app/Rules/CopyrightRule.php @@ -0,0 +1,11 @@ +string('password', 100)->nullable()->default(null); $table->string('sorting_col', 30)->nullable()->default(null); $table->string('sorting_order', 4)->nullable()->default(null); + $table->string('copyright', 300)->nullable()->default(null); // Indices and constraint definitions $table->primary('id'); $table->unique('legacy_id'); diff --git a/routes/api.php b/routes/api.php index 433760831e..50f83bcef2 100644 --- a/routes/api.php +++ b/routes/api.php @@ -38,6 +38,7 @@ Route::post('/Album::setTitle', [AlbumController::class, 'setTitle']); Route::post('/Album::setNSFW', [AlbumController::class, 'setNSFW']); Route::post('/Album::setDescription', [AlbumController::class, 'setDescription']); +Route::post('/Album::setCopyright', [AlbumController::class, 'setCopyright']); Route::post('/Album::setCover', [AlbumController::class, 'setCover']); Route::post('/Album::setShowTags', [AlbumController::class, 'setShowTags']); Route::post('/Album::setProtectionPolicy', [AlbumController::class, 'setProtectionPolicy']); From 5f0fcd7c0fa53a722c4a00a0e47e7019d4b9a574 Mon Sep 17 00:00:00 2001 From: Thanasis Mpalatsoukas Date: Sat, 17 Jun 2023 17:34:59 +0300 Subject: [PATCH 02/14] fix: fixed some spelling mistakes. --- app/Http/Controllers/AlbumController.php | 4 ++-- app/Http/RuleSets/Album/SetAlbumCopyrightRuleSet.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/AlbumController.php b/app/Http/Controllers/AlbumController.php index 737e276796..c90a964d4a 100644 --- a/app/Http/Controllers/AlbumController.php +++ b/app/Http/Controllers/AlbumController.php @@ -188,9 +188,9 @@ public function setDescription(SetAlbumDescriptionRequest $request): void } /** - * Change the description of the album. + * Change the copyright of the album. * - * @param SetAlbumDescriptionRequest $request + * @param SetAlbumCopyrightRequest $request * * @return void * diff --git a/app/Http/RuleSets/Album/SetAlbumCopyrightRuleSet.php b/app/Http/RuleSets/Album/SetAlbumCopyrightRuleSet.php index 2a024e2de4..f0f89ea395 100644 --- a/app/Http/RuleSets/Album/SetAlbumCopyrightRuleSet.php +++ b/app/Http/RuleSets/Album/SetAlbumCopyrightRuleSet.php @@ -8,7 +8,7 @@ use App\Rules\RandomIDRule; /** - * Rules applied when updating the titles of a group of album. + * Rules applied when updating the copyright of an album. */ class SetAlbumCopyrightRuleSet implements RuleSet { From 608346a363d1fb3b609cf7c92c052e921110456e Mon Sep 17 00:00:00 2001 From: Sakis bal <43223812+ThanasisMpalatsoukas@users.noreply.github.com> Date: Sun, 18 Jun 2023 11:41:50 +0300 Subject: [PATCH 03/14] Update app/Http/Requests/Album/SetAlbumCopyrightRequest.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Benoît Viguier --- app/Http/Requests/Album/SetAlbumCopyrightRequest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Requests/Album/SetAlbumCopyrightRequest.php b/app/Http/Requests/Album/SetAlbumCopyrightRequest.php index d4c5192558..22f00c470b 100644 --- a/app/Http/Requests/Album/SetAlbumCopyrightRequest.php +++ b/app/Http/Requests/Album/SetAlbumCopyrightRequest.php @@ -30,7 +30,7 @@ public function rules(): array */ protected function processValidatedValues(array $values, array $files): void { - $this->album = $this->albumFactory->findBaseAlbumsOrFail( + $this->album = $this->albumFactory->findBaseAlbumOrFail( $values[RequestAttribute::ALBUM_IDS_ATTRIBUTE], false ); $this->copyright = $values[RequestAttribute::COPYRIGHT_ATTRIBUTE]; From 896e203f6d7f0645e6702b52b7e9bce718c2f6b7 Mon Sep 17 00:00:00 2001 From: Thanasis Mpalatsoukas Date: Sun, 18 Jun 2023 20:05:50 +0300 Subject: [PATCH 04/14] fix: added basic localization, properties and tests tested for editing the copyright value. Creating a different endpoint for removing copyright might not be necessary as the copyright value can be edited to be "". --- .../Album/SetAlbumCopyrightRequest.php | 2 +- app/Models/BaseAlbumImpl.php | 2 ++ app/Models/Extensions/BaseAlbum.php | 1 + lang/de/lychee.php | 2 ++ lang/el/lychee.php | 2 ++ lang/en/lychee.php | 2 ++ lang/es/lychee.php | 2 ++ lang/fr/lychee.php | 2 ++ lang/it/lychee.php | 2 ++ lang/nl/lychee.php | 2 ++ lang/no/lychee.php | 2 ++ lang/pl/lychee.php | 2 ++ lang/pt/lychee.php | 2 ++ lang/ru/lychee.php | 2 ++ tests/Feature/AlbumTest.php | 12 +++++++++ tests/Feature/LibUnitTests/AlbumsUnitTest.php | 25 +++++++++++++++++++ 16 files changed, 63 insertions(+), 1 deletion(-) diff --git a/app/Http/Requests/Album/SetAlbumCopyrightRequest.php b/app/Http/Requests/Album/SetAlbumCopyrightRequest.php index 22f00c470b..04b57c8321 100644 --- a/app/Http/Requests/Album/SetAlbumCopyrightRequest.php +++ b/app/Http/Requests/Album/SetAlbumCopyrightRequest.php @@ -31,7 +31,7 @@ public function rules(): array protected function processValidatedValues(array $values, array $files): void { $this->album = $this->albumFactory->findBaseAlbumOrFail( - $values[RequestAttribute::ALBUM_IDS_ATTRIBUTE], false + $values[RequestAttribute::ALBUM_ID_ATTRIBUTE], false ); $this->copyright = $values[RequestAttribute::COPYRIGHT_ATTRIBUTE]; } diff --git a/app/Models/BaseAlbumImpl.php b/app/Models/BaseAlbumImpl.php index 9a9bac9730..f419027341 100644 --- a/app/Models/BaseAlbumImpl.php +++ b/app/Models/BaseAlbumImpl.php @@ -108,6 +108,7 @@ * @property AccessPermission|null $public_permissions * @property int|null $access_permissions_count * @property AccessPermission|null $current_user_permissions + * @property string|null $copyright * * @method static BaseAlbumImplBuilder|BaseAlbumImpl addSelect($column) * @method static BaseAlbumImplBuilder|BaseAlbumImpl join(string $table, string $first, string $operator = null, string $second = null, string $type = 'inner', string $where = false) @@ -177,6 +178,7 @@ class BaseAlbumImpl extends Model implements HasRandomID 'owner_id' => 0, 'sorting_col' => null, 'sorting_order' => null, + 'copyright' => null, // Special visibility attributes 'is_nsfw' => false, ]; diff --git a/app/Models/Extensions/BaseAlbum.php b/app/Models/Extensions/BaseAlbum.php index c161d481db..1e2f2079bb 100644 --- a/app/Models/Extensions/BaseAlbum.php +++ b/app/Models/Extensions/BaseAlbum.php @@ -30,6 +30,7 @@ * @property Carbon $updated_at * @property string|null $description * @property bool $is_nsfw + * @property string|null $copyright * @property int $owner_id * @property User $owner * @property Collection $access_permissions diff --git a/lang/de/lychee.php b/lang/de/lychee.php index 49875cfc1b..67aa44eb8d 100644 --- a/lang/de/lychee.php +++ b/lang/de/lychee.php @@ -151,6 +151,8 @@ 'ALBUM_ABOUT' => 'Über', 'ALBUM_BASICS' => 'Grundlegende Informationen', 'ALBUM_TITLE' => 'Titel', + 'ALBUM_COPYRIGHT' => '', + 'ALBUM_SET_COPYRIGHT' => '', 'ALBUM_NEW_TITLE' => 'Geben Sie einen neuen Titel für dieses Album ein:', 'ALBUMS_NEW_TITLE' => 'Geben Sie einen Titel für alle %d ausgewählten Alben ein:', 'ALBUM_SET_TITLE' => 'Titel speichern', diff --git a/lang/el/lychee.php b/lang/el/lychee.php index 4c8b3b9b2c..b33bcbedd5 100644 --- a/lang/el/lychee.php +++ b/lang/el/lychee.php @@ -151,6 +151,8 @@ 'ALBUM_ABOUT' => 'Περί', 'ALBUM_BASICS' => 'Βασικές Πληροφορίες', 'ALBUM_TITLE' => 'Τίτλος', + 'ALBUM_COPYRIGHT' => 'Πνευματική ιδιοκτησία', + 'ALBUM_SET_COPYRIGHT' => 'Δήλωσε πνευματική ιδιοκτησία', 'ALBUM_NEW_TITLE' => 'Εισάγετε έναν νέο τίτλο για αυτό το Λεύκωμα:', 'ALBUMS_NEW_TITLE' => 'Εισάγετε νέο τίτλο για όλα %d τα επιλεγμένα λευκώματα:', 'ALBUM_SET_TITLE' => 'Ορίστε Τίτλο', diff --git a/lang/en/lychee.php b/lang/en/lychee.php index fe52f67857..d81b063d81 100644 --- a/lang/en/lychee.php +++ b/lang/en/lychee.php @@ -151,6 +151,8 @@ 'ALBUM_ABOUT' => 'About', 'ALBUM_BASICS' => 'Basics', 'ALBUM_TITLE' => 'Title', + 'ALBUM_COPYRIGHT' => 'Copyright', + 'ALBUM_SET_COPYRIGHT' => 'Set copyright', 'ALBUM_NEW_TITLE' => 'Enter a new title for this album:', 'ALBUMS_NEW_TITLE' => 'Enter a title for all %d selected albums:', 'ALBUM_SET_TITLE' => 'Set Title', diff --git a/lang/es/lychee.php b/lang/es/lychee.php index 40f2ed59af..d2316404b5 100644 --- a/lang/es/lychee.php +++ b/lang/es/lychee.php @@ -151,6 +151,8 @@ 'ALBUM_ABOUT' => 'Acerca de', 'ALBUM_BASICS' => 'Básico', 'ALBUM_TITLE' => 'Título', + 'ALBUM_COPYRIGHT' => '', + 'ALBUM_SET_COPYRIGHT' => '', 'ALBUM_NEW_TITLE' => 'Ingrese un nuevo título para este álbum:', 'ALBUMS_NEW_TITLE' => 'Ingrese un título para todos %d álbumes seleccionados:', 'ALBUM_SET_TITLE' => 'Establecer Título', diff --git a/lang/fr/lychee.php b/lang/fr/lychee.php index 413dab30ef..cd07e6a4af 100644 --- a/lang/fr/lychee.php +++ b/lang/fr/lychee.php @@ -151,6 +151,8 @@ 'ALBUM_ABOUT' => 'À propos', 'ALBUM_BASICS' => 'Informations de base', 'ALBUM_TITLE' => 'Titre', + 'ALBUM_COPYRIGHT' => '', + 'ALBUM_SET_COPYRIGHT' => '', 'ALBUM_NEW_TITLE' => 'Entrez un nouveau titre pour cet album :', 'ALBUMS_NEW_TITLE' => 'Entrez un titre pour les %d albums sélectionnés :', 'ALBUM_SET_TITLE' => 'Enregistrer le titre', diff --git a/lang/it/lychee.php b/lang/it/lychee.php index a562eeb3a8..80ec0efa31 100644 --- a/lang/it/lychee.php +++ b/lang/it/lychee.php @@ -151,6 +151,8 @@ 'ALBUM_ABOUT' => 'Informazioni', 'ALBUM_BASICS' => 'Base', 'ALBUM_TITLE' => 'Titolo', + 'ALBUM_COPYRIGHT' => '', + 'ALBUM_SET_COPYRIGHT' => '', 'ALBUM_NEW_TITLE' => 'Inserire un nuovo titolo per questo album:', 'ALBUMS_NEW_TITLE' => 'Inserire un nuovo titolo per %d gli album selezionati:', 'ALBUM_SET_TITLE' => 'Imposta Titolo', diff --git a/lang/nl/lychee.php b/lang/nl/lychee.php index 92bfc89d8d..ef76c31c6e 100644 --- a/lang/nl/lychee.php +++ b/lang/nl/lychee.php @@ -151,6 +151,8 @@ 'ALBUM_ABOUT' => 'Over', 'ALBUM_BASICS' => 'Basics', 'ALBUM_TITLE' => 'Titel', + 'ALBUM_COPYRIGHT' => '', + 'ALBUM_SET_COPYRIGHT' => '', 'ALBUM_NEW_TITLE' => 'Geef dit album een nieuwe titel:', 'ALBUMS_NEW_TITLE' => 'Geef alle geselecteerde %d albums een nieuwe titel:', 'ALBUM_SET_TITLE' => 'Sla Titel op', diff --git a/lang/no/lychee.php b/lang/no/lychee.php index 199338b445..0e592a3708 100644 --- a/lang/no/lychee.php +++ b/lang/no/lychee.php @@ -151,6 +151,8 @@ 'ALBUM_ABOUT' => 'Om', 'ALBUM_BASICS' => 'Grunnleggende', 'ALBUM_TITLE' => 'Tittel', + 'ALBUM_COPYRIGHT' => '', + 'ALBUM_SET_COPYRIGHT' => '', 'ALBUM_NEW_TITLE' => 'Legg inn en ny tittel for Albumet:', 'ALBUMS_NEW_TITLE' => 'Legg inn en ny tittel for %d valgte album:', 'ALBUM_SET_TITLE' => 'Lagre Tittel', diff --git a/lang/pl/lychee.php b/lang/pl/lychee.php index 2b58c23402..6e8b2f4039 100644 --- a/lang/pl/lychee.php +++ b/lang/pl/lychee.php @@ -151,6 +151,8 @@ 'ALBUM_ABOUT' => 'Informacje o albumie', 'ALBUM_BASICS' => 'Informacje podstawowe', 'ALBUM_TITLE' => 'Tytuł', + 'ALBUM_COPYRIGHT' => '', + 'ALBUM_SET_COPYRIGHT' => '', 'ALBUM_NEW_TITLE' => 'Edytuj tytuł albumu:', 'ALBUMS_NEW_TITLE' => 'Wpisz tytuł dla %d wybranych albumów:', 'ALBUM_SET_TITLE' => 'Zapisz', diff --git a/lang/pt/lychee.php b/lang/pt/lychee.php index d0de3ea043..d8c7d2d3a3 100644 --- a/lang/pt/lychee.php +++ b/lang/pt/lychee.php @@ -151,6 +151,8 @@ 'ALBUM_ABOUT' => 'Acerca de', 'ALBUM_BASICS' => 'Básicos', 'ALBUM_TITLE' => 'Título', + 'ALBUM_COPYRIGHT' => '', + 'ALBUM_SET_COPYRIGHT' => '', 'ALBUM_NEW_TITLE' => 'Inserir novo título para este álbum:', 'ALBUMS_NEW_TITLE' => 'Inserir um título para todos %d álbums selecionados:', 'ALBUM_SET_TITLE' => 'Escolher Título', diff --git a/lang/ru/lychee.php b/lang/ru/lychee.php index 6621ff5e8a..e36594dfc9 100644 --- a/lang/ru/lychee.php +++ b/lang/ru/lychee.php @@ -151,6 +151,8 @@ 'ALBUM_ABOUT' => 'Об альбоме', 'ALBUM_BASICS' => 'Основное', 'ALBUM_TITLE' => 'Заголовок', + 'ALBUM_COPYRIGHT' => '', + 'ALBUM_SET_COPYRIGHT' => '', 'ALBUM_NEW_TITLE' => 'Новый заголовок альбома:', 'ALBUMS_NEW_TITLE' => 'Введите заголовок для всех %d выбранных альбомов:', 'ALBUM_SET_TITLE' => 'Сохранить заголовок', diff --git a/tests/Feature/AlbumTest.php b/tests/Feature/AlbumTest.php index 952594ee13..35050529ad 100644 --- a/tests/Feature/AlbumTest.php +++ b/tests/Feature/AlbumTest.php @@ -628,6 +628,18 @@ public function testEditAlbumByOwner(): void $this->albums_tests->get($albumID); } + public function testEditAlbumCopyright(): void + { + Auth::loginUsingId(1); + $this->users_tests->add('Test user', 'Test password 1')->offsetGet('id'); + + $albumID = $this->albums_tests->add(null, 'Test Album')->offsetGet('id'); + $this->albums_tests->set_copyright($albumID, 'Test copyright value'); + + Auth::logout(); + Session::flush(); + } + public function testDeleteMultipleAlbumsByAnonUser(): void { Auth::loginUsingId(1); diff --git a/tests/Feature/LibUnitTests/AlbumsUnitTest.php b/tests/Feature/LibUnitTests/AlbumsUnitTest.php index 509c465bd3..6a2e4d9833 100644 --- a/tests/Feature/LibUnitTests/AlbumsUnitTest.php +++ b/tests/Feature/LibUnitTests/AlbumsUnitTest.php @@ -209,6 +209,31 @@ public function set_title( } } + /** + * Change copyright. + * + * @param string $id + * @param string $copyright + * @param int $expectedStatusCode + * @param string|null $assertSee + */ + public function set_copyright( + string $id, + string $copyright, + int $expectedStatusCode = 204, + ?string $assertSee = null + ): void { + $response = $this->testCase->postJson( + '/api/Album::setCopyright', + ['albumID' => $id, 'copyright' => $copyright] + ); + + $this->assertStatus($response, $expectedStatusCode); + if ($assertSee !== null) { + $response->assertSee($assertSee, false); + } + } + /** * Change description. * From 69adfa02b83ea7cbd6a2f2f6cd457baa0b571e38 Mon Sep 17 00:00:00 2001 From: Sakis bal <43223812+ThanasisMpalatsoukas@users.noreply.github.com> Date: Mon, 19 Jun 2023 12:16:26 +0300 Subject: [PATCH 05/14] Update lang/fr/lychee.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Benoît Viguier --- lang/fr/lychee.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/fr/lychee.php b/lang/fr/lychee.php index cd07e6a4af..5d2638f621 100644 --- a/lang/fr/lychee.php +++ b/lang/fr/lychee.php @@ -151,7 +151,7 @@ 'ALBUM_ABOUT' => 'À propos', 'ALBUM_BASICS' => 'Informations de base', 'ALBUM_TITLE' => 'Titre', - 'ALBUM_COPYRIGHT' => '', + 'ALBUM_COPYRIGHT' => 'Droits d’auteur', 'ALBUM_SET_COPYRIGHT' => '', 'ALBUM_NEW_TITLE' => 'Entrez un nouveau titre pour cet album :', 'ALBUMS_NEW_TITLE' => 'Entrez un titre pour les %d albums sélectionnés :', From 30d5ffcaaf24a79c747b6f12938b0b19486d1e92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Viguier?= Date: Mon, 19 Jun 2023 11:17:46 +0200 Subject: [PATCH 06/14] Update lang/fr/lychee.php --- lang/fr/lychee.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/fr/lychee.php b/lang/fr/lychee.php index 5d2638f621..ce746d806d 100644 --- a/lang/fr/lychee.php +++ b/lang/fr/lychee.php @@ -152,7 +152,7 @@ 'ALBUM_BASICS' => 'Informations de base', 'ALBUM_TITLE' => 'Titre', 'ALBUM_COPYRIGHT' => 'Droits d’auteur', - 'ALBUM_SET_COPYRIGHT' => '', + 'ALBUM_SET_COPYRIGHT' => 'Définir les droits d’auteur', 'ALBUM_NEW_TITLE' => 'Entrez un nouveau titre pour cet album :', 'ALBUMS_NEW_TITLE' => 'Entrez un titre pour les %d albums sélectionnés :', 'ALBUM_SET_TITLE' => 'Enregistrer le titre', From dca89499baba61d708e6d4d4a207e262146faf36 Mon Sep 17 00:00:00 2001 From: Thanasis Mpalatsoukas Date: Mon, 19 Jun 2023 12:47:09 +0300 Subject: [PATCH 07/14] fix: added copyright in langs that didn't have the key --- lang/cz/lychee.php | 2 ++ lang/sk/lychee.php | 2 ++ lang/sv/lychee.php | 2 ++ lang/vi/lychee.php | 2 ++ lang/zh_CN/lychee.php | 2 ++ lang/zh_TW/lychee.php | 2 ++ 6 files changed, 12 insertions(+) diff --git a/lang/cz/lychee.php b/lang/cz/lychee.php index c7ad4546bd..3dcc87c9a4 100644 --- a/lang/cz/lychee.php +++ b/lang/cz/lychee.php @@ -151,6 +151,8 @@ 'ALBUM_ABOUT' => 'O albu', 'ALBUM_BASICS' => 'Základní informace', 'ALBUM_TITLE' => 'Název', + 'ALBUM_COPYRIGHT' => '', + 'ALBUM_SET_COPYRIGHT' => '', 'ALBUM_NEW_TITLE' => 'Zadat nový název alba:', 'ALBUMS_NEW_TITLE' => 'Zadat nový název pro %d vybraná alba:', 'ALBUM_SET_TITLE' => 'Uložit název', diff --git a/lang/sk/lychee.php b/lang/sk/lychee.php index 197a412f09..0d487659ff 100644 --- a/lang/sk/lychee.php +++ b/lang/sk/lychee.php @@ -151,6 +151,8 @@ 'ALBUM_ABOUT' => 'O albume', 'ALBUM_BASICS' => 'Základné informácie', 'ALBUM_TITLE' => 'Názov', + 'ALBUM_COPYRIGHT' => '', + 'ALBUM_SET_COPYRIGHT' => '', 'ALBUM_NEW_TITLE' => 'Zadajte nový názov pre tento album:', 'ALBUMS_NEW_TITLE' => 'Zadajte názov pre všetky %d vybrané albumy:', 'ALBUM_SET_TITLE' => 'Názov uložiť', diff --git a/lang/sv/lychee.php b/lang/sv/lychee.php index 8526f33529..766e452654 100644 --- a/lang/sv/lychee.php +++ b/lang/sv/lychee.php @@ -151,6 +151,8 @@ 'ALBUM_ABOUT' => 'Om', 'ALBUM_BASICS' => 'Grundläggande', 'ALBUM_TITLE' => 'Titel', + 'ALBUM_COPYRIGHT' => '', + 'ALBUM_SET_COPYRIGHT' => '', 'ALBUM_NEW_TITLE' => 'Skriv en ny titel för det här albumet:', 'ALBUMS_NEW_TITLE' => 'Skriv en ny titel för alla %d valda album:', 'ALBUM_SET_TITLE' => 'Spara titel', diff --git a/lang/vi/lychee.php b/lang/vi/lychee.php index 528d87d326..878a379752 100644 --- a/lang/vi/lychee.php +++ b/lang/vi/lychee.php @@ -151,6 +151,8 @@ 'ALBUM_ABOUT' => 'Giới thiệu', 'ALBUM_BASICS' => 'Những phần cơ bản', 'ALBUM_TITLE' => 'Tên album', + 'ALBUM_COPYRIGHT' => '', + 'ALBUM_SET_COPYRIGHT' => '', 'ALBUM_NEW_TITLE' => 'Đặt tên mới cho album này:', 'ALBUMS_NEW_TITLE' => 'Đặt tên cho tất cả %d những album được chọn:', 'ALBUM_SET_TITLE' => 'Đặt tên', diff --git a/lang/zh_CN/lychee.php b/lang/zh_CN/lychee.php index 8f016fab63..cfeb1b327d 100644 --- a/lang/zh_CN/lychee.php +++ b/lang/zh_CN/lychee.php @@ -151,6 +151,8 @@ 'ALBUM_ABOUT' => '关于', 'ALBUM_BASICS' => '基本信息', 'ALBUM_TITLE' => '标题', + 'ALBUM_COPYRIGHT' => '', + 'ALBUM_SET_COPYRIGHT' => '', 'ALBUM_NEW_TITLE' => '输入新的相册标题:', 'ALBUMS_NEW_TITLE' => '设置标题为 %d 已选择的相册:', 'ALBUM_SET_TITLE' => '设置标题', diff --git a/lang/zh_TW/lychee.php b/lang/zh_TW/lychee.php index 1a794a6f1f..3401d5130e 100644 --- a/lang/zh_TW/lychee.php +++ b/lang/zh_TW/lychee.php @@ -151,6 +151,8 @@ 'ALBUM_ABOUT' => '關於', 'ALBUM_BASICS' => '基本資訊', 'ALBUM_TITLE' => '標題', + 'ALBUM_COPYRIGHT' => '', + 'ALBUM_SET_COPYRIGHT' => '', 'ALBUM_NEW_TITLE' => '輸入新的相簿標題:', 'ALBUMS_NEW_TITLE' => '設定標題為 %d 已選擇的所有相簿:', 'ALBUM_SET_TITLE' => '設定標題', From ce124e635d13f2a8f1080d2c2a7f4d13c15e1c26 Mon Sep 17 00:00:00 2001 From: Thanasis Mpalatsoukas Date: Mon, 19 Jun 2023 12:57:55 +0300 Subject: [PATCH 08/14] fix: added default english on all langs --- lang/cz/lychee.php | 4 ++-- lang/de/lychee.php | 4 ++-- lang/es/lychee.php | 4 ++-- lang/it/lychee.php | 4 ++-- lang/nl/lychee.php | 4 ++-- lang/no/lychee.php | 4 ++-- lang/pl/lychee.php | 4 ++-- lang/pt/lychee.php | 4 ++-- lang/ru/lychee.php | 4 ++-- lang/sk/lychee.php | 4 ++-- lang/sv/lychee.php | 4 ++-- lang/vi/lychee.php | 4 ++-- lang/zh_CN/lychee.php | 4 ++-- lang/zh_TW/lychee.php | 4 ++-- 14 files changed, 28 insertions(+), 28 deletions(-) diff --git a/lang/cz/lychee.php b/lang/cz/lychee.php index 3dcc87c9a4..8178fd1f01 100644 --- a/lang/cz/lychee.php +++ b/lang/cz/lychee.php @@ -151,8 +151,8 @@ 'ALBUM_ABOUT' => 'O albu', 'ALBUM_BASICS' => 'Základní informace', 'ALBUM_TITLE' => 'Název', - 'ALBUM_COPYRIGHT' => '', - 'ALBUM_SET_COPYRIGHT' => '', + 'ALBUM_COPYRIGHT' => 'Copyright', + 'ALBUM_SET_COPYRIGHT' => 'Set copyright', 'ALBUM_NEW_TITLE' => 'Zadat nový název alba:', 'ALBUMS_NEW_TITLE' => 'Zadat nový název pro %d vybraná alba:', 'ALBUM_SET_TITLE' => 'Uložit název', diff --git a/lang/de/lychee.php b/lang/de/lychee.php index 67aa44eb8d..b7a95361bd 100644 --- a/lang/de/lychee.php +++ b/lang/de/lychee.php @@ -151,8 +151,8 @@ 'ALBUM_ABOUT' => 'Über', 'ALBUM_BASICS' => 'Grundlegende Informationen', 'ALBUM_TITLE' => 'Titel', - 'ALBUM_COPYRIGHT' => '', - 'ALBUM_SET_COPYRIGHT' => '', + 'ALBUM_COPYRIGHT' => 'Copyright', + 'ALBUM_SET_COPYRIGHT' => 'Set copyright', 'ALBUM_NEW_TITLE' => 'Geben Sie einen neuen Titel für dieses Album ein:', 'ALBUMS_NEW_TITLE' => 'Geben Sie einen Titel für alle %d ausgewählten Alben ein:', 'ALBUM_SET_TITLE' => 'Titel speichern', diff --git a/lang/es/lychee.php b/lang/es/lychee.php index d2316404b5..ef6306a25c 100644 --- a/lang/es/lychee.php +++ b/lang/es/lychee.php @@ -151,8 +151,8 @@ 'ALBUM_ABOUT' => 'Acerca de', 'ALBUM_BASICS' => 'Básico', 'ALBUM_TITLE' => 'Título', - 'ALBUM_COPYRIGHT' => '', - 'ALBUM_SET_COPYRIGHT' => '', + 'ALBUM_COPYRIGHT' => 'Copyright', + 'ALBUM_SET_COPYRIGHT' => 'Set copyright', 'ALBUM_NEW_TITLE' => 'Ingrese un nuevo título para este álbum:', 'ALBUMS_NEW_TITLE' => 'Ingrese un título para todos %d álbumes seleccionados:', 'ALBUM_SET_TITLE' => 'Establecer Título', diff --git a/lang/it/lychee.php b/lang/it/lychee.php index 80ec0efa31..f758d4b1ea 100644 --- a/lang/it/lychee.php +++ b/lang/it/lychee.php @@ -151,8 +151,8 @@ 'ALBUM_ABOUT' => 'Informazioni', 'ALBUM_BASICS' => 'Base', 'ALBUM_TITLE' => 'Titolo', - 'ALBUM_COPYRIGHT' => '', - 'ALBUM_SET_COPYRIGHT' => '', + 'ALBUM_COPYRIGHT' => 'Copyright', + 'ALBUM_SET_COPYRIGHT' => 'Set copyright', 'ALBUM_NEW_TITLE' => 'Inserire un nuovo titolo per questo album:', 'ALBUMS_NEW_TITLE' => 'Inserire un nuovo titolo per %d gli album selezionati:', 'ALBUM_SET_TITLE' => 'Imposta Titolo', diff --git a/lang/nl/lychee.php b/lang/nl/lychee.php index ef76c31c6e..cddbe4884a 100644 --- a/lang/nl/lychee.php +++ b/lang/nl/lychee.php @@ -151,8 +151,8 @@ 'ALBUM_ABOUT' => 'Over', 'ALBUM_BASICS' => 'Basics', 'ALBUM_TITLE' => 'Titel', - 'ALBUM_COPYRIGHT' => '', - 'ALBUM_SET_COPYRIGHT' => '', + 'ALBUM_COPYRIGHT' => 'Copyright', + 'ALBUM_SET_COPYRIGHT' => 'Set copyright', 'ALBUM_NEW_TITLE' => 'Geef dit album een nieuwe titel:', 'ALBUMS_NEW_TITLE' => 'Geef alle geselecteerde %d albums een nieuwe titel:', 'ALBUM_SET_TITLE' => 'Sla Titel op', diff --git a/lang/no/lychee.php b/lang/no/lychee.php index 0e592a3708..81ea2c92f6 100644 --- a/lang/no/lychee.php +++ b/lang/no/lychee.php @@ -151,8 +151,8 @@ 'ALBUM_ABOUT' => 'Om', 'ALBUM_BASICS' => 'Grunnleggende', 'ALBUM_TITLE' => 'Tittel', - 'ALBUM_COPYRIGHT' => '', - 'ALBUM_SET_COPYRIGHT' => '', + 'ALBUM_COPYRIGHT' => 'Copyright', + 'ALBUM_SET_COPYRIGHT' => 'Set copyright', 'ALBUM_NEW_TITLE' => 'Legg inn en ny tittel for Albumet:', 'ALBUMS_NEW_TITLE' => 'Legg inn en ny tittel for %d valgte album:', 'ALBUM_SET_TITLE' => 'Lagre Tittel', diff --git a/lang/pl/lychee.php b/lang/pl/lychee.php index 6e8b2f4039..d1c0f3d5f8 100644 --- a/lang/pl/lychee.php +++ b/lang/pl/lychee.php @@ -151,8 +151,8 @@ 'ALBUM_ABOUT' => 'Informacje o albumie', 'ALBUM_BASICS' => 'Informacje podstawowe', 'ALBUM_TITLE' => 'Tytuł', - 'ALBUM_COPYRIGHT' => '', - 'ALBUM_SET_COPYRIGHT' => '', + 'ALBUM_COPYRIGHT' => 'Copyright', + 'ALBUM_SET_COPYRIGHT' => 'Set copyright', 'ALBUM_NEW_TITLE' => 'Edytuj tytuł albumu:', 'ALBUMS_NEW_TITLE' => 'Wpisz tytuł dla %d wybranych albumów:', 'ALBUM_SET_TITLE' => 'Zapisz', diff --git a/lang/pt/lychee.php b/lang/pt/lychee.php index d8c7d2d3a3..93d5af7e6b 100644 --- a/lang/pt/lychee.php +++ b/lang/pt/lychee.php @@ -151,8 +151,8 @@ 'ALBUM_ABOUT' => 'Acerca de', 'ALBUM_BASICS' => 'Básicos', 'ALBUM_TITLE' => 'Título', - 'ALBUM_COPYRIGHT' => '', - 'ALBUM_SET_COPYRIGHT' => '', + 'ALBUM_COPYRIGHT' => 'Copyright', + 'ALBUM_SET_COPYRIGHT' => 'Set copyright', 'ALBUM_NEW_TITLE' => 'Inserir novo título para este álbum:', 'ALBUMS_NEW_TITLE' => 'Inserir um título para todos %d álbums selecionados:', 'ALBUM_SET_TITLE' => 'Escolher Título', diff --git a/lang/ru/lychee.php b/lang/ru/lychee.php index e36594dfc9..591a704b6b 100644 --- a/lang/ru/lychee.php +++ b/lang/ru/lychee.php @@ -151,8 +151,8 @@ 'ALBUM_ABOUT' => 'Об альбоме', 'ALBUM_BASICS' => 'Основное', 'ALBUM_TITLE' => 'Заголовок', - 'ALBUM_COPYRIGHT' => '', - 'ALBUM_SET_COPYRIGHT' => '', + 'ALBUM_COPYRIGHT' => 'Copyright', + 'ALBUM_SET_COPYRIGHT' => 'Set copyright', 'ALBUM_NEW_TITLE' => 'Новый заголовок альбома:', 'ALBUMS_NEW_TITLE' => 'Введите заголовок для всех %d выбранных альбомов:', 'ALBUM_SET_TITLE' => 'Сохранить заголовок', diff --git a/lang/sk/lychee.php b/lang/sk/lychee.php index 0d487659ff..294ea4d229 100644 --- a/lang/sk/lychee.php +++ b/lang/sk/lychee.php @@ -151,8 +151,8 @@ 'ALBUM_ABOUT' => 'O albume', 'ALBUM_BASICS' => 'Základné informácie', 'ALBUM_TITLE' => 'Názov', - 'ALBUM_COPYRIGHT' => '', - 'ALBUM_SET_COPYRIGHT' => '', + 'ALBUM_COPYRIGHT' => 'Copyright', + 'ALBUM_SET_COPYRIGHT' => 'Set copyright', 'ALBUM_NEW_TITLE' => 'Zadajte nový názov pre tento album:', 'ALBUMS_NEW_TITLE' => 'Zadajte názov pre všetky %d vybrané albumy:', 'ALBUM_SET_TITLE' => 'Názov uložiť', diff --git a/lang/sv/lychee.php b/lang/sv/lychee.php index 766e452654..2506158798 100644 --- a/lang/sv/lychee.php +++ b/lang/sv/lychee.php @@ -151,8 +151,8 @@ 'ALBUM_ABOUT' => 'Om', 'ALBUM_BASICS' => 'Grundläggande', 'ALBUM_TITLE' => 'Titel', - 'ALBUM_COPYRIGHT' => '', - 'ALBUM_SET_COPYRIGHT' => '', + 'ALBUM_COPYRIGHT' => 'Copyright', + 'ALBUM_SET_COPYRIGHT' => 'Set copyright', 'ALBUM_NEW_TITLE' => 'Skriv en ny titel för det här albumet:', 'ALBUMS_NEW_TITLE' => 'Skriv en ny titel för alla %d valda album:', 'ALBUM_SET_TITLE' => 'Spara titel', diff --git a/lang/vi/lychee.php b/lang/vi/lychee.php index 878a379752..1f57a846d9 100644 --- a/lang/vi/lychee.php +++ b/lang/vi/lychee.php @@ -151,8 +151,8 @@ 'ALBUM_ABOUT' => 'Giới thiệu', 'ALBUM_BASICS' => 'Những phần cơ bản', 'ALBUM_TITLE' => 'Tên album', - 'ALBUM_COPYRIGHT' => '', - 'ALBUM_SET_COPYRIGHT' => '', + 'ALBUM_COPYRIGHT' => 'Copyright', + 'ALBUM_SET_COPYRIGHT' => 'Set copyright', 'ALBUM_NEW_TITLE' => 'Đặt tên mới cho album này:', 'ALBUMS_NEW_TITLE' => 'Đặt tên cho tất cả %d những album được chọn:', 'ALBUM_SET_TITLE' => 'Đặt tên', diff --git a/lang/zh_CN/lychee.php b/lang/zh_CN/lychee.php index cfeb1b327d..2294b431c9 100644 --- a/lang/zh_CN/lychee.php +++ b/lang/zh_CN/lychee.php @@ -151,8 +151,8 @@ 'ALBUM_ABOUT' => '关于', 'ALBUM_BASICS' => '基本信息', 'ALBUM_TITLE' => '标题', - 'ALBUM_COPYRIGHT' => '', - 'ALBUM_SET_COPYRIGHT' => '', + 'ALBUM_COPYRIGHT' => 'Copyright', + 'ALBUM_SET_COPYRIGHT' => 'Set copyright', 'ALBUM_NEW_TITLE' => '输入新的相册标题:', 'ALBUMS_NEW_TITLE' => '设置标题为 %d 已选择的相册:', 'ALBUM_SET_TITLE' => '设置标题', diff --git a/lang/zh_TW/lychee.php b/lang/zh_TW/lychee.php index 3401d5130e..2a5ffaf571 100644 --- a/lang/zh_TW/lychee.php +++ b/lang/zh_TW/lychee.php @@ -151,8 +151,8 @@ 'ALBUM_ABOUT' => '關於', 'ALBUM_BASICS' => '基本資訊', 'ALBUM_TITLE' => '標題', - 'ALBUM_COPYRIGHT' => '', - 'ALBUM_SET_COPYRIGHT' => '', + 'ALBUM_COPYRIGHT' => 'Copyright', + 'ALBUM_SET_COPYRIGHT' => 'Set copyright', 'ALBUM_NEW_TITLE' => '輸入新的相簿標題:', 'ALBUMS_NEW_TITLE' => '設定標題為 %d 已選擇的所有相簿:', 'ALBUM_SET_TITLE' => '設定標題', From ac6710fdd52c513fd8e14993142e70e73fa89ec2 Mon Sep 17 00:00:00 2001 From: ildyria Date: Sun, 28 Apr 2024 19:26:26 +0200 Subject: [PATCH 09/14] fix migration not properly done. --- app/Livewire/DTO/AlbumFormatted.php | 2 ++ .../2021_12_04_181200_refactor_models.php | 1 - .../2024_04_28_172241_add_album_copyright.php | 30 +++++++++++++++++++ resources/js/lycheeOrg/backend.d.ts | 1 + 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2024_04_28_172241_add_album_copyright.php diff --git a/app/Livewire/DTO/AlbumFormatted.php b/app/Livewire/DTO/AlbumFormatted.php index 1a86351177..c8f7152ed5 100644 --- a/app/Livewire/DTO/AlbumFormatted.php +++ b/app/Livewire/DTO/AlbumFormatted.php @@ -21,6 +21,7 @@ class AlbumFormatted public bool $can_download; public ?string $created_at = null; public ?string $description = null; + public ?string $copyright = null; public function __construct(AbstractAlbum $album, ?string $url) { @@ -33,6 +34,7 @@ public function __construct(AbstractAlbum $album, ?string $url) $this->max_taken_at = $album->max_taken_at?->format($min_max_date_format); $this->created_at = $album->created_at->format($create_date_format); $this->description = trim($album->description ?? ''); + $this->copyright = $album->copyright; } if ($album instanceof Album) { $this->num_children = $album->num_children; diff --git a/database/migrations/2021_12_04_181200_refactor_models.php b/database/migrations/2021_12_04_181200_refactor_models.php index 211d2b491c..3a93b12689 100644 --- a/database/migrations/2021_12_04_181200_refactor_models.php +++ b/database/migrations/2021_12_04_181200_refactor_models.php @@ -515,7 +515,6 @@ private function createBaseAlbumTable(): void $table->string('password', 100)->nullable()->default(null); $table->string('sorting_col', 30)->nullable()->default(null); $table->string('sorting_order', 4)->nullable()->default(null); - $table->string('copyright', 300)->nullable()->default(null); // Indices and constraint definitions $table->primary('id'); $table->unique('legacy_id'); diff --git a/database/migrations/2024_04_28_172241_add_album_copyright.php b/database/migrations/2024_04_28_172241_add_album_copyright.php new file mode 100644 index 0000000000..3659ca9db2 --- /dev/null +++ b/database/migrations/2024_04_28_172241_add_album_copyright.php @@ -0,0 +1,30 @@ +string(self::COLUMN, 300)->nullable()->default(null); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table(self::TABLE, function (Blueprint $table) { + $table->dropColumn(self::COLUMN); + }); + } +}; diff --git a/resources/js/lycheeOrg/backend.d.ts b/resources/js/lycheeOrg/backend.d.ts index 8dcafadec1..6b6e734fee 100644 --- a/resources/js/lycheeOrg/backend.d.ts +++ b/resources/js/lycheeOrg/backend.d.ts @@ -131,6 +131,7 @@ export type Album = { cover_id: string | null; thumb: Thumb | null; owner_name?: string; + copyright: string | null; is_nsfw: boolean; rights: AlbumRightsDTO; policy: AlbumProtectionPolicy; From 60655d00e8be2dedf8ef19fe2c28d22b9dba8b7f Mon Sep 17 00:00:00 2001 From: ildyria Date: Sun, 28 Apr 2024 19:29:24 +0200 Subject: [PATCH 10/14] a bit too fast --- database/migrations/2024_04_28_172241_add_album_copyright.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/migrations/2024_04_28_172241_add_album_copyright.php b/database/migrations/2024_04_28_172241_add_album_copyright.php index 3659ca9db2..ab283e0362 100644 --- a/database/migrations/2024_04_28_172241_add_album_copyright.php +++ b/database/migrations/2024_04_28_172241_add_album_copyright.php @@ -13,7 +13,7 @@ */ public function up(): void { - Schema::create(self::TABLE, function (Blueprint $table) { + Schema::table(self::TABLE, function (Blueprint $table) { $table->string(self::COLUMN, 300)->nullable()->default(null); }); } From 7c1363e0ba4074327c2d3af56db11468b797e323 Mon Sep 17 00:00:00 2001 From: ildyria Date: Sun, 28 Apr 2024 19:31:58 +0200 Subject: [PATCH 11/14] add copyright to details --- resources/views/components/gallery/album/details.blade.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/resources/views/components/gallery/album/details.blade.php b/resources/views/components/gallery/album/details.blade.php index d0ac54dcbd..e0eeb1c918 100644 --- a/resources/views/components/gallery/album/details.blade.php +++ b/resources/views/components/gallery/album/details.blade.php @@ -8,6 +8,11 @@ {{ __('lychee.ALBUM_CREATED') }} {{ $this->AlbumFormatted->created_at }} @endif + @if($this->AlbumFormatted->copyright !== null && $this->AlbumFormatted->copyright !== '') + + {{ $this->AlbumFormatted->copyright }} + + @endif @if($this->num_albums > 0) {{ $this->num_albums }} {{ __('lychee.ALBUM_SUBALBUMS') }} From adefdd3f3bf242e2121584cef0d71493b118a095 Mon Sep 17 00:00:00 2001 From: ildyria Date: Sun, 28 Apr 2024 20:02:53 +0200 Subject: [PATCH 12/14] full support of per-album-copyright --- .../Components/Forms/Album/Properties.php | 9 +++++++ app/Rules/CopyrightRule.php | 2 +- .../gallery/album/details.blade.php | 2 +- .../livewire/forms/album/properties.blade.php | 5 ++++ tests/Livewire/Forms/Album/PropertiesTest.php | 26 +++++++++++++++++++ 5 files changed, 42 insertions(+), 2 deletions(-) diff --git a/app/Livewire/Components/Forms/Album/Properties.php b/app/Livewire/Components/Forms/Album/Properties.php index 6918908e63..a45d2c85b2 100644 --- a/app/Livewire/Components/Forms/Album/Properties.php +++ b/app/Livewire/Components/Forms/Album/Properties.php @@ -20,6 +20,7 @@ use App\Models\Album as ModelsAlbum; use App\Models\Extensions\BaseAlbum; use App\Policies\AlbumPolicy; +use App\Rules\CopyrightRule; use App\Rules\TitleRule; use Illuminate\Contracts\View\View; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; @@ -44,6 +45,7 @@ class Properties extends Component public string $album_sorting_order = ''; // ! wired public string $album_aspect_ratio = ''; // ! wired public string $license = 'none'; // ! wired + public string $copyright = ''; // ! wired /** * This is the equivalent of the constructor for Livewire Components. @@ -63,6 +65,7 @@ public function mount(BaseAlbum $album): void $this->description = $album->description ?? ''; $this->photo_sorting_column = $album->photo_sorting?->column->value ?? ''; $this->photo_sorting_order = $album->photo_sorting?->order->value ?? ''; + $this->copyright = $album->copyright ?? ''; if ($this->is_model_album) { /** @var ModelsAlbum $album */ $this->license = $album->license->value; @@ -94,6 +97,7 @@ public function submit(AlbumFactory $albumFactory): void ...SetPhotoSortingRuleSet::rules(), ...SetAlbumSortingRuleSet::rules(), RequestAttribute::ALBUM_ASPECT_RATIO_ATTRIBUTE => ['present', 'nullable', new Enum(AspectRatioType::class)], + RequestAttribute::COPYRIGHT_ATTRIBUTE => ['present', 'nullable', new CopyrightRule()], ]; if (!$this->areValid($rules)) { @@ -106,12 +110,17 @@ public function submit(AlbumFactory $albumFactory): void $baseAlbum->title = $this->title; $baseAlbum->description = $this->description; + $this->copyright = trim($this->copyright); + // Not super pretty but whatever. $column = ColumnSortingPhotoType::tryFrom($this->photo_sorting_column); $order = OrderSortingType::tryFrom($this->photo_sorting_order); $photoSortingCriterion = $column === null ? null : new PhotoSortingCriterion($column->toColumnSortingType(), $order); $baseAlbum->photo_sorting = $photoSortingCriterion; + // If left empty, we set to null + $baseAlbum->copyright = $this->copyright === '' ? null : $this->copyright; + if ($this->is_model_album) { /** @var ModelsAlbum $baseAlbum */ $baseAlbum->license = LicenseType::from($this->license); diff --git a/app/Rules/CopyrightRule.php b/app/Rules/CopyrightRule.php index 7db79cb9f3..0f5891e488 100644 --- a/app/Rules/CopyrightRule.php +++ b/app/Rules/CopyrightRule.php @@ -6,6 +6,6 @@ class CopyrightRule extends StringRule { public function __construct() { - parent::__construct(false, 300); + parent::__construct(true, 300); } } diff --git a/resources/views/components/gallery/album/details.blade.php b/resources/views/components/gallery/album/details.blade.php index e0eeb1c918..8b55698664 100644 --- a/resources/views/components/gallery/album/details.blade.php +++ b/resources/views/components/gallery/album/details.blade.php @@ -10,7 +10,7 @@ @endif @if($this->AlbumFormatted->copyright !== null && $this->AlbumFormatted->copyright !== '') - {{ $this->AlbumFormatted->copyright }} + {{ __('lychee.ALBUM_COPYRIGHT') }} {{ $this->AlbumFormatted->copyright }} @endif @if($this->num_albums > 0) diff --git a/resources/views/livewire/forms/album/properties.blade.php b/resources/views/livewire/forms/album/properties.blade.php index d5ea5e2191..a94c1a12c3 100644 --- a/resources/views/livewire/forms/album/properties.blade.php +++ b/resources/views/livewire/forms/album/properties.blade.php @@ -26,6 +26,11 @@ {{ __('lychee.ALBUM_SET_LICENSE') }} +
+ {{ __('lychee.ALBUM_SET_COPYRIGHT') }}: + + +
Set album thumbs aspect ratio diff --git a/tests/Livewire/Forms/Album/PropertiesTest.php b/tests/Livewire/Forms/Album/PropertiesTest.php index 9bfb7c3ae0..992b04f800 100644 --- a/tests/Livewire/Forms/Album/PropertiesTest.php +++ b/tests/Livewire/Forms/Album/PropertiesTest.php @@ -13,6 +13,7 @@ namespace Tests\Livewire\Forms\Album; use App\Livewire\Components\Forms\Album\Properties; +use App\Models\Album; use Livewire\Livewire; use Tests\Livewire\Base\BaseLivewireTest; @@ -40,4 +41,29 @@ public function testPropertiesLoggedIn(): void ->assertOk() ->assertNotDispatched('notify', self::notifySuccess()); } + + public function testSetCopyright(): void + { + Livewire::actingAs($this->admin)->test(Properties::class, ['album' => $this->album1]) + ->assertOk() + ->assertViewIs('livewire.forms.album.properties') + ->set('copyright', 'something') + ->call('submit') + ->assertOk() + ->assertDispatched('notify', self::notifySuccess()); + + $copyright = Album::findOrFail($this->album1->id)->copyright; + $this->assertEquals('something', $copyright); + + Livewire::actingAs($this->admin)->test(Properties::class, ['album' => $this->album1]) + ->assertOk() + ->assertViewIs('livewire.forms.album.properties') + ->set('copyright', '') + ->call('submit') + ->assertOk() + ->assertDispatched('notify', self::notifySuccess()); + + $copyright = Album::findOrFail($this->album1->id)->copyright; + $this->assertEquals(null, $copyright); + } } From c310246ea1e9f69126793a92c1ff14c67d30eb7c Mon Sep 17 00:00:00 2001 From: ildyria Date: Sun, 28 Apr 2024 20:04:13 +0200 Subject: [PATCH 13/14] fix missing langauge --- lang/hu/lychee.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lang/hu/lychee.php b/lang/hu/lychee.php index 961ba7256d..4cac3932cc 100644 --- a/lang/hu/lychee.php +++ b/lang/hu/lychee.php @@ -155,6 +155,8 @@ 'ALBUM_ABOUT' => 'Névjegy', 'ALBUM_BASICS' => 'Alapok', 'ALBUM_TITLE' => 'Cím', + 'ALBUM_COPYRIGHT' => 'Copyright', + 'ALBUM_SET_COPYRIGHT' => 'Set copyright', 'ALBUM_NEW_TITLE' => 'Adjon meg egy új címet ennek az albumnak:', 'ALBUMS_NEW_TITLE' => 'Adjon meg címet az összes %d kiválasztott albumnak:', 'ALBUM_SET_TITLE' => 'Cím beállítása', From b0a5c3d6c48ef23cc79c41e59afa8f86b98e20a6 Mon Sep 17 00:00:00 2001 From: ildyria Date: Sun, 28 Apr 2024 20:10:43 +0200 Subject: [PATCH 14/14] fix phpstan --- tests/Livewire/Forms/Album/PropertiesTest.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/Livewire/Forms/Album/PropertiesTest.php b/tests/Livewire/Forms/Album/PropertiesTest.php index 992b04f800..946a2fe0ae 100644 --- a/tests/Livewire/Forms/Album/PropertiesTest.php +++ b/tests/Livewire/Forms/Album/PropertiesTest.php @@ -52,8 +52,9 @@ public function testSetCopyright(): void ->assertOk() ->assertDispatched('notify', self::notifySuccess()); - $copyright = Album::findOrFail($this->album1->id)->copyright; - $this->assertEquals('something', $copyright); + /** @var Album $album */ + $album = Album::findOrFail($this->album1->id); + $this->assertEquals('something', $album->copyright); Livewire::actingAs($this->admin)->test(Properties::class, ['album' => $this->album1]) ->assertOk() @@ -63,7 +64,8 @@ public function testSetCopyright(): void ->assertOk() ->assertDispatched('notify', self::notifySuccess()); - $copyright = Album::findOrFail($this->album1->id)->copyright; - $this->assertEquals(null, $copyright); + /** @var Album $album */ + $album = Album::findOrFail($this->album1->id); + $this->assertEquals(null, $album->copyright); } }