From 5e763d15ec3b3b6a68d025711f56dc5b69af7765 Mon Sep 17 00:00:00 2001 From: Lars Date: Mon, 16 Nov 2026 08:24:23 +0100 Subject: [PATCH] Ergaenze Stammdaten, Suche, Dimensionen, Abdeckung und Ausgabenachweis Co-authored-by: Cursor --- app/Domain/Catalog/Composition.php | 2 + app/Domain/Catalog/ContentElement.php | 2 + app/Domain/Catalog/EditorialDimension.php | 16 ++++ .../Catalog/EditorialDimensionValue.php | 16 ++++ app/Domain/Catalog/IdentityChange.php | 32 +++++++ app/Domain/Catalog/IdentityDimension.php | 55 ++++++++++++ app/Domain/Catalog/IdentityDimensionValue.php | 15 ++++ app/Domain/Catalog/IdentityProfile.php | 39 ++++++++ app/Domain/Catalog/OfferCoverage.php | 38 ++++++++ app/Domain/Catalog/OfferService.php | 29 ++++++ app/Domain/Entitlement/MediaDelivery.php | 25 ++++++ .../Compositions/Pages/EditComposition.php | 11 +++ .../Pages/EditContentElement.php | 10 +++ .../Controllers/Member/LibraryController.php | 61 ++++++++++++- app/Http/CourseOutline.php | 9 +- app/Http/LibraryCatalog.php | 6 +- ...6_11_16_130000_identity_display_fields.php | 45 ++++++++++ ...2026_11_16_140000_editorial_dimensions.php | 75 ++++++++++++++++ .../2026_11_16_150000_media_deliveries.php | 28 ++++++ resources/views/member/library.blade.php | 8 ++ resources/views/member/program.blade.php | 3 + tests/Feature/CatalogFollowThroughTest.php | 90 +++++++++++++++++++ tests/Feature/IdentityProfileTest.php | 51 +++++++++++ 23 files changed, 661 insertions(+), 5 deletions(-) create mode 100644 app/Domain/Catalog/EditorialDimension.php create mode 100644 app/Domain/Catalog/EditorialDimensionValue.php create mode 100644 app/Domain/Catalog/IdentityChange.php create mode 100644 app/Domain/Catalog/IdentityDimension.php create mode 100644 app/Domain/Catalog/IdentityDimensionValue.php create mode 100644 app/Domain/Catalog/IdentityProfile.php create mode 100644 app/Domain/Catalog/OfferCoverage.php create mode 100644 app/Domain/Entitlement/MediaDelivery.php create mode 100644 database/migrations/2026_11_16_130000_identity_display_fields.php create mode 100644 database/migrations/2026_11_16_140000_editorial_dimensions.php create mode 100644 database/migrations/2026_11_16_150000_media_deliveries.php create mode 100644 tests/Feature/CatalogFollowThroughTest.php create mode 100644 tests/Feature/IdentityProfileTest.php diff --git a/app/Domain/Catalog/Composition.php b/app/Domain/Catalog/Composition.php index 188c726..d57ee67 100644 --- a/app/Domain/Catalog/Composition.php +++ b/app/Domain/Catalog/Composition.php @@ -10,6 +10,8 @@ class Composition extends Model { protected $fillable = [ 'designation', + 'display_title', + 'summary', 'kind', 'editorial_content_kind_id', 'archived_at', diff --git a/app/Domain/Catalog/ContentElement.php b/app/Domain/Catalog/ContentElement.php index ea68840..99a1e36 100644 --- a/app/Domain/Catalog/ContentElement.php +++ b/app/Domain/Catalog/ContentElement.php @@ -13,7 +13,9 @@ class ContentElement extends Model 'kind', 'output_class', 'working_title', + 'display_title', 'description', + 'summary', 'editorial_content_kind_id', 'archived_at', ]; diff --git a/app/Domain/Catalog/EditorialDimension.php b/app/Domain/Catalog/EditorialDimension.php new file mode 100644 index 0000000..575d9fc --- /dev/null +++ b/app/Domain/Catalog/EditorialDimension.php @@ -0,0 +1,16 @@ +hasMany(EditorialDimensionValue::class); + } +} diff --git a/app/Domain/Catalog/EditorialDimensionValue.php b/app/Domain/Catalog/EditorialDimensionValue.php new file mode 100644 index 0000000..a7bb7e9 --- /dev/null +++ b/app/Domain/Catalog/EditorialDimensionValue.php @@ -0,0 +1,16 @@ +belongsTo(EditorialDimension::class, 'editorial_dimension_id'); + } +} diff --git a/app/Domain/Catalog/IdentityChange.php b/app/Domain/Catalog/IdentityChange.php new file mode 100644 index 0000000..8f24569 --- /dev/null +++ b/app/Domain/Catalog/IdentityChange.php @@ -0,0 +1,32 @@ + 'datetime', + ]; + } + + public function actor(): BelongsTo + { + return $this->belongsTo(User::class, 'actor_id'); + } +} diff --git a/app/Domain/Catalog/IdentityDimension.php b/app/Domain/Catalog/IdentityDimension.php new file mode 100644 index 0000000..537e81a --- /dev/null +++ b/app/Domain/Catalog/IdentityDimension.php @@ -0,0 +1,55 @@ +updateOrCreate( + [ + 'subject_type' => $subject->getMorphClass(), + 'subject_id' => $subject->getKey(), + 'editorial_dimension_value_id' => $value->id, + ], + ['origin' => $origin], + ); + } + + /** + * @param list $valueIds + */ + public function matches(Model $subject, array $valueIds): bool + { + if ($valueIds === []) { + return true; + } + + $assigned = IdentityDimensionValue::query() + ->where('subject_type', $subject->getMorphClass()) + ->where('subject_id', $subject->getKey()) + ->pluck('editorial_dimension_value_id') + ->all(); + + $wanted = EditorialDimensionValue::query()->whereIn('id', $valueIds)->get()->groupBy('editorial_dimension_id'); + + if ($wanted->isEmpty()) { + return false; + } + + foreach ($wanted as $group) { + $ids = $group->pluck('id')->all(); + if (array_intersect($ids, $assigned) === []) { + return false; + } + } + + return true; + } +} diff --git a/app/Domain/Catalog/IdentityDimensionValue.php b/app/Domain/Catalog/IdentityDimensionValue.php new file mode 100644 index 0000000..ad216aa --- /dev/null +++ b/app/Domain/Catalog/IdentityDimensionValue.php @@ -0,0 +1,15 @@ + $fields + */ + public function fill(Model $subject, array $fields, ?User $actor = null): void + { + foreach ($fields as $field => $value) { + $next = is_string($value) ? trim($value) : $value; + $next = $next === '' ? null : $next; + $before = $subject->getAttribute($field); + $before = $before === '' ? null : $before; + + if ($before === $next) { + continue; + } + + $subject->setAttribute($field, $next); + IdentityChange::query()->create([ + 'subject_type' => $subject->getMorphClass(), + 'subject_id' => $subject->getKey(), + 'field' => $field, + 'before' => $before, + 'after' => $next, + 'actor_id' => $actor?->id, + 'occurred_at' => now(), + ]); + } + + $subject->save(); + } +} diff --git a/app/Domain/Catalog/OfferCoverage.php b/app/Domain/Catalog/OfferCoverage.php new file mode 100644 index 0000000..6711c6e --- /dev/null +++ b/app/Domain/Catalog/OfferCoverage.php @@ -0,0 +1,38 @@ + $articles + * @return list + */ + public function missingLeaves(CompositionVersion $version, array $articles): array + { + $covered = []; + + foreach ($articles as $article) { + $release = $article->currentRelease; + if ($release === null) { + continue; + } + + foreach ($release->contents()->pluck('content_element_version_id') as $id) { + $covered[(int) $id] = true; + } + } + + $missing = []; + + foreach ($this->resolver->expand($version) as $row) { + if (! isset($covered[$row['version_id']])) { + $missing[] = $row['path']; + } + } + + return $missing; + } +} diff --git a/app/Domain/Catalog/OfferService.php b/app/Domain/Catalog/OfferService.php index cc82e89..a8f913b 100644 --- a/app/Domain/Catalog/OfferService.php +++ b/app/Domain/Catalog/OfferService.php @@ -89,6 +89,7 @@ public function activate(Offer $offer, array $lines, array $attributes = []): Of $this->assertAttributes($attributes); $scope = $this->scopeFor($lines); + $this->assertCoverage($lines, $attributes); return DB::transaction(function () use ($offer, $lines, $attributes, $scope): OfferVersion { $offer = Offer::query()->lockForUpdate()->findOrFail($offer->id); @@ -171,6 +172,34 @@ private function assertAttributes(array $attributes): void * @param list $lines * @return list */ + /** + * @param list $lines + * @param array $attributes + */ + private function assertCoverage(array $lines, array $attributes): void + { + $versionId = $attributes['composition_version_id'] ?? null; + + if ($versionId === null) { + return; + } + + $version = CompositionVersion::query()->findOrFail($versionId); + $articles = []; + + foreach ($lines as $line) { + if ($line['target'] instanceof LicenseArticle) { + $articles[] = $line['target']; + } + } + + $missing = app(OfferCoverage::class)->missingLeaves($version, $articles); + + if ($missing !== []) { + throw new DomainRuleException('Das Angebot deckt nicht alle Blätter: '.implode(', ', $missing)); + } + } + private function scopeFor(array $lines): array { $scope = []; diff --git a/app/Domain/Entitlement/MediaDelivery.php b/app/Domain/Entitlement/MediaDelivery.php new file mode 100644 index 0000000..9ea89db --- /dev/null +++ b/app/Domain/Entitlement/MediaDelivery.php @@ -0,0 +1,25 @@ + 'datetime', + ]; + } +} diff --git a/app/Filament/Resources/Compositions/Pages/EditComposition.php b/app/Filament/Resources/Compositions/Pages/EditComposition.php index 1411f39..c2bab64 100644 --- a/app/Filament/Resources/Compositions/Pages/EditComposition.php +++ b/app/Filament/Resources/Compositions/Pages/EditComposition.php @@ -11,6 +11,7 @@ use App\Domain\Catalog\ContentVersionStatus; use App\Domain\Catalog\DomainRuleException; use App\Domain\Catalog\EditorialContentKind; +use App\Domain\Catalog\IdentityProfile; use App\Filament\Resources\Combinations\CombinationResource; use App\Filament\Resources\Courses\CourseResource; use App\Filament\Resources\Exercises\ExerciseResource; @@ -22,6 +23,7 @@ use Filament\Forms\Components\Placeholder; use Filament\Forms\Components\Repeater; use Filament\Forms\Components\Select; +use Filament\Forms\Components\Textarea; use Filament\Forms\Components\TextInput; use Filament\Notifications\Notification; use Filament\Resources\Pages\EditRecord; @@ -44,6 +46,9 @@ public function form(Schema $schema): Schema { return $schema->columns(1)->components([ TextInput::make('designation')->label('Bezeichnung')->required(), + TextInput::make('display_title')->label('Anzeigetitel') + ->helperText('Erscheint in der Bibliothek. Leer lässt die Bezeichnung stehen.'), + Textarea::make('summary')->label('Kurzbeschreibung')->rows(3), Select::make('kind')->label('Art')->options(CompositionKind::options())->required() ->helperText('Übung, Kurs und fachliche Kombination sind verschiedene Zusammenstellungen. Die Art lässt sich hier ändern.'), Select::make('editorial_content_kind_id') @@ -153,6 +158,8 @@ protected function mutateFormDataBeforeFill(array $data): array return [ 'designation' => $composition->designation, + 'display_title' => $composition->display_title, + 'summary' => $composition->summary, 'kind' => $kind instanceof CompositionKind ? $kind->value : $kind, 'editorial_content_kind_id' => $composition->editorial_content_kind_id, 'members' => $members, @@ -169,6 +176,10 @@ protected function handleRecordUpdate(Model $record, array $data): Model try { $kind = CompositionKind::from($data['kind']); $record->designation = trim((string) $data['designation']); + app(IdentityProfile::class)->fill($record, [ + 'display_title' => $data['display_title'] ?? null, + 'summary' => $data['summary'] ?? null, + ], auth()->user()); $record->kind = $kind; $record->editorial_content_kind_id = filled($data['editorial_content_kind_id'] ?? null) ? (int) $data['editorial_content_kind_id'] diff --git a/app/Filament/Resources/ContentElements/Pages/EditContentElement.php b/app/Filament/Resources/ContentElements/Pages/EditContentElement.php index 7182907..9a0edfa 100644 --- a/app/Filament/Resources/ContentElements/Pages/EditContentElement.php +++ b/app/Filament/Resources/ContentElements/Pages/EditContentElement.php @@ -6,6 +6,7 @@ use App\Domain\Catalog\ContentService; use App\Domain\Catalog\DomainRuleException; use App\Domain\Catalog\EditorialContentKind; +use App\Domain\Catalog\IdentityProfile; use App\Domain\Catalog\Pillar; use App\Domain\Catalog\PillarService; use App\Filament\Resources\ContentElements\ContentElementResource; @@ -47,6 +48,9 @@ public function form(Schema $schema): Schema return new HtmlString('Medium und Fassungen ansehen'); }), TextInput::make('working_title')->label('Arbeitstitel')->required(), + TextInput::make('display_title')->label('Anzeigetitel') + ->helperText('Erscheint in der Bibliothek. Leer lässt den Arbeitstitel stehen. Speichern legt keine Fassung an.'), + Textarea::make('summary')->label('Kurzbeschreibung')->rows(3), Textarea::make('description')->label('Beschreibung')->rows(4) ->helperText('Gilt für das Medium, nicht für eine einzelne Fassung.'), Select::make('editorial_content_kind_id') @@ -121,7 +125,9 @@ protected function mutateFormDataBeforeFill(array $data): array { return [ 'working_title' => $this->getRecord()->working_title, + 'display_title' => $this->getRecord()->display_title, 'description' => $this->getRecord()->description, + 'summary' => $this->getRecord()->summary, 'pillars' => $this->getRecord()->pillars()->pluck('pillars.id')->all(), ]; } @@ -134,6 +140,10 @@ protected function handleRecordUpdate(Model $record, array $data): Model /** @var ContentElement $record */ try { app(ContentService::class)->describe($record, (string) $data['working_title'], $data['description'] ?? null); + app(IdentityProfile::class)->fill($record, [ + 'display_title' => $data['display_title'] ?? null, + 'summary' => $data['summary'] ?? null, + ], auth()->user()); app(PillarService::class)->assign($record, array_map(intval(...), $data['pillars'] ?? [])); } catch (DomainRuleException $exception) { Notification::make()->title($exception->getMessage())->danger()->send(); diff --git a/app/Http/Controllers/Member/LibraryController.php b/app/Http/Controllers/Member/LibraryController.php index 89040d8..33fd8eb 100644 --- a/app/Http/Controllers/Member/LibraryController.php +++ b/app/Http/Controllers/Member/LibraryController.php @@ -5,10 +5,12 @@ use App\Domain\Catalog\ArticleRelease; use App\Domain\Catalog\Composition; use App\Domain\Catalog\ContentElementVersion; +use App\Domain\Catalog\IdentityDimension; use App\Domain\Catalog\LicenseArticle; use App\Domain\Entitlement\DecideAccess; use App\Domain\Entitlement\Grant; use App\Domain\Entitlement\GrantStatus; +use App\Domain\Entitlement\MediaDelivery; use App\Http\Controllers\Controller; use App\Http\CourseOutline; use App\Http\LibraryCatalog; @@ -22,7 +24,42 @@ class LibraryController extends Controller { public function index(Request $request): View { - return view('member.library', app(LibraryCatalog::class)->index($request->user())); + $catalog = app(LibraryCatalog::class)->index($request->user()); + $query = trim((string) $request->query('q', '')); + + $dimensionIds = array_values(array_filter(array_map(intval(...), (array) $request->query('dimension', [])))); + $dimensions = app(IdentityDimension::class); + + if ($query !== '') { + $catalog['programs'] = array_values(array_filter( + $catalog['programs'], + fn (array $card): bool => $this->matches($card, $query), + )); + $catalog['materials'] = array_values(array_filter( + $catalog['materials'], + fn (array $card): bool => $this->matches($card, $query), + )); + } + + if ($dimensionIds !== []) { + $catalog['programs'] = array_values(array_filter( + $catalog['programs'], + fn (array $card): bool => $dimensions->matches($card['composition'], $dimensionIds), + )); + $catalog['materials'] = array_values(array_filter( + $catalog['materials'], + function (array $card) use ($dimensions, $dimensionIds): bool { + $release = $card['article']->currentRelease; + $subject = $release?->rootCompositionVersion?->composition + ?? $release?->rootElementVersion?->element + ?? $card['article']; + + return $dimensions->matches($subject, $dimensionIds); + }, + )); + } + + return view('member.library', [...$catalog, 'query' => $query]); } public function program(Request $request, Composition $composition): View @@ -104,6 +141,18 @@ public function media( $decision = app(DecideAccess::class)($request->user(), $article, $release, $version, $action); abort_unless($decision->allowed, 403, $decision->reason); + if ($decision->grant !== null) { + MediaDelivery::query()->create([ + 'grant_id' => $decision->grant->id, + 'license_article_id' => $article->id, + 'article_release_id' => $release->id, + 'content_element_version_id' => $version->id, + 'action' => $action, + 'format' => 'bestand', + 'delivered_at' => now(), + ]); + } + $version->loadMissing('element'); $file = $version->metadata['file'] ?? null; @@ -122,6 +171,16 @@ public function media( ]); } + /** + * @param array $card + */ + private function matches(array $card, string $query): bool + { + $haystack = mb_strtolower(($card['title'] ?? '').' '.($card['summary'] ?? '')); + + return str_contains($haystack, mb_strtolower($query)); + } + private function grantQuery(Request $request) { return Grant::query() diff --git a/app/Http/CourseOutline.php b/app/Http/CourseOutline.php index 37ca130..2c4df90 100644 --- a/app/Http/CourseOutline.php +++ b/app/Http/CourseOutline.php @@ -20,8 +20,13 @@ public function title(LicenseArticle $article): string 'rootElementVersion.element', ]); - return $release->rootCompositionVersion?->composition?->designation - ?? $release->rootElementVersion?->element?->working_title + $composition = $release->rootCompositionVersion?->composition; + $element = $release->rootElementVersion?->element; + + return (filled($composition?->display_title) ? $composition->display_title : null) + ?? $composition?->designation + ?? (filled($element?->display_title) ? $element->display_title : null) + ?? $element?->working_title ?? $release->classification_note ?? $article->code; } diff --git a/app/Http/LibraryCatalog.php b/app/Http/LibraryCatalog.php index 59472b7..ed800df 100644 --- a/app/Http/LibraryCatalog.php +++ b/app/Http/LibraryCatalog.php @@ -41,7 +41,8 @@ public function index(User $user): array $programs[$composition->id] = [ 'composition' => $composition, 'version' => $version, - 'title' => $composition->designation, + 'title' => filled($composition->display_title) ? $composition->display_title : $composition->designation, + 'summary' => $composition->summary, 'kind' => $composition->editorialContentKind?->label ?? ($composition->kind?->label()), ]; @@ -72,7 +73,8 @@ public function program(User $user, Composition $composition): array return [ 'composition' => $composition, - 'title' => $composition->designation, + 'title' => filled($composition->display_title) ? $composition->display_title : $composition->designation, + 'summary' => $composition->summary, 'kind' => $composition->editorialContentKind?->label ?? ($composition->kind?->label()), 'nodes' => array_map( diff --git a/database/migrations/2026_11_16_130000_identity_display_fields.php b/database/migrations/2026_11_16_130000_identity_display_fields.php new file mode 100644 index 0000000..7498a53 --- /dev/null +++ b/database/migrations/2026_11_16_130000_identity_display_fields.php @@ -0,0 +1,45 @@ +string('display_title')->nullable()->after('working_title'); + $table->text('summary')->nullable()->after('description'); + }); + + Schema::table('compositions', function (Blueprint $table) { + $table->string('display_title')->nullable()->after('designation'); + $table->text('summary')->nullable()->after('display_title'); + }); + + Schema::create('identity_changes', function (Blueprint $table) { + $table->id(); + $table->string('subject_type'); + $table->unsignedBigInteger('subject_id'); + $table->string('field'); + $table->text('before')->nullable(); + $table->text('after')->nullable(); + $table->foreignId('actor_id')->nullable()->constrained('users')->nullOnDelete(); + $table->timestamp('occurred_at'); + $table->timestamps(); + $table->index(['subject_type', 'subject_id']); + }); + } + + public function down(): void + { + Schema::dropIfExists('identity_changes'); + Schema::table('compositions', function (Blueprint $table) { + $table->dropColumn(['display_title', 'summary']); + }); + Schema::table('content_elements', function (Blueprint $table) { + $table->dropColumn(['display_title', 'summary']); + }); + } +}; diff --git a/database/migrations/2026_11_16_140000_editorial_dimensions.php b/database/migrations/2026_11_16_140000_editorial_dimensions.php new file mode 100644 index 0000000..26009fe --- /dev/null +++ b/database/migrations/2026_11_16_140000_editorial_dimensions.php @@ -0,0 +1,75 @@ +id(); + $table->string('slug')->unique(); + $table->string('label'); + $table->timestamps(); + }); + + Schema::create('editorial_dimension_values', function (Blueprint $table) { + $table->id(); + $table->foreignId('editorial_dimension_id')->constrained()->cascadeOnDelete(); + $table->string('slug'); + $table->string('label'); + $table->timestamps(); + $table->unique(['editorial_dimension_id', 'slug']); + }); + + Schema::create('identity_dimension_values', function (Blueprint $table) { + $table->id(); + $table->string('subject_type'); + $table->unsignedBigInteger('subject_id'); + $table->foreignId('editorial_dimension_value_id')->constrained()->cascadeOnDelete(); + $table->string('origin'); + $table->timestamps(); + $table->unique(['subject_type', 'subject_id', 'editorial_dimension_value_id'], 'identity_dimension_unique'); + }); + + $now = now(); + $dimensionId = DB::table('editorial_dimensions')->insertGetId([ + 'slug' => 'saeule', + 'label' => 'Fachliche Säule', + 'created_at' => $now, + 'updated_at' => $now, + ]); + + foreach (DB::table('pillars')->orderBy('id')->get() as $pillar) { + $slug = 'pfeiler-'.$pillar->id; + $valueId = DB::table('editorial_dimension_values')->insertGetId([ + 'editorial_dimension_id' => $dimensionId, + 'slug' => $slug, + 'label' => $pillar->name, + 'created_at' => $now, + 'updated_at' => $now, + ]); + + foreach (DB::table('content_element_pillar')->where('pillar_id', $pillar->id)->get() as $link) { + DB::table('identity_dimension_values')->insert([ + 'subject_type' => 'App\\Domain\\Catalog\\ContentElement', + 'subject_id' => $link->content_element_id, + 'editorial_dimension_value_id' => $valueId, + 'origin' => 'direkt', + 'created_at' => $now, + 'updated_at' => $now, + ]); + } + } + } + + public function down(): void + { + Schema::dropIfExists('identity_dimension_values'); + Schema::dropIfExists('editorial_dimension_values'); + Schema::dropIfExists('editorial_dimensions'); + } +}; diff --git a/database/migrations/2026_11_16_150000_media_deliveries.php b/database/migrations/2026_11_16_150000_media_deliveries.php new file mode 100644 index 0000000..f54c497 --- /dev/null +++ b/database/migrations/2026_11_16_150000_media_deliveries.php @@ -0,0 +1,28 @@ +id(); + $table->foreignId('grant_id')->constrained()->restrictOnDelete(); + $table->foreignId('license_article_id')->constrained()->restrictOnDelete(); + $table->foreignId('article_release_id')->constrained()->restrictOnDelete(); + $table->foreignId('content_element_version_id')->constrained()->restrictOnDelete(); + $table->string('action'); + $table->string('format'); + $table->timestamp('delivered_at'); + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('media_deliveries'); + } +}; diff --git a/resources/views/member/library.blade.php b/resources/views/member/library.blade.php index 4cb09cc..4c4a5be 100644 --- a/resources/views/member/library.blade.php +++ b/resources/views/member/library.blade.php @@ -5,6 +5,14 @@ @section('content') @include('member.partials.nav')

Bibliothek

+
+ + + + @if (filled($query ?? null)) + Zurücksetzen + @endif +

Programme zeigen den Aufbau. Einzelne Materialien stehen darunter, solange sie zu keinem freigegebenen Programm gehören.

@if ($programs === [] && $materials === [])
diff --git a/resources/views/member/program.blade.php b/resources/views/member/program.blade.php index b92cead..8cf0dfd 100644 --- a/resources/views/member/program.blade.php +++ b/resources/views/member/program.blade.php @@ -9,5 +9,8 @@ @if ($kind)

{{ $kind }}

@endif + @if (filled($summary ?? null)) +

{{ $summary }}

+ @endif @include('member.partials.structure', ['nodes' => $nodes]) @endsection diff --git a/tests/Feature/CatalogFollowThroughTest.php b/tests/Feature/CatalogFollowThroughTest.php new file mode 100644 index 0000000..5378032 --- /dev/null +++ b/tests/Feature/CatalogFollowThroughTest.php @@ -0,0 +1,90 @@ +publishElementVersion($content->createElement('film', 'film', 'Film'), null, ['file' => 'inhalte/a.mp4']); + $sheet = $content->publishElementVersion($content->createElement('text', 'document', 'Blatt'), 'Text'); + $program = $content->publishComposition($content->createComposition('Programm'), [ + ['role' => 'Film', 'target' => $film], + ['role' => 'Blatt', 'target' => $sheet], + ]); + $articles = app(ArticleService::class); + $filmArticle = $articles->create('nur-film'); + $articles->publishRelease($filmArticle, $film, 'Nur der Film.'); + $offers = app(OfferService::class); + $rights = $offers->createRightsProfile('Film', 'ehrenamtlich', ['film' => ['streamen']]); + + $this->expectException(DomainRuleException::class); + $offers->activate($offers->create('Lückenhaft'), [ + ['target' => $filmArticle->fresh(), 'rights' => $rights], + ], [ + 'grant_kind' => 'kauf', + 'price_cents' => 100, + 'composition_version_id' => $program->id, + ]); + } + + public function test_a_dimension_filters_the_library_and_a_delivery_is_recorded(): void + { + Storage::fake('media_derived'); + Storage::disk('media_derived')->put('inhalte/demo.txt', 'text'); + $content = app(ContentService::class); + $version = $content->publishElementVersion( + $content->createElement('text', 'text', 'Filterblatt'), + null, + ['file' => 'inhalte/demo.txt'], + ); + $dimension = EditorialDimension::query()->create(['slug' => 'alter', 'label' => 'Alter']); + $value = EditorialDimensionValue::query()->create([ + 'editorial_dimension_id' => $dimension->id, + 'slug' => 'grundschule', + 'label' => 'Grundschule', + ]); + app(IdentityDimension::class)->assign($version->element, $value); + $articles = app(ArticleService::class); + $article = $articles->create('filter'); + $release = $articles->publishRelease($article, $version, 'Eigenständig.'); + $offers = app(OfferService::class); + $rights = $offers->createRightsProfile('Lesen', 'ehrenamtlich', ['text' => ['ansehen']]); + $offer = $offers->create('Filterangebot'); + $offers->activate($offer, [['target' => $article->fresh(), 'rights' => $rights]], ['grant_kind' => 'auf_abruf']); + $member = User::factory()->create(); + app(GrantIssuer::class)->claim($member, $offer); + + $this->actingAs($member)->get(route('member.library', ['dimension' => [$value->id]]))->assertOk()->assertSee('Filterblatt'); + $this->actingAs($member)->get(route('member.library', ['dimension' => [999]]))->assertOk()->assertDontSee('Filterblatt'); + + $url = SignedLink::temporary('member.media', now()->addMinutes(5), [ + 'article' => $article->id, + 'release' => $release->id, + 'version' => $version->id, + 'action' => 'ansehen', + 'reader' => $member->id, + ]); + $this->actingAs($member)->get($url)->assertOk(); + $this->assertSame(1, MediaDelivery::query()->count()); + $this->assertSame('ansehen', MediaDelivery::query()->first()->action); + } +} diff --git a/tests/Feature/IdentityProfileTest.php b/tests/Feature/IdentityProfileTest.php new file mode 100644 index 0000000..f406c1f --- /dev/null +++ b/tests/Feature/IdentityProfileTest.php @@ -0,0 +1,51 @@ +publishElementVersion($content->createElement('text', 'text', 'Arbeitstitel'), 'Text'); + $element = $version->element; + $article = app(ArticleService::class)->create('stamm'); + app(ArticleService::class)->publishRelease($article, $version, 'Eigenständig.'); + $offers = app(OfferService::class); + $rights = $offers->createRightsProfile('Lesen', 'ehrenamtlich', ['text' => ['ansehen']]); + $offer = $offers->create('Stammangebot'); + $offers->activate($offer, [['target' => $article->fresh(), 'rights' => $rights]], ['grant_kind' => 'auf_abruf']); + $member = User::factory()->create(); + app(GrantIssuer::class)->claim($member, $offer); + + $versions = $element->versions()->count(); + $releases = $article->releases()->count(); + app(IdentityProfile::class)->fill($element, [ + 'display_title' => 'Sichtbarer Titel', + 'summary' => 'Kurz für die Bibliothek', + ], $member); + + $this->assertSame($versions, $element->fresh()->versions()->count()); + $this->assertSame($releases, $article->fresh()->releases()->count()); + $this->assertSame('Sichtbarer Titel', app(CourseOutline::class)->title($article->fresh())); + $change = IdentityChange::query()->where('field', 'display_title')->first(); + $this->assertSame($member->id, $change->actor_id); + $this->assertNotNull($change->occurred_at); + + $this->actingAs($member)->get(route('member.library', ['q' => 'Sichtbarer']))->assertOk()->assertSee('Sichtbarer Titel'); + $this->actingAs($member)->get(route('member.library', ['q' => 'kommt-nicht-vor']))->assertOk()->assertDontSee('Sichtbarer Titel'); + } +}