mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 11:11:10 +00:00
Adds book deletion and restore to the web client.
Soft deletes books so the scan keeps their paths reserved, lists the deleted books on a themed page, and lets the user restore them. Updates the API, bundled themes, localization, documentation and tests. Closes #213
This commit is contained in:
1 parent
ef5ede6325
commit
f26b07d4ff
125 files changed
+9856
-378
No files matched your search
+6
@@ -33,6 +33,8 @@ public class BookEntityFixture
|
||||
/// <param name="path">Optional. The file system path of the book.</param>
|
||||
/// <param name="title">Optional. The title of the book.</param>
|
||||
/// <param name="originalTitle">Optional. The original title of the book.</param>
|
||||
/// <param name="deletedOnUtc">Optional. The date and time when the book was deleted. Only used when the book is marked as deleted.</param>
|
||||
/// <param name="isDeleted">Optional. Whether the book is marked as deleted.</param>
|
||||
/// <param name="includeMetadata">Whether the owned metadata collections (Tags, Genres, ISBNs, Ratings) should be included, or forced to empty collections.</param>
|
||||
/// <returns>The created <see cref="BookEntity"/>.</returns>
|
||||
public BookEntity Create(
|
||||
@@ -41,6 +43,8 @@ public class BookEntityFixture
|
||||
string? path = null,
|
||||
string? title = null,
|
||||
string? originalTitle = null,
|
||||
DateTime? deletedOnUtc = null,
|
||||
bool isDeleted = false,
|
||||
bool includeMetadata = true)
|
||||
{
|
||||
int releaseYear = Random.Shared.Next(2000, 2010);
|
||||
@@ -83,6 +87,8 @@ public class BookEntityFixture
|
||||
.RuleFor(x => x.AppleBooksId, f => $"id{f.Random.Number(1, 999999)}")
|
||||
.RuleFor(x => x.ISBNs, f => includeMetadata ? _isbnEntityFixture.CreateMany(f.Random.Number(1, 5)) : [])
|
||||
.RuleFor(x => x.Ratings, f => includeMetadata ? _bookRatingEntityFixture.CreateMany(f.Random.Number(1, 5)) : [])
|
||||
.RuleFor(x => x.IsDeleted, isDeleted)
|
||||
.RuleFor(x => x.DeletedOnUtc, f => isDeleted ? (deletedOnUtc ?? f.Date.Recent()) : null)
|
||||
.RuleFor(x => x.CreatedOnUtc, f => f.Date.Past())
|
||||
.RuleFor(x => x.UpdatedOnUtc, f => f.Date.Recent())
|
||||
.Generate();
|
||||
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Commands.RestoreBook;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Commands.RestoreBook;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="RestoreBookCommand"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class RestoreBookCommandFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="RestoreBookCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">Optional. The Id of the media library the book belongs to, taken from the route.</param>
|
||||
/// <param name="bookId">Optional. The Id of the deleted book to restore, taken from the route.</param>
|
||||
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeBookId">Whether the book Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="RestoreBookCommand"/>.</returns>
|
||||
public RestoreBookCommand Create(
|
||||
string? libraryId = null,
|
||||
string? bookId = null,
|
||||
bool includeLibraryId = true,
|
||||
bool includeBookId = true)
|
||||
{
|
||||
return new RestoreBookCommand(
|
||||
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
|
||||
includeBookId ? (bookId ?? Guid.NewGuid().ToString()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="RestoreBookCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="RestoreBookCommand"/> instances.</returns>
|
||||
public List<RestoreBookCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Queries.GetDeletedBooks;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Queries.GetDeletedBooks;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetDeletedBooksQuery"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetDeletedBooksQueryFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="GetDeletedBooksQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">Optional. The Id of the media library whose deleted books are retrieved, taken from the route.</param>
|
||||
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="GetDeletedBooksQuery"/>.</returns>
|
||||
public GetDeletedBooksQuery Create(
|
||||
string? libraryId = null,
|
||||
bool includeLibraryId = true)
|
||||
{
|
||||
return new GetDeletedBooksQuery(
|
||||
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetDeletedBooksQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetDeletedBooksQuery"/> instances.</returns>
|
||||
public List<GetDeletedBooksQuery> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="DeletedBookResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DeletedBookResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="DeletedBookResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the deleted book.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library the deleted book belongs to.</param>
|
||||
/// <param name="title">Optional. The title of the deleted book.</param>
|
||||
/// <param name="originalTitle">Optional. The original title of the deleted book.</param>
|
||||
/// <param name="path">Optional. The file system path of the deleted book.</param>
|
||||
/// <param name="deletedOnUtc">Optional. The date and time when the book was deleted.</param>
|
||||
/// <param name="coverPath">Optional. The path of the cover image of the deleted book.</param>
|
||||
/// <param name="includeOriginalTitle">Whether the original title should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="DeletedBookResponse"/>.</returns>
|
||||
public DeletedBookResponse Create(
|
||||
Guid? id = null,
|
||||
Guid? libraryId = null,
|
||||
string? title = null,
|
||||
string? originalTitle = null,
|
||||
string? path = null,
|
||||
DateTime? deletedOnUtc = null,
|
||||
string? coverPath = null,
|
||||
bool includeOriginalTitle = true,
|
||||
bool includeCoverPath = true)
|
||||
{
|
||||
return new DeletedBookResponse(
|
||||
id ?? _faker.Random.Guid(),
|
||||
libraryId ?? _faker.Random.Guid(),
|
||||
title ?? _faker.Lorem.Sentence(3),
|
||||
includeOriginalTitle ? (originalTitle ?? _faker.Lorem.Sentence(3)) : null,
|
||||
path ?? _faker.System.FilePath(),
|
||||
deletedOnUtc ?? _faker.Date.Recent(),
|
||||
includeCoverPath ? (coverPath ?? $"/covers/{_faker.Random.Guid()}.jpg") : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="DeletedBookResponse"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="DeletedBookResponse"/> instances.</returns>
|
||||
public List<DeletedBookResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.WrittenContentLibrary.BookLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.WrittenContentLibrary.BookLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="DeletedBookDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DeletedBookDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="DeletedBookDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the deleted book.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library the deleted book belongs to.</param>
|
||||
/// <param name="title">Optional. The title of the deleted book.</param>
|
||||
/// <param name="originalTitle">Optional. The original title of the deleted book.</param>
|
||||
/// <param name="path">Optional. The file system path of the deleted book.</param>
|
||||
/// <param name="deletedOnUtc">Optional. The date and time when the book was deleted.</param>
|
||||
/// <param name="coverPath">Optional. The relative path of the stored cover image of the deleted book.</param>
|
||||
/// <param name="includeOriginalTitle">Whether the original title should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="DeletedBookDto"/>.</returns>
|
||||
public DeletedBookDto Create(
|
||||
Guid? id = null,
|
||||
Guid? libraryId = null,
|
||||
string? title = null,
|
||||
string? originalTitle = null,
|
||||
string? path = null,
|
||||
DateTime? deletedOnUtc = null,
|
||||
string? coverPath = null,
|
||||
bool includeOriginalTitle = true,
|
||||
bool includeCoverPath = true)
|
||||
{
|
||||
return new DeletedBookDto(
|
||||
Id: id ?? _faker.Random.Guid(),
|
||||
LibraryId: libraryId ?? _faker.Random.Guid(),
|
||||
Title: title ?? _faker.Lorem.Sentence(),
|
||||
OriginalTitle: includeOriginalTitle ? (originalTitle ?? _faker.Lorem.Sentence()) : null,
|
||||
Path: path ?? _faker.System.FilePath(),
|
||||
DeletedOnUtc: deletedOnUtc ?? _faker.Date.Recent(),
|
||||
CoverPath: includeCoverPath ? (coverPath ?? _faker.System.FilePath()) : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="DeletedBookDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="DeletedBookDto"/> instances.</returns>
|
||||
public List<DeletedBookDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user