Zeige Nutzbarkeit, Didaktik und oeffentliche Programmfassung
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
5e763d15ec
commit
c99a957e6f
17 files changed
+307
-6
No files matched your search
@@ -12,6 +12,10 @@ class Composition extends Model
|
||||
'designation',
|
||||
'display_title',
|
||||
'summary',
|
||||
'thumbnail_path',
|
||||
'thumbnail_alt',
|
||||
'thumbnail_error',
|
||||
'public_slug',
|
||||
'kind',
|
||||
'editorial_content_kind_id',
|
||||
'archived_at',
|
||||
|
||||
@@ -14,6 +14,9 @@ class CompositionVersion extends Model
|
||||
'status',
|
||||
'members_hash',
|
||||
'resolved_hash',
|
||||
'learning_goal',
|
||||
'duration_minutes',
|
||||
'material_note',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
|
||||
@@ -16,6 +16,9 @@ class ContentElement extends Model
|
||||
'display_title',
|
||||
'description',
|
||||
'summary',
|
||||
'thumbnail_path',
|
||||
'thumbnail_alt',
|
||||
'thumbnail_error',
|
||||
'editorial_content_kind_id',
|
||||
'archived_at',
|
||||
];
|
||||
|
||||
@@ -86,6 +86,7 @@ public function publishComposition(
|
||||
array $members,
|
||||
?User $confirmedBy = null,
|
||||
?string $note = null,
|
||||
array $didactic = [],
|
||||
): CompositionVersion {
|
||||
if ($members === []) {
|
||||
throw new DomainRuleException('Eine Komposition braucht mindestens ein Mitglied.');
|
||||
@@ -97,13 +98,16 @@ public function publishComposition(
|
||||
$this->assertReadyMember($member['target']);
|
||||
}
|
||||
|
||||
return DB::transaction(function () use ($composition, $members, $confirmedBy, $note): CompositionVersion {
|
||||
return DB::transaction(function () use ($composition, $members, $confirmedBy, $note, $didactic): CompositionVersion {
|
||||
$number = ((int) $composition->versions()->max('number')) + 1;
|
||||
$version = $composition->versions()->create([
|
||||
'number' => $number,
|
||||
'status' => ContentVersionStatus::Entwurf,
|
||||
'members_hash' => $this->membersHash($members),
|
||||
'resolved_hash' => 'pending',
|
||||
'learning_goal' => $this->optionalText($didactic['learning_goal'] ?? null),
|
||||
'duration_minutes' => isset($didactic['duration_minutes']) ? (int) $didactic['duration_minutes'] : null,
|
||||
'material_note' => $this->optionalText($didactic['material_note'] ?? null),
|
||||
]);
|
||||
|
||||
foreach (array_values($members) as $index => $member) {
|
||||
@@ -219,6 +223,17 @@ private function membersHash(array $members): string
|
||||
return hash('sha256', json_encode($list, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
private function optionalText(mixed $value): ?string
|
||||
{
|
||||
if (! is_string($value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$value = trim($value);
|
||||
|
||||
return $value === '' ? null : $value;
|
||||
}
|
||||
|
||||
private function required(string $value, string $message): string
|
||||
{
|
||||
$value = trim($value);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Domain\Catalog\CompositionMember;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
@@ -56,6 +57,20 @@ public function form(Schema $schema): Schema
|
||||
->options(fn (): array => EditorialContentKind::selectOptions())
|
||||
->nullable()
|
||||
->helperText('Optional für Bibliothek und Website. Ändert weder die technische Art noch eine Fassung.'),
|
||||
Placeholder::make('usage')->label('Verwendung')->content(function (): HtmlString {
|
||||
$version = $this->currentReadyVersion();
|
||||
if ($version === null) {
|
||||
return new HtmlString('Noch keine Fassung.');
|
||||
}
|
||||
$lines = CompositionMember::query()
|
||||
->where('nested_composition_version_id', $version->id)
|
||||
->with('compositionVersion.composition')
|
||||
->get()
|
||||
->map(fn (CompositionMember $member): string => ($member->compositionVersion->composition->designation ?? 'Programm').' · '.$member->role)
|
||||
->all();
|
||||
|
||||
return new HtmlString($lines === [] ? 'In keiner anderen Fassung enthalten.' : e(implode(' · ', $lines)));
|
||||
}),
|
||||
Placeholder::make('history')->label('Aktuelle Fassung')->content(function (): HtmlString {
|
||||
/** @var Composition $composition */
|
||||
$composition = $this->getRecord();
|
||||
|
||||
@@ -160,6 +160,7 @@ public function media(
|
||||
return view('member.read', [
|
||||
'article' => $article,
|
||||
'version' => $version,
|
||||
'license' => $decision->grant?->rights_snapshot['purpose'] ?? null,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||
use App\Domain\Catalog\CompositionStructureReader;
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class PublicCatalogController extends Controller
|
||||
{
|
||||
public function index(): View
|
||||
{
|
||||
$kind = EditorialContentKind::query()->where('slug', 'programm')->first();
|
||||
$programs = Composition::query()
|
||||
->when($kind !== null, fn ($query) => $query->where('editorial_content_kind_id', $kind->id))
|
||||
->orderBy('designation')
|
||||
->get()
|
||||
->filter(fn (Composition $composition): bool => app(CompositionDisplayRelease::class)->highestReleasedVersion($composition) !== null);
|
||||
|
||||
return view('public.programs', ['programs' => $programs]);
|
||||
}
|
||||
|
||||
public function program(Composition $composition): View
|
||||
{
|
||||
$kind = $composition->editorialContentKind;
|
||||
abort_unless($kind?->slug === 'programm', 404);
|
||||
$version = app(CompositionDisplayRelease::class)->highestReleasedVersion($composition);
|
||||
abort_if($version === null, 404);
|
||||
|
||||
return view('public.program', [
|
||||
'composition' => $composition,
|
||||
'version' => $version,
|
||||
'nodes' => app(CompositionStructureReader::class)->tree($version),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||
use App\Domain\Catalog\CompositionStructureReader;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ReleaseStatus;
|
||||
use App\Domain\Catalog\StructureNode;
|
||||
@@ -71,16 +72,24 @@ public function program(User $user, Composition $composition): array
|
||||
$version = $this->display->highestReleasedVersion($composition);
|
||||
abort_if($version === null, 404);
|
||||
|
||||
$nodes = array_map(
|
||||
fn (StructureNode $node): array => $this->present($user, $node),
|
||||
$this->structure->tree($version),
|
||||
);
|
||||
$leaves = $this->leaves($nodes);
|
||||
$open = count(array_filter($leaves, fn (array $leaf): bool => $leaf['view_url'] !== null));
|
||||
|
||||
return [
|
||||
'composition' => $composition,
|
||||
'title' => filled($composition->display_title) ? $composition->display_title : $composition->designation,
|
||||
'summary' => $composition->summary,
|
||||
'kind' => $composition->editorialContentKind?->label
|
||||
?? ($composition->kind?->label()),
|
||||
'nodes' => array_map(
|
||||
fn (StructureNode $node): array => $this->present($user, $node),
|
||||
$this->structure->tree($version),
|
||||
),
|
||||
'learning_goal' => $version->learning_goal,
|
||||
'duration_minutes' => $version->duration_minutes,
|
||||
'material_note' => $version->material_note,
|
||||
'coverage' => $leaves === [] ? 'nicht nutzbar' : ($open === count($leaves) ? 'vollständig' : ($open === 0 ? 'nicht nutzbar' : 'teilweise')),
|
||||
'nodes' => $nodes,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -104,6 +113,7 @@ private function present(User $user, StructureNode $node): array
|
||||
'output_class' => $node->outputClass,
|
||||
'view_url' => $view,
|
||||
'download_url' => $download,
|
||||
'program_url' => $this->programUrl($node),
|
||||
'children' => array_map(
|
||||
fn (StructureNode $child): array => $this->present($user, $child),
|
||||
$node->children,
|
||||
@@ -111,6 +121,42 @@ private function present(User $user, StructureNode $node): array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $nodes
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
private function leaves(array $nodes): array
|
||||
{
|
||||
$leaves = [];
|
||||
|
||||
foreach ($nodes as $node) {
|
||||
if ($node['children'] === []) {
|
||||
$leaves[] = $node;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$leaves = [...$leaves, ...$this->leaves($node['children'])];
|
||||
}
|
||||
|
||||
return $leaves;
|
||||
}
|
||||
|
||||
private function programUrl(StructureNode $node): ?string
|
||||
{
|
||||
if ($node->compositionId === null || $node->compositionVersionId === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$version = CompositionVersion::query()->find($node->compositionVersionId);
|
||||
|
||||
if ($version === null || ! $this->display->isReleased($version)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return route('member.program', $node->compositionId);
|
||||
}
|
||||
|
||||
private function viewAction(?string $outputClass): string
|
||||
{
|
||||
return in_array($outputClass, ['film', 'audio'], true) ? 'streamen' : 'ansehen';
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
foreach (['content_elements', 'compositions'] as $tableName) {
|
||||
Schema::table($tableName, function (Blueprint $table) {
|
||||
$table->string('thumbnail_path')->nullable();
|
||||
$table->string('thumbnail_alt')->nullable();
|
||||
$table->string('thumbnail_error')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
Schema::table('compositions', function (Blueprint $table) {
|
||||
$table->string('public_slug')->nullable()->unique();
|
||||
});
|
||||
|
||||
Schema::table('composition_versions', function (Blueprint $table) {
|
||||
$table->text('learning_goal')->nullable();
|
||||
$table->unsignedSmallInteger('duration_minutes')->nullable();
|
||||
$table->text('material_note')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('composition_versions', function (Blueprint $table) {
|
||||
$table->dropColumn(['learning_goal', 'duration_minutes', 'material_note']);
|
||||
});
|
||||
Schema::table('compositions', function (Blueprint $table) {
|
||||
$table->dropColumn(['thumbnail_path', 'thumbnail_alt', 'thumbnail_error', 'public_slug']);
|
||||
});
|
||||
Schema::table('content_elements', function (Blueprint $table) {
|
||||
$table->dropColumn(['thumbnail_path', 'thumbnail_alt', 'thumbnail_error']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -26,6 +26,10 @@
|
||||
@foreach ($programs as $program)
|
||||
<li>
|
||||
<a href="{{ route('member.program', $program['composition']) }}"><strong>{{ $program['kind'] ? $program['kind'].': ' : '' }}{{ $program['title'] }}</strong></a>
|
||||
<span>{{ filled($program['composition']->thumbnail_path) ? ($program['composition']->thumbnail_alt ?: 'Vorschaubild') : 'Platzhalter' }}</span>
|
||||
@if (filled($program['composition']->thumbnail_error))
|
||||
<span>{{ $program['composition']->thumbnail_error }}</span>
|
||||
@endif
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<ol class="course">
|
||||
@foreach ($nodes as $node)
|
||||
<li>
|
||||
<h2>{{ $node['role'] }}: {{ $node['title'] }}</h2>
|
||||
<h2>{{ $node['role'] }}: @if ($node['program_url'] ?? null)<a href="{{ $node['program_url'] }}">{{ $node['title'] }}</a>@else{{ $node['title'] }}@endif</h2>
|
||||
@if ($node['kind'])
|
||||
<p>{{ $node['kind'] }}</p>
|
||||
@endif
|
||||
|
||||
@@ -12,5 +12,19 @@
|
||||
@if (filled($summary ?? null))
|
||||
<p class="lede">{{ $summary }}</p>
|
||||
@endif
|
||||
<p>Nutzbarkeit: {{ $coverage }}</p>
|
||||
<p>{{ filled($composition->thumbnail_path) ? ($composition->thumbnail_alt ?: 'Vorschaubild') : 'Platzhalter' }}</p>
|
||||
@if (filled($composition->thumbnail_error))
|
||||
<p>{{ $composition->thumbnail_error }}</p>
|
||||
@endif
|
||||
@if (filled($learning_goal))
|
||||
<p>Lernziel: {{ $learning_goal }}</p>
|
||||
@endif
|
||||
@if ($duration_minutes)
|
||||
<p>Zeit: {{ $duration_minutes }} Minuten</p>
|
||||
@endif
|
||||
@if (filled($material_note))
|
||||
<p>Material: {{ $material_note }}</p>
|
||||
@endif
|
||||
@include('member.partials.structure', ['nodes' => $nodes])
|
||||
@endsection
|
||||
@@ -5,6 +5,9 @@
|
||||
@section('content')
|
||||
@include('member.partials.nav')
|
||||
<h1>{{ $version->element->working_title }}</h1>
|
||||
@if (filled($license ?? null))
|
||||
<p>Lizenzkennzeichnung: {{ $license }}</p>
|
||||
@endif
|
||||
<article class="prose">
|
||||
{!! nl2br(e($version->body)) !!}
|
||||
</article>
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
@extends('layouts.site')
|
||||
|
||||
@section('title', $composition->display_title ?: $composition->designation)
|
||||
|
||||
@section('content')
|
||||
<p><a href="{{ route('public.programs') }}">Programme</a></p>
|
||||
<h1>{{ $composition->display_title ?: $composition->designation }}</h1>
|
||||
@if (filled($composition->summary))
|
||||
<p class="lede">{{ $composition->summary }}</p>
|
||||
@endif
|
||||
@if (filled($version->learning_goal))
|
||||
<p>Lernziel: {{ $version->learning_goal }}</p>
|
||||
@endif
|
||||
<ol class="course">
|
||||
@foreach ($nodes as $node)
|
||||
<li>
|
||||
<h2>{{ $node->role }}: {{ $node->title }}</h2>
|
||||
@if ($node->children !== [])
|
||||
<ol>
|
||||
@foreach ($node->children as $child)
|
||||
<li>{{ $child->role }}: {{ $child->title }}</li>
|
||||
@endforeach
|
||||
</ol>
|
||||
@endif
|
||||
</li>
|
||||
@endforeach
|
||||
</ol>
|
||||
@endsection
|
||||
@@ -0,0 +1,17 @@
|
||||
@extends('layouts.site')
|
||||
|
||||
@section('title', 'Programme')
|
||||
|
||||
@section('content')
|
||||
<h1>Programme</h1>
|
||||
<p class="lede">Gezeigt wird nur eine zur Anzeige freigegebene Programmfassung. Dateien bleiben im Mitgliederbereich.</p>
|
||||
@if ($programs->isEmpty())
|
||||
<div class="empty"><p>Noch kein Programm ist öffentlich gelistet.</p></div>
|
||||
@else
|
||||
<ul class="catalog">
|
||||
@foreach ($programs as $program)
|
||||
<li><a href="{{ route('public.program', $program) }}"><strong>{{ $program->display_title ?: $program->designation }}</strong></a></li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
@endsection
|
||||
@@ -9,6 +9,7 @@
|
||||
use App\Http\Controllers\Member\LibraryController;
|
||||
use App\Http\Controllers\Member\MemberController;
|
||||
use App\Http\Controllers\PageController;
|
||||
use App\Http\Controllers\PublicCatalogController;
|
||||
use App\Http\Controllers\PublicMediaController;
|
||||
use App\Http\Controllers\ThemeController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
@@ -16,6 +17,8 @@
|
||||
Route::get('/', [PageController::class, 'home'])->name('home');
|
||||
Route::get('/sitemap.xml', [PageController::class, 'sitemap'])->name('sitemap');
|
||||
Route::get('/themen', [ThemeController::class, 'index'])->name('themes');
|
||||
Route::get('/programme', [PublicCatalogController::class, 'index'])->name('public.programs');
|
||||
Route::get('/programme/{composition}', [PublicCatalogController::class, 'program'])->name('public.program');
|
||||
Route::get('/themen/{slug}', [ThemeController::class, 'show'])->name('theme')->where('slug', '[a-z0-9]+(?:-[a-z0-9]+)*');
|
||||
Route::get('/medien/{path}', [PublicMediaController::class, 'show'])->where('path', '.*')->name('media.public');
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\ArticleService;
|
||||
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Entitlement\GrantIssuer;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class LibraryCompletionTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_didactic_fields_partial_coverage_and_public_page_follow_the_released_version(): void
|
||||
{
|
||||
$content = app(ContentService::class);
|
||||
$film = $content->publishElementVersion($content->createElement('film', 'film', 'Hof'), null, ['file' => 'inhalte/hof.mp4']);
|
||||
$sheet = $content->publishElementVersion($content->createElement('text', 'document', 'Blatt'), 'Text');
|
||||
$programm = EditorialContentKind::query()->where('slug', 'programm')->firstOrFail();
|
||||
$version = $content->publishComposition(
|
||||
tap($content->createComposition('Öffentliches Programm'), function ($item) use ($programm): void {
|
||||
$item->editorial_content_kind_id = $programm->id;
|
||||
$item->thumbnail_error = 'Kein Bild erzeugt.';
|
||||
$item->save();
|
||||
}),
|
||||
[
|
||||
['role' => 'Film', 'target' => $film],
|
||||
['role' => 'Blatt', 'target' => $sheet],
|
||||
],
|
||||
null,
|
||||
null,
|
||||
['learning_goal' => 'Abstand halten', 'duration_minutes' => 20, 'material_note' => 'Ein Blatt'],
|
||||
);
|
||||
$articles = app(ArticleService::class);
|
||||
$filmArticle = $articles->create('nur-film-fertig');
|
||||
$articles->publishRelease($filmArticle, $film, 'Nur Film.');
|
||||
$offers = app(OfferService::class);
|
||||
$rights = $offers->createRightsProfile('Film', 'ehrenamtlich', ['film' => ['streamen']]);
|
||||
$offer = $offers->create('Teilprogramm');
|
||||
$offers->activate($offer, [['target' => $filmArticle->fresh(), 'rights' => $rights]], ['grant_kind' => 'auf_abruf']);
|
||||
$member = User::factory()->create();
|
||||
app(GrantIssuer::class)->claim($member, $offer);
|
||||
app(CompositionDisplayRelease::class)->release($version, $member);
|
||||
|
||||
$this->actingAs($member)->get(route('member.program', $version->composition))
|
||||
->assertOk()
|
||||
->assertSee('teilweise')
|
||||
->assertSee('Abstand halten')
|
||||
->assertSee('Kein Bild erzeugt.')
|
||||
->assertSee('Platzhalter');
|
||||
|
||||
$this->get(route('public.program', $version->composition))
|
||||
->assertOk()
|
||||
->assertSee('Öffentliches Programm')
|
||||
->assertSee('Abstand halten')
|
||||
->assertDontSee('inhalte/hof.mp4');
|
||||
|
||||
$this->get('/medien/bibliothek/geheim.jpg')->assertNotFound();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user