Merge remote-tracking branch 'origin/develop' into feature/merkmale-symbol-seite
No files matched your search
@@ -13,6 +13,8 @@ class Offer extends Model
|
|||||||
'composition_id',
|
'composition_id',
|
||||||
'option_label',
|
'option_label',
|
||||||
'standalone_bundle',
|
'standalone_bundle',
|
||||||
|
'claim_access',
|
||||||
|
'claim_requires_article_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected function casts(): array
|
protected function casts(): array
|
||||||
@@ -31,6 +33,12 @@ public function composition(): BelongsTo
|
|||||||
return $this->belongsTo(Composition::class);
|
return $this->belongsTo(Composition::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Freigaben einzelner Konten für den Abruf (nur bei Vergabe „auf Abruf“ mit der Regel „freigeschaltete Konten“). */
|
||||||
|
public function releases(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(OfferRelease::class);
|
||||||
|
}
|
||||||
|
|
||||||
/** Bezeichnung der Option auf der Produktseite. */
|
/** Bezeichnung der Option auf der Produktseite. */
|
||||||
public function optionName(): string
|
public function optionName(): string
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Catalog;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Carbon\CarbonInterface;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Freigabe eines Kontos für ein Angebot „auf Abruf“ (ADR-56). Gilt je Angebot und Konto, wird nie gelöscht, nur entzogen.
|
||||||
|
*/
|
||||||
|
class OfferRelease extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'offer_id',
|
||||||
|
'user_id',
|
||||||
|
'granted_by',
|
||||||
|
'granted_at',
|
||||||
|
'valid_until',
|
||||||
|
'revoked_by',
|
||||||
|
'revoked_at',
|
||||||
|
'reason',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected function casts(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'granted_at' => 'datetime',
|
||||||
|
'valid_until' => 'datetime',
|
||||||
|
'revoked_at' => 'datetime',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function offer(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Offer::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function user(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function grantor(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'granted_by');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isActiveAt(CarbonInterface $now): bool
|
||||||
|
{
|
||||||
|
return $this->revoked_at === null
|
||||||
|
&& $this->granted_at->lessThanOrEqualTo($now)
|
||||||
|
&& ($this->valid_until === null || $this->valid_until->greaterThan($now));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,194 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Cms\Widgets\Types;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\EditorialContentKind;
|
||||||
|
use App\Domain\Catalog\Pillar;
|
||||||
|
use App\Domain\Cms\Widgets\RenderContext;
|
||||||
|
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||||
|
use App\Domain\Cms\Widgets\WidgetType;
|
||||||
|
use App\Domain\Commerce\Shop;
|
||||||
|
use App\Domain\Commerce\ShopCatalog;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\Textarea;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shop-Produkte (ADR-55): die kaufbaren Produkte als Kacheln, aus derselben Datenquelle wie die Shopseite (ShopCatalog).
|
||||||
|
*
|
||||||
|
* Gespeichert werden nur Darstellungswahl und Filter (Säule, Materialart); Titel, Bild, Preis und Marker kommen zur
|
||||||
|
* Laufzeit aus den Fachdaten. Das Widget zeigt nichts, solange der Shop nicht sichtbar ist (Schalter „Shop sichtbar“).
|
||||||
|
* Eine Kachel begründet keine Berechtigung. Anders als Programm- und Modulkarten trägt es Preise und führt zur Produktseite.
|
||||||
|
*/
|
||||||
|
class ShopProductsWidget extends WidgetType
|
||||||
|
{
|
||||||
|
public function key(): string
|
||||||
|
{
|
||||||
|
return 'shop_products';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return 'Shop-Produkte';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function description(): string
|
||||||
|
{
|
||||||
|
return 'Die kaufbaren Produkte des Shops als Kacheln mit Bild, Marker und Preis; optional gefiltert und sortiert.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function supportedUnits(): array
|
||||||
|
{
|
||||||
|
return [2, 3, 4];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function minUnits(): int
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function preferredUnits(): int
|
||||||
|
{
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function narrowBehavior(): string
|
||||||
|
{
|
||||||
|
return 'Die Kacheln stehen untereinander; ab etwa 17 rem Kachelbreite mehrere nebeneinander.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function stages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'narrow' => 'eine Kachel je Zeile',
|
||||||
|
'wide' => 'mehrere Kacheln nebeneinander ab 17 rem Kachelbreite',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function icon(): string
|
||||||
|
{
|
||||||
|
return 'heroicon-o-shopping-bag';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function schematic(): array
|
||||||
|
{
|
||||||
|
return [[2, 4, 17, 28, 'line'], [21, 4, 17, 28, 'line'], [40, 4, 17, 28, 'line'], [4, 6, 13, 10, 'image'], [23, 6, 13, 10, 'image'], [42, 6, 13, 10, 'image'], [4, 19, 11, 3, 'ink'], [23, 19, 11, 3, 'ink'], [42, 19, 11, 3, 'ink'], [4, 26, 7, 3, 'accent'], [23, 26, 7, 3, 'accent'], [42, 26, 7, 3, 'accent']];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function variants(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'kacheln' => 'Kacheln mit Bild',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function settings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'sort' => ['name' => 'Alphabetisch', 'neu' => 'Neueste zuerst', 'preis' => 'Preis aufsteigend'],
|
||||||
|
'limit' => ['alle' => 'Alle Produkte', 'n3' => '3 Produkte', 'n6' => '6 Produkte', 'n9' => '9 Produkte', 'n12' => '12 Produkte', 'n24' => '24 Produkte'],
|
||||||
|
'search' => ['aus' => 'Ohne Suchfeld', 'an' => 'Mit Suchfeld'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function settingLabels(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'sort' => ['Reihenfolge', 'Ohne Wahl gilt die Reihenfolge der Shopseite: Altbestand, Artikel, Pakete.'],
|
||||||
|
'limit' => ['Anzahl', 'Wie viele Produkte höchstens erscheinen. Ohne Wahl erscheinen alle.'],
|
||||||
|
'search' => ['Suchfeld', 'Ein Suchfeld über den Kacheln. Es wirkt auf der Shopseite; auf anderen Seiten führt die Suche in den Shop.'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function settingGroups(): array
|
||||||
|
{
|
||||||
|
return ['Auswahl' => ['sort', 'limit', 'search']];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataRules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'heading' => ['nullable', 'string', 'max:160'],
|
||||||
|
'intro' => ['nullable', 'string', 'max:400'],
|
||||||
|
'pillar' => ['nullable', 'integer'],
|
||||||
|
'kind' => ['nullable', 'integer'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataFields(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
TextInput::make('heading')->label('Abschnittsüberschrift (optional)')->maxLength(160),
|
||||||
|
Textarea::make('intro')->label('Einleitung (optional)')->rows(2)->maxLength(400),
|
||||||
|
Select::make('pillar')
|
||||||
|
->label('Nur Produkte einer Säule (optional)')
|
||||||
|
->helperText('Nur veröffentlichte Säulen sind wählbar. Ohne Wahl erscheinen alle Produkte.')
|
||||||
|
->options(fn (): array => Pillar::query()->published()->pluck('name', 'id')->all())
|
||||||
|
->placeholder('Alle Säulen')
|
||||||
|
->native(false),
|
||||||
|
Select::make('kind')
|
||||||
|
->label('Nur eine Materialart (optional)')
|
||||||
|
->options(fn (): array => EditorialContentKind::query()->where('is_active', true)->orderBy('sort_order')->get()
|
||||||
|
->filter(fn (EditorialContentKind $kind): bool => in_array('lizenzartikel', (array) ($kind->contexts ?? []), true))
|
||||||
|
->pluck('label', 'id')->all())
|
||||||
|
->placeholder('Alle Materialarten')
|
||||||
|
->native(false),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clean(array $data, array $refs, WidgetErrors $errors): array
|
||||||
|
{
|
||||||
|
foreach (['heading', 'intro'] as $key) {
|
||||||
|
$data[$key] = filled($data[$key] ?? null) ? trim((string) $data[$key]) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pillar = filled($data['pillar'] ?? null) ? (int) $data['pillar'] : null;
|
||||||
|
|
||||||
|
if ($pillar !== null && ! Pillar::query()->published()->whereKey($pillar)->exists()) {
|
||||||
|
$errors->add('data.pillar', 'Diese Säule gibt es nicht oder sie ist nicht veröffentlicht.');
|
||||||
|
$pillar = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$kind = filled($data['kind'] ?? null) ? (int) $data['kind'] : null;
|
||||||
|
|
||||||
|
if ($kind !== null && ! EditorialContentKind::query()->whereKey($kind)->exists()) {
|
||||||
|
$errors->add('data.kind', 'Diese Materialart gibt es nicht.');
|
||||||
|
$kind = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['pillar'] = $pillar;
|
||||||
|
$data['kind'] = $kind;
|
||||||
|
|
||||||
|
return [$data, $refs];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resolve(array $widget, RenderContext $context): array
|
||||||
|
{
|
||||||
|
if (! Shop::visible()) {
|
||||||
|
return ['cards' => [], 'term' => '', 'shopVisible' => false];
|
||||||
|
}
|
||||||
|
|
||||||
|
$settings = is_array($widget['settings'] ?? null) ? $widget['settings'] : [];
|
||||||
|
$search = ($settings['search'] ?? 'aus') === 'an';
|
||||||
|
$term = $search && ! $context->preview ? trim((string) request()->query('suche', '')) : '';
|
||||||
|
$limit = preg_match('/^n(\d+)$/', (string) ($settings['limit'] ?? ''), $match) === 1 ? (int) $match[1] : null;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'cards' => app(ShopCatalog::class)->cards($term, [
|
||||||
|
'pillar' => $widget['data']['pillar'] ?? null,
|
||||||
|
'kind' => $widget['data']['kind'] ?? null,
|
||||||
|
'sort' => $settings['sort'] ?? null,
|
||||||
|
'limit' => $limit,
|
||||||
|
]),
|
||||||
|
'term' => $term,
|
||||||
|
'shopVisible' => true,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function summary(array $widget): string
|
||||||
|
{
|
||||||
|
$heading = $widget['data']['heading'] ?? null;
|
||||||
|
|
||||||
|
return trim(($heading ? $heading.' · ' : '').'Shop-Produkte');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,12 +34,16 @@ public function __construct(
|
|||||||
private readonly ShopMarkers $markers,
|
private readonly ShopMarkers $markers,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
public const SORTS = ['name' => 'Alphabetisch', 'neu' => 'Neueste zuerst', 'preis' => 'Preis aufsteigend'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param array{pillar?: int|null, kind?: int|null, sort?: string|null, limit?: int|null} $options Filter nach Säule
|
||||||
|
* und Materialart, Sortierung (name, neu, preis) und Höchstzahl
|
||||||
* @return list<array<string, mixed>>
|
* @return list<array<string, mixed>>
|
||||||
*/
|
*/
|
||||||
public function cards(string $term = ''): array
|
public function cards(string $term = '', array $options = []): array
|
||||||
{
|
{
|
||||||
$term = mb_strtolower(trim($term));
|
$term = mb_strtolower(mb_substr(trim($term), 0, 100));
|
||||||
$cards = [];
|
$cards = [];
|
||||||
|
|
||||||
// Altbestand: Angebote mit mehreren Positionen auf einer freigegebenen Programmseite.
|
// Altbestand: Angebote mit mehreren Positionen auf einer freigegebenen Programmseite.
|
||||||
@@ -54,6 +58,8 @@ public function cards(string $term = ''): array
|
|||||||
$teaser = (string) ($composition->teaser ?: FormattedText::plain($composition->summary));
|
$teaser = (string) ($composition->teaser ?: FormattedText::plain($composition->summary));
|
||||||
$pillars = $this->pillarNames($composition->pillars);
|
$pillars = $this->pillarNames($composition->pillars);
|
||||||
$card = $this->card('c:'.$composition->id, 'programm', route('public.program', $composition), $title, $teaser, $summaries[$composition->id], 'Programm', null, $pillars, [], $this->image($composition));
|
$card = $this->card('c:'.$composition->id, 'programm', route('public.program', $composition), $title, $teaser, $summaries[$composition->id], 'Programm', null, $pillars, [], $this->image($composition));
|
||||||
|
$card['pillar_ids'] = $composition->pillars->pluck('id')->map(fn ($id): int => (int) $id)->all();
|
||||||
|
$card['kind_id'] = $composition->editorial_content_kind_id !== null ? (int) $composition->editorial_content_kind_id : null;
|
||||||
|
|
||||||
if ($this->matches($term, $title.' '.$teaser.' '.FormattedText::plain($composition->summary).' '.$composition->search_terms.' '.implode(' ', $pillars))) {
|
if ($this->matches($term, $title.' '.$teaser.' '.FormattedText::plain($composition->summary).' '.$composition->search_terms.' '.implode(' ', $pillars))) {
|
||||||
$cards[] = $card;
|
$cards[] = $card;
|
||||||
@@ -74,6 +80,9 @@ public function cards(string $term = ''): array
|
|||||||
'a:'.$article->id, 'artikel', route('shop.article', $article), $title, $teaser, $articleSummaries[$article->id],
|
'a:'.$article->id, 'artikel', route('shop.article', $article), $title, $teaser, $articleSummaries[$article->id],
|
||||||
(string) ($kind?->label ?? ''), $this->symbol($kind?->symbol), $pillars, $this->markers->visible($article, $offerIds), $this->image($article),
|
(string) ($kind?->label ?? ''), $this->symbol($kind?->symbol), $pillars, $this->markers->visible($article, $offerIds), $this->image($article),
|
||||||
);
|
);
|
||||||
|
$card['pillar_ids'] = $article->pillars->pluck('id')->map(fn ($id): int => (int) $id)->all();
|
||||||
|
$card['kind_id'] = $kind !== null ? (int) $kind->id : null;
|
||||||
|
$card['since'] = $this->markers->firstOffered($offerIds)?->getTimestamp() ?? 0;
|
||||||
|
|
||||||
if ($this->matches($term, $title.' '.$teaser.' '.$profile->value('summary').' '.$profile->searchTerms.' '.($kind?->label ?? '').' '.implode(' ', $pillars))) {
|
if ($this->matches($term, $title.' '.$teaser.' '.$profile->value('summary').' '.$profile->searchTerms.' '.($kind?->label ?? '').' '.implode(' ', $pillars))) {
|
||||||
$cards[] = $card;
|
$cards[] = $card;
|
||||||
@@ -94,7 +103,42 @@ public function cards(string $term = ''): array
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $cards;
|
return $this->arrange($cards, $options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter, Sortierung und Höchstzahl der Kacheln (Widget und Shopseite). Ohne Angabe bleibt die Reihenfolge der
|
||||||
|
* Datenquelle.
|
||||||
|
*
|
||||||
|
* @param list<array<string, mixed>> $cards
|
||||||
|
* @param array<string, mixed> $options
|
||||||
|
* @return list<array<string, mixed>>
|
||||||
|
*/
|
||||||
|
private function arrange(array $cards, array $options): array
|
||||||
|
{
|
||||||
|
$pillar = isset($options['pillar']) ? (int) $options['pillar'] : 0;
|
||||||
|
$kind = isset($options['kind']) ? (int) $options['kind'] : 0;
|
||||||
|
|
||||||
|
if ($pillar > 0) {
|
||||||
|
$cards = array_filter($cards, fn (array $card): bool => in_array($pillar, $card['pillar_ids'] ?? [], true));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($kind > 0) {
|
||||||
|
$cards = array_filter($cards, fn (array $card): bool => ($card['kind_id'] ?? null) === $kind);
|
||||||
|
}
|
||||||
|
|
||||||
|
$cards = array_values($cards);
|
||||||
|
|
||||||
|
match ($options['sort'] ?? null) {
|
||||||
|
'name' => usort($cards, fn (array $a, array $b): int => strcmp(mb_strtolower($a['title']), mb_strtolower($b['title']))),
|
||||||
|
'neu' => usort($cards, fn (array $a, array $b): int => [$b['since'] ?? 0, mb_strtolower($a['title'])] <=> [$a['since'] ?? 0, mb_strtolower($b['title'])]),
|
||||||
|
'preis' => usort($cards, fn (array $a, array $b): int => [$a['from_cents'], mb_strtolower($a['title'])] <=> [$b['from_cents'], mb_strtolower($b['title'])]),
|
||||||
|
default => null,
|
||||||
|
};
|
||||||
|
|
||||||
|
$limit = isset($options['limit']) ? (int) $options['limit'] : 0;
|
||||||
|
|
||||||
|
return $limit > 0 ? array_slice($cards, 0, $limit) : $cards;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -120,6 +164,9 @@ private function card(string $key, string $kind, string $url, string $title, str
|
|||||||
'symbol' => $symbol,
|
'symbol' => $symbol,
|
||||||
'pillars' => $pillars,
|
'pillars' => $pillars,
|
||||||
'markers' => $markers,
|
'markers' => $markers,
|
||||||
|
'pillar_ids' => [],
|
||||||
|
'kind_id' => null,
|
||||||
|
'since' => 0,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ public function visible(LicenseArticle $article, array $offerIds, ?Carbon $now =
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Zeitpunkt der ersten Fassung eines Angebots als Kauf. */
|
/** Zeitpunkt der ersten Fassung eines Angebots als Kauf. */
|
||||||
private function firstOffered(array $offerIds): ?Carbon
|
public function firstOffered(array $offerIds): ?Carbon
|
||||||
{
|
{
|
||||||
if ($offerIds === []) {
|
if ($offerIds === []) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -28,6 +28,11 @@ public function claim(User $user, Offer $offer): Acquisition
|
|||||||
throw new DomainRuleException('Dieses Angebot richtet sich nicht an Personen.');
|
throw new DomainRuleException('Dieses Angebot richtet sich nicht an Personen.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wer ein Angebot auf Abruf übernehmen darf, bestimmt seine Regel (ADR-56); „bei Registrierung“ kennt keine.
|
||||||
|
if ($version->grant_kind === 'auf_abruf') {
|
||||||
|
app(OfferAccess::class)->assertMayClaim($user, $offer);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->issue($user, $version, AcquisitionType::FreierAbruf, 'offer', $offer->id);
|
return $this->issue($user, $version, AcquisitionType::FreierAbruf, 'offer', $offer->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Entitlement;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ArticleRelease;
|
||||||
|
use App\Domain\Commerce\ProductOptions;
|
||||||
|
use App\Models\User;
|
||||||
|
use Carbon\CarbonInterface;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Neue Stände zu Artikeln, die das Konto bereits besitzt („Neu für dich“, ADR-56).
|
||||||
|
*
|
||||||
|
* Nach der Updatepolitik (ADR-09, OPEN-01) stehen alle später veröffentlichten Stände desselben Artikels dem Inhaber
|
||||||
|
* ohne Aufpreis zu, solange die Lizenz gilt. Sie erscheinen von selbst in der Bibliothek; diese Liste macht sie nur
|
||||||
|
* sichtbar. Es wird nichts vergeben und nichts übernommen.
|
||||||
|
*/
|
||||||
|
class NewStands
|
||||||
|
{
|
||||||
|
/** So lange (in Tagen) nach der Veröffentlichung erscheint ein neuer Stand in der Liste. */
|
||||||
|
public const DAYS = 90;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection<int, array{grant: Grant, title: string, number: int, since: CarbonInterface}>
|
||||||
|
*/
|
||||||
|
public function forUser(User $user): Collection
|
||||||
|
{
|
||||||
|
if ($user->party_id === null) {
|
||||||
|
return collect();
|
||||||
|
}
|
||||||
|
|
||||||
|
$limit = now()->subDays(self::DAYS);
|
||||||
|
$titles = app(ProductOptions::class);
|
||||||
|
|
||||||
|
return Grant::query()
|
||||||
|
->with(['article.currentRelease', 'releaseAtGrant'])
|
||||||
|
->where('status', GrantStatus::Aktiv)
|
||||||
|
->where(fn ($query) => $query->whereNull('valid_until')->orWhere('valid_until', '>', now()))
|
||||||
|
->whereHas('acquisition', fn ($query) => $query->where('party_id', $user->party_id))
|
||||||
|
->whereHas('article', fn ($query) => $query->whereNull('archived_at'))
|
||||||
|
->orderByDesc('id')
|
||||||
|
->get()
|
||||||
|
->filter(function (Grant $grant) use ($limit): bool {
|
||||||
|
$current = $grant->article?->currentRelease;
|
||||||
|
$had = $grant->releaseAtGrant;
|
||||||
|
|
||||||
|
return $current instanceof ArticleRelease
|
||||||
|
&& $had instanceof ArticleRelease
|
||||||
|
&& (int) $current->number > (int) $had->number
|
||||||
|
&& $current->created_at !== null
|
||||||
|
&& $current->created_at->greaterThanOrEqualTo($limit);
|
||||||
|
})
|
||||||
|
->unique('license_article_id')
|
||||||
|
->map(fn (Grant $grant): array => [
|
||||||
|
'grant' => $grant,
|
||||||
|
'title' => $titles->articleTitle($grant->article),
|
||||||
|
'number' => (int) $grant->article->currentRelease->number,
|
||||||
|
'since' => $grant->article->currentRelease->created_at,
|
||||||
|
])
|
||||||
|
->values();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,227 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Entitlement;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
|
use App\Domain\Catalog\LicenseArticle;
|
||||||
|
use App\Domain\Catalog\Offer;
|
||||||
|
use App\Domain\Catalog\OfferRelease;
|
||||||
|
use App\Domain\Catalog\OfferService;
|
||||||
|
use App\Domain\Catalog\OfferStatus;
|
||||||
|
use App\Domain\Catalog\OfferVersion;
|
||||||
|
use App\Models\User;
|
||||||
|
use Carbon\CarbonInterface;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wer ein Angebot „auf Abruf“ in die Bibliothek übernehmen darf (ADR-56). Drei Regeln, serverseitig beim Abruf geprüft:
|
||||||
|
* alle angemeldeten Mitglieder, nur ausdrücklich freigeschaltete Konten (Freigabe je Angebot und Konto, wie bei
|
||||||
|
* Rabattcodes, nie gelöscht, nur entzogen) oder Mitglieder, die einen bestimmten anderen Artikel besitzen.
|
||||||
|
*
|
||||||
|
* Die Regel gilt nur für Vergaben „auf Abruf“. „Bei Registrierung“ geht automatisch an neue Konten; Kauf ist Sache der
|
||||||
|
* Kasse. Die Regel begründet keinen Zugang, sie begrenzt nur den freien Abruf.
|
||||||
|
*/
|
||||||
|
class OfferAccess
|
||||||
|
{
|
||||||
|
public const ALL = 'alle';
|
||||||
|
|
||||||
|
public const RELEASED = 'konten';
|
||||||
|
|
||||||
|
public const OWNERS = 'besitz';
|
||||||
|
|
||||||
|
public const OPTIONS = [
|
||||||
|
self::ALL => 'Alle angemeldeten Mitglieder',
|
||||||
|
self::RELEASED => 'Nur freigeschaltete Konten',
|
||||||
|
self::OWNERS => 'Mitglieder, die einen bestimmten Artikel besitzen',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function __construct(private readonly OfferService $offers) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die Regel eines Angebots festlegen. Der Artikel ist nur bei „besitzt einen Artikel“ gesetzt.
|
||||||
|
*/
|
||||||
|
public function setRule(Offer $offer, string $access, ?int $articleId = null): void
|
||||||
|
{
|
||||||
|
if (! array_key_exists($access, self::OPTIONS)) {
|
||||||
|
throw new DomainRuleException('Diese Regel für den Abruf gibt es nicht.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($access === self::OWNERS) {
|
||||||
|
$article = $articleId === null ? null : LicenseArticle::query()->whereNull('archived_at')->find($articleId);
|
||||||
|
|
||||||
|
if ($article === null) {
|
||||||
|
throw new DomainRuleException('Für diese Regel braucht es einen vorhandenen, nicht archivierten Lizenzartikel.');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$articleId = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$offer->claim_access = $access;
|
||||||
|
$offer->claim_requires_article_id = $articleId;
|
||||||
|
$offer->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Warum das Konto das Angebot nicht abrufen darf; null, wenn es das darf. Regeln gelten nur für Vergaben „auf Abruf“.
|
||||||
|
*/
|
||||||
|
public function refusal(User $user, Offer $offer, ?CarbonInterface $now = null): ?string
|
||||||
|
{
|
||||||
|
$now ??= now();
|
||||||
|
$version = $this->activeVersion($offer);
|
||||||
|
|
||||||
|
if ($version === null || ! in_array($version->grant_kind, ['auf_abruf', 'bei_registrierung'], true) || $version->holder_kind !== 'person') {
|
||||||
|
return 'Dieses Angebot wird nicht frei vergeben.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user->party_id === null) {
|
||||||
|
return 'Nur ein Mitgliedskonto kann ein Angebot abrufen.';
|
||||||
|
}
|
||||||
|
|
||||||
|
// „Bei Registrierung“ geht automatisch an neue Konten und kennt keine Regel.
|
||||||
|
if ($version->grant_kind !== 'auf_abruf') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return match ((string) $offer->claim_access) {
|
||||||
|
self::RELEASED => $this->activeRelease($offer, $user, $now) === null ? 'Dieses Angebot ist für dein Konto nicht freigeschaltet.' : null,
|
||||||
|
self::OWNERS => $offer->claim_requires_article_id !== null && $this->owns($user, (int) $offer->claim_requires_article_id, $now) ? null : 'Dieses Angebot steht für dein Konto nicht zur Verfügung.',
|
||||||
|
default => null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public function mayClaim(User $user, Offer $offer, ?CarbonInterface $now = null): bool
|
||||||
|
{
|
||||||
|
return $this->refusal($user, $offer, $now) === null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertMayClaim(User $user, Offer $offer): void
|
||||||
|
{
|
||||||
|
$reason = $this->refusal($user, $offer);
|
||||||
|
|
||||||
|
if ($reason !== null) {
|
||||||
|
throw new DomainRuleException($reason);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die Angebote auf Abruf, die das Konto jetzt übernehmen darf und noch nicht übernommen hat.
|
||||||
|
*
|
||||||
|
* @return Collection<int, Offer>
|
||||||
|
*/
|
||||||
|
public function claimable(User $user): Collection
|
||||||
|
{
|
||||||
|
if ($user->party_id === null) {
|
||||||
|
return collect();
|
||||||
|
}
|
||||||
|
|
||||||
|
$taken = Acquisition::query()
|
||||||
|
->where('party_id', $user->party_id)
|
||||||
|
->where('type', AcquisitionType::FreierAbruf)
|
||||||
|
->where('reference_type', 'offer')
|
||||||
|
->pluck('reference_id')
|
||||||
|
->all();
|
||||||
|
|
||||||
|
return Offer::query()
|
||||||
|
->whereHas('versions', fn ($query) => $query->where('status', OfferStatus::Aktiv)->where('holder_kind', 'person')->whereIn('grant_kind', ['auf_abruf', 'bei_registrierung']))
|
||||||
|
->whereNotIn('id', $taken)
|
||||||
|
->orderBy('name')
|
||||||
|
->get()
|
||||||
|
->filter(fn (Offer $offer): bool => $this->mayClaim($user, $offer))
|
||||||
|
->values();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ein Konto für ein Angebot freischalten (Regel „nur freigeschaltete Konten“).
|
||||||
|
*/
|
||||||
|
public function release(Offer $offer, User $member, ?User $actor, ?CarbonInterface $until = null, ?string $reason = null): OfferRelease
|
||||||
|
{
|
||||||
|
if ($offer->claim_access !== self::RELEASED) {
|
||||||
|
throw new DomainRuleException('Freigaben gibt es nur bei der Regel „nur freigeschaltete Konten“.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($member->party_id === null) {
|
||||||
|
throw new DomainRuleException('Nur ein Mitgliedskonto kann für ein Angebot freigeschaltet werden.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return DB::transaction(function () use ($offer, $member, $actor, $until, $reason): OfferRelease {
|
||||||
|
Offer::query()->whereKey($offer->id)->lockForUpdate()->firstOrFail();
|
||||||
|
|
||||||
|
if ($this->activeRelease($offer, $member) !== null) {
|
||||||
|
throw new DomainRuleException('Dieses Konto ist für das Angebot bereits freigeschaltet.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($until !== null && $until->lessThanOrEqualTo(now())) {
|
||||||
|
throw new DomainRuleException('Das Ende der Freigabe liegt in der Vergangenheit.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return OfferRelease::query()->create([
|
||||||
|
'offer_id' => $offer->id,
|
||||||
|
'user_id' => $member->id,
|
||||||
|
'granted_by' => $actor?->id,
|
||||||
|
'granted_at' => now(),
|
||||||
|
'valid_until' => $until,
|
||||||
|
'reason' => filled($reason) ? trim((string) $reason) : null,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entzieht die Freigabe. Sie bleibt mit Zeitpunkt, Person und Begründung gespeichert; bereits übernommene Angebote
|
||||||
|
* bleiben in der Bibliothek.
|
||||||
|
*/
|
||||||
|
public function revoke(OfferRelease $release, ?User $actor, ?string $reason = null): OfferRelease
|
||||||
|
{
|
||||||
|
return DB::transaction(function () use ($release, $actor, $reason): OfferRelease {
|
||||||
|
$release = OfferRelease::query()->lockForUpdate()->findOrFail($release->id);
|
||||||
|
|
||||||
|
if ($release->revoked_at !== null) {
|
||||||
|
throw new DomainRuleException('Diese Freigabe ist bereits entzogen.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$release->forceFill([
|
||||||
|
'revoked_at' => now(),
|
||||||
|
'revoked_by' => $actor?->id,
|
||||||
|
'reason' => filled($reason) ? trim((string) $reason) : $release->reason,
|
||||||
|
])->save();
|
||||||
|
|
||||||
|
return $release;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function activeRelease(Offer $offer, User $member, ?CarbonInterface $now = null): ?OfferRelease
|
||||||
|
{
|
||||||
|
$now ??= now();
|
||||||
|
|
||||||
|
return OfferRelease::query()
|
||||||
|
->where('offer_id', $offer->id)
|
||||||
|
->where('user_id', $member->id)
|
||||||
|
->whereNull('revoked_at')
|
||||||
|
->where('granted_at', '<=', $now)
|
||||||
|
->where(fn ($query) => $query->whereNull('valid_until')->orWhere('valid_until', '>', $now))
|
||||||
|
->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Das Konto besitzt den Artikel, wenn seine Person eine aktive, gültige Berechtigung darauf hat. */
|
||||||
|
public function owns(User $user, int $articleId, ?CarbonInterface $now = null): bool
|
||||||
|
{
|
||||||
|
$now ??= now();
|
||||||
|
|
||||||
|
if ($user->party_id === null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Grant::query()
|
||||||
|
->where('license_article_id', $articleId)
|
||||||
|
->where('status', GrantStatus::Aktiv)
|
||||||
|
->where(fn ($query) => $query->whereNull('valid_from')->orWhere('valid_from', '<=', $now))
|
||||||
|
->where(fn ($query) => $query->whereNull('valid_until')->orWhere('valid_until', '>', $now))
|
||||||
|
->whereHas('acquisition', fn ($query) => $query->where('party_id', $user->party_id))
|
||||||
|
->exists();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function activeVersion(Offer $offer): ?OfferVersion
|
||||||
|
{
|
||||||
|
return $offer->versions()->where('status', OfferStatus::Aktiv)->orderByDesc('number')->first();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
use App\Domain\Catalog\LicenceScope;
|
use App\Domain\Catalog\LicenceScope;
|
||||||
use App\Domain\Catalog\LicenseArticle;
|
use App\Domain\Catalog\LicenseArticle;
|
||||||
use App\Domain\Catalog\Offer;
|
use App\Domain\Catalog\Offer;
|
||||||
|
use App\Domain\Catalog\OfferRelease;
|
||||||
use App\Domain\Catalog\OfferService;
|
use App\Domain\Catalog\OfferService;
|
||||||
use App\Domain\Catalog\OfferStatus;
|
use App\Domain\Catalog\OfferStatus;
|
||||||
use App\Domain\Catalog\OfferVersion;
|
use App\Domain\Catalog\OfferVersion;
|
||||||
@@ -17,6 +18,7 @@
|
|||||||
use App\Domain\Catalog\StatusValue;
|
use App\Domain\Catalog\StatusValue;
|
||||||
use App\Domain\Commerce\Money;
|
use App\Domain\Commerce\Money;
|
||||||
use App\Domain\Commerce\ProductOptions;
|
use App\Domain\Commerce\ProductOptions;
|
||||||
|
use App\Domain\Entitlement\OfferAccess;
|
||||||
use App\Filament\Pages\Zahlungsjournal;
|
use App\Filament\Pages\Zahlungsjournal;
|
||||||
use App\Filament\Resources\Offers\OfferResource;
|
use App\Filament\Resources\Offers\OfferResource;
|
||||||
use App\Filament\Support\CatalogLabels;
|
use App\Filament\Support\CatalogLabels;
|
||||||
@@ -24,9 +26,12 @@
|
|||||||
use App\Filament\Support\PublicationReadiness;
|
use App\Filament\Support\PublicationReadiness;
|
||||||
use App\Filament\Support\ReportsDomainRules;
|
use App\Filament\Support\ReportsDomainRules;
|
||||||
use App\Filament\Support\ShopAccess;
|
use App\Filament\Support\ShopAccess;
|
||||||
|
use App\Models\User;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
|
use Filament\Forms\Components\DatePicker;
|
||||||
use Filament\Forms\Components\Repeater;
|
use Filament\Forms\Components\Repeater;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\Textarea;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Resources\Pages\ViewRecord;
|
use Filament\Resources\Pages\ViewRecord;
|
||||||
use Filament\Schemas\Components\Utilities\Get;
|
use Filament\Schemas\Components\Utilities\Get;
|
||||||
@@ -34,6 +39,7 @@
|
|||||||
use Filament\Schemas\Schema;
|
use Filament\Schemas\Schema;
|
||||||
use Filament\Support\Enums\Width;
|
use Filament\Support\Enums\Width;
|
||||||
use Illuminate\Contracts\Support\Htmlable;
|
use Illuminate\Contracts\Support\Htmlable;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -243,6 +249,175 @@ public function endAction(): Action
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Ein Angebot auf Abruf: nur dafür gibt es Regeln, wer es übernehmen darf (ADR-56). */
|
||||||
|
private function isOnDemand(): bool
|
||||||
|
{
|
||||||
|
return $this->activeVersion()?->grant_kind === 'auf_abruf';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wer das Angebot übernehmen darf: alle Mitglieder, nur freigeschaltete Konten oder wer einen Artikel besitzt.
|
||||||
|
*/
|
||||||
|
public function claimRuleAction(): Action
|
||||||
|
{
|
||||||
|
return Action::make('claimRule')
|
||||||
|
->label('Regel für den Abruf')
|
||||||
|
->modalHeading(fn (): string => 'Wer darf „'.$this->getRecord()->name.'“ abrufen?')
|
||||||
|
->modalDescription('Die Regel gilt für den kostenlosen Abruf in die Bibliothek und wird beim Abruf geprüft. Sie begrenzt nur den Abruf; sie vergibt nichts. Bereits übernommene Angebote bleiben in der Bibliothek.')
|
||||||
|
->modalSubmitActionLabel('Regel speichern')
|
||||||
|
->visible(fn (): bool => $this->isOnDemand())
|
||||||
|
->fillForm(fn (): array => [
|
||||||
|
'claim_access' => (string) ($this->getRecord()->claim_access ?: OfferAccess::ALL),
|
||||||
|
'claim_requires_article_id' => $this->getRecord()->claim_requires_article_id,
|
||||||
|
])
|
||||||
|
->schema([
|
||||||
|
Select::make('claim_access')->label('Wer darf abrufen')
|
||||||
|
->options(OfferAccess::OPTIONS)
|
||||||
|
->required()->live()->native(false)
|
||||||
|
->helperText('„Nur freigeschaltete Konten“: Du schaltest einzelne Konten auf dieser Seite frei und entziehst die Freigabe wieder. Sie gilt nur für dieses Angebot.'),
|
||||||
|
Select::make('claim_requires_article_id')->label('Artikel, den das Konto besitzen muss')
|
||||||
|
->options(fn (): array => LicenseArticle::query()->whereNull('archived_at')->orderBy('code')->get()
|
||||||
|
->mapWithKeys(fn (LicenseArticle $article): array => [$article->id => app(ProductOptions::class)->articleTitle($article)])->all())
|
||||||
|
->searchable()
|
||||||
|
->required(fn (Get $get): bool => $get('claim_access') === OfferAccess::OWNERS)
|
||||||
|
->visible(fn (Get $get): bool => $get('claim_access') === OfferAccess::OWNERS)
|
||||||
|
->helperText('Das Konto muss eine gültige Berechtigung auf diesen Artikel haben, zum Beispiel durch einen Kauf.'),
|
||||||
|
])
|
||||||
|
->action(function (array $data): void {
|
||||||
|
$this->report(function () use ($data): string {
|
||||||
|
app(OfferAccess::class)->setRule($this->getRecord(), (string) $data['claim_access'], filled($data['claim_requires_article_id'] ?? null) ? (int) $data['claim_requires_article_id'] : null);
|
||||||
|
|
||||||
|
return 'Die Regel für den Abruf ist gespeichert.';
|
||||||
|
}, 'Die Regel ist gespeichert.');
|
||||||
|
$this->getRecord()->unsetRelations();
|
||||||
|
$this->getRecord()->refresh();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function releaseAction(): Action
|
||||||
|
{
|
||||||
|
return Action::make('release')
|
||||||
|
->label('Konto freischalten')
|
||||||
|
->modalHeading(fn (): string => 'Konto für „'.$this->getRecord()->name.'“ freischalten')
|
||||||
|
->modalDescription('Das Konto darf genau dieses Angebot abrufen, solange Freigabe und Angebot gelten. Die Freigabe gilt nicht für andere Angebote und bleibt mit dem Entzug im Verlauf stehen.')
|
||||||
|
->modalSubmitActionLabel('Konto freischalten')
|
||||||
|
->visible(fn (): bool => $this->isOnDemand() && $this->getRecord()->claim_access === OfferAccess::RELEASED)
|
||||||
|
->schema([
|
||||||
|
Select::make('user_id')->label('Mitgliedskonto')->required()->searchable()
|
||||||
|
->getSearchResultsUsing(fn (string $search): array => $this->searchMembers($search))
|
||||||
|
->getOptionLabelUsing(fn ($value): ?string => ($user = User::query()->find($value)) === null ? null : $user->name.' ('.$user->email.')')
|
||||||
|
->helperText('Suche nach Name oder E-Mail-Adresse. Nur Konten mit Mitgliedsprofil.'),
|
||||||
|
DatePicker::make('valid_until')->label('Freigabe gültig bis einschließlich')->native(false)->displayFormat('d.m.Y')
|
||||||
|
->helperText('Leer: ohne Ende.'),
|
||||||
|
Textarea::make('reason')->label('Grundlage der Freigabe')->rows(2)->maxLength(500)
|
||||||
|
->helperText('Zum Beispiel „Teilnahme am Seminar am 12.11.2026“. Bleibt im Verlauf stehen.'),
|
||||||
|
])
|
||||||
|
->action(function (array $data): void {
|
||||||
|
$this->report(function () use ($data): string {
|
||||||
|
$member = User::query()->findOrFail($data['user_id']);
|
||||||
|
$until = filled($data['valid_until'] ?? null) ? Carbon::parse((string) $data['valid_until'], config('app.timezone'))->endOfDay() : null;
|
||||||
|
app(OfferAccess::class)->release($this->getRecord(), $member, auth('staff')->user() ?? auth()->user(), $until, $data['reason'] ?? null);
|
||||||
|
|
||||||
|
return 'Das Konto von '.$member->name.' ist für das Angebot freigeschaltet.';
|
||||||
|
}, 'Das Konto ist freigeschaltet.');
|
||||||
|
$this->getRecord()->unsetRelations();
|
||||||
|
$this->getRecord()->refresh();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function revokeAction(): Action
|
||||||
|
{
|
||||||
|
return Action::make('revoke')
|
||||||
|
->label('Freigabe entziehen')
|
||||||
|
->color('danger')
|
||||||
|
->requiresConfirmation()
|
||||||
|
->modalHeading('Freigabe entziehen?')
|
||||||
|
->modalDescription('Das Konto kann das Angebot danach nicht mehr abrufen. Bereits übernommene Angebote bleiben in der Bibliothek. Die Freigabe bleibt mit dem Entzug im Verlauf stehen.')
|
||||||
|
->modalSubmitActionLabel('Freigabe entziehen')
|
||||||
|
->schema([
|
||||||
|
Textarea::make('reason')->label('Grund')->rows(2)->maxLength(500),
|
||||||
|
])
|
||||||
|
->action(function (array $data, array $arguments): void {
|
||||||
|
$this->report(function () use ($data, $arguments): string {
|
||||||
|
$release = OfferRelease::query()->where('offer_id', $this->getRecord()->id)->findOrFail((int) ($arguments['release'] ?? 0));
|
||||||
|
app(OfferAccess::class)->revoke($release, auth('staff')->user() ?? auth()->user(), $data['reason'] ?? null);
|
||||||
|
|
||||||
|
return 'Die Freigabe ist entzogen.';
|
||||||
|
}, 'Die Freigabe ist entzogen.');
|
||||||
|
$this->getRecord()->unsetRelations();
|
||||||
|
$this->getRecord()->refresh();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, string>
|
||||||
|
*/
|
||||||
|
private function searchMembers(string $search): array
|
||||||
|
{
|
||||||
|
$like = '%'.mb_strtolower(trim($search)).'%';
|
||||||
|
|
||||||
|
return User::query()
|
||||||
|
->whereNotNull('party_id')
|
||||||
|
->where(fn ($query) => $query->whereRaw('LOWER(name) LIKE ?', [$like])->orWhereRaw('LOWER(email) LIKE ?', [$like]))
|
||||||
|
->orderBy('name')
|
||||||
|
->limit(20)
|
||||||
|
->get()
|
||||||
|
->mapWithKeys(fn (User $user): array => [$user->id => $user->name.' ('.$user->email.')'])
|
||||||
|
->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abschnitte „Wer darf abrufen“ und „Freigeschaltete Konten“ für ein Angebot auf Abruf.
|
||||||
|
*
|
||||||
|
* @return list<array<string, mixed>>
|
||||||
|
*/
|
||||||
|
private function abrufAbschnitte(Offer $offer): array
|
||||||
|
{
|
||||||
|
$date = fn ($value): string => $value?->format('d.m.Y') ?? '';
|
||||||
|
$access = (string) ($offer->claim_access ?: OfferAccess::ALL);
|
||||||
|
$article = $offer->claim_requires_article_id !== null ? LicenseArticle::query()->find($offer->claim_requires_article_id) : null;
|
||||||
|
$releases = $offer->releases()->with(['user', 'grantor'])->orderByDesc('id')->get();
|
||||||
|
$active = $releases->filter(fn (OfferRelease $release): bool => $release->revoked_at === null);
|
||||||
|
$past = $releases->filter(fn (OfferRelease $release): bool => $release->revoked_at !== null);
|
||||||
|
$sections = [[
|
||||||
|
'titel' => 'Wer darf abrufen',
|
||||||
|
'hilfe' => 'Diese Regel gilt für den kostenlosen Abruf in die Bibliothek (Mitgliederbereich → Angebote). Sie wird beim Abruf geprüft, nicht nur in der Anzeige.',
|
||||||
|
'zeilen' => [[
|
||||||
|
'text' => OfferAccess::OPTIONS[$access] ?? $access,
|
||||||
|
'neben' => $access === OfferAccess::OWNERS
|
||||||
|
? 'Erforderlich: '.($article !== null ? app(ProductOptions::class)->articleTitle($article) : 'ein Artikel fehlt (Regel prüfen)')
|
||||||
|
: ($access === OfferAccess::RELEASED ? 'Mit „Konto freischalten“ gibst du einzelne Konten frei.' : 'Jedes angemeldete Mitgliedskonto sieht das Angebot und kann es übernehmen.'),
|
||||||
|
]],
|
||||||
|
]];
|
||||||
|
|
||||||
|
if ($access === OfferAccess::RELEASED) {
|
||||||
|
$sections[] = [
|
||||||
|
'titel' => 'Freigeschaltete Konten',
|
||||||
|
'zusatz' => $active->count().' aktiv',
|
||||||
|
'hilfe' => 'Nur diese Konten sehen das Angebot im Mitgliederbereich und können es übernehmen.',
|
||||||
|
'zeilen' => $active->map(fn (OfferRelease $release): array => [
|
||||||
|
'text' => ($release->user?->name ?? 'Konto').' ('.($release->user?->email ?? '').')',
|
||||||
|
'neben' => 'freigeschaltet am '.$date($release->granted_at).($release->grantor ? ' von '.$release->grantor->name : '').($release->valid_until ? ', gültig bis einschließlich '.$date($release->valid_until) : '').(filled($release->reason) ? ' · '.$release->reason : ''),
|
||||||
|
'aktion' => ['label' => 'Entziehen', 'wire' => "mountAction('revoke', { release: ".$release->id.' })'],
|
||||||
|
])->values()->all(),
|
||||||
|
'leer' => ['titel' => 'Noch kein Konto freigeschaltet', 'text' => 'Mit „Konto freischalten“ gibst du ein Konto für dieses Angebot frei.'],
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($past->isNotEmpty()) {
|
||||||
|
$sections[] = [
|
||||||
|
'titel' => 'Entzogene Freigaben',
|
||||||
|
'hilfe' => 'Der Verlauf bleibt erhalten.',
|
||||||
|
'zeilen' => $past->map(fn (OfferRelease $release): array => [
|
||||||
|
'text' => $release->user?->name ?? 'Konto',
|
||||||
|
'neben' => 'entzogen am '.$date($release->revoked_at).(filled($release->reason) ? ' · '.$release->reason : ''),
|
||||||
|
])->values()->all(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sections;
|
||||||
|
}
|
||||||
|
|
||||||
/** „ der Produktseite „Titel““ oder leer, wenn die Option (noch) keine Produktseite hat. */
|
/** „ der Produktseite „Titel““ oder leer, wenn die Option (noch) keine Produktseite hat. */
|
||||||
private function productPageSuffix(): string
|
private function productPageSuffix(): string
|
||||||
{
|
{
|
||||||
@@ -330,6 +505,16 @@ private function angebotDaten(): array
|
|||||||
'wire' => "mountAction('end')",
|
'wire' => "mountAction('end')",
|
||||||
'art' => 'line',
|
'art' => 'line',
|
||||||
]] : []),
|
]] : []),
|
||||||
|
...($this->isOnDemand() ? [[
|
||||||
|
'label' => 'Regel für den Abruf',
|
||||||
|
'wire' => "mountAction('claimRule')",
|
||||||
|
'art' => 'line',
|
||||||
|
]] : []),
|
||||||
|
...($this->isOnDemand() && $offer->claim_access === OfferAccess::RELEASED ? [[
|
||||||
|
'label' => 'Konto freischalten',
|
||||||
|
'wire' => "mountAction('release')",
|
||||||
|
'art' => 'line',
|
||||||
|
]] : []),
|
||||||
...(ShopAccess::allowed() ? [[
|
...(ShopAccess::allowed() ? [[
|
||||||
'label' => 'Zahlungen zu diesem Angebot',
|
'label' => 'Zahlungen zu diesem Angebot',
|
||||||
'href' => Zahlungsjournal::getUrl(['angebot' => $offer->id, 'zeitraum' => 'jahr', 'betrieb' => 'alle']),
|
'href' => Zahlungsjournal::getUrl(['angebot' => $offer->id, 'zeitraum' => 'jahr', 'betrieb' => 'alle']),
|
||||||
@@ -340,6 +525,7 @@ private function angebotDaten(): array
|
|||||||
'voraussetzungen' => app(PublicationReadiness::class)->forOffer($offer),
|
'voraussetzungen' => app(PublicationReadiness::class)->forOffer($offer),
|
||||||
'haupt' => [
|
'haupt' => [
|
||||||
...($active !== null ? [$this->optionAbschnitt($offer, $active)] : []),
|
...($active !== null ? [$this->optionAbschnitt($offer, $active)] : []),
|
||||||
|
...($this->isOnDemand() ? $this->abrufAbschnitte($offer) : []),
|
||||||
[
|
[
|
||||||
'titel' => 'Positionen',
|
'titel' => 'Positionen',
|
||||||
'zusatz' => $active !== null ? 'Fassung '.$active->number : null,
|
'zusatz' => $active !== null ? 'Fassung '.$active->number : null,
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
use App\Domain\Catalog\DomainRuleException;
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
use App\Domain\Catalog\Offer;
|
use App\Domain\Catalog\Offer;
|
||||||
use App\Domain\Catalog\OfferStatus;
|
|
||||||
use App\Domain\Commerce\Cart;
|
use App\Domain\Commerce\Cart;
|
||||||
use App\Domain\Commerce\Checkout;
|
use App\Domain\Commerce\Checkout;
|
||||||
use App\Domain\Commerce\LedgerEntry;
|
use App\Domain\Commerce\LedgerEntry;
|
||||||
@@ -12,9 +11,12 @@
|
|||||||
use App\Domain\Commerce\OrderHolders;
|
use App\Domain\Commerce\OrderHolders;
|
||||||
use App\Domain\Commerce\SalesTerms;
|
use App\Domain\Commerce\SalesTerms;
|
||||||
use App\Domain\Commerce\Shop;
|
use App\Domain\Commerce\Shop;
|
||||||
|
use App\Domain\Commerce\ShopCatalog;
|
||||||
use App\Domain\Commerce\StaleOverview;
|
use App\Domain\Commerce\StaleOverview;
|
||||||
use App\Domain\Commerce\Stripe\StripeGateway;
|
use App\Domain\Commerce\Stripe\StripeGateway;
|
||||||
use App\Domain\Entitlement\GrantIssuer;
|
use App\Domain\Entitlement\GrantIssuer;
|
||||||
|
use App\Domain\Entitlement\NewStands;
|
||||||
|
use App\Domain\Entitlement\OfferAccess;
|
||||||
use App\Domain\Identity\PartyType;
|
use App\Domain\Identity\PartyType;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
@@ -24,18 +26,21 @@
|
|||||||
class CheckoutController extends Controller
|
class CheckoutController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Angebote für das Konto: was sich ohne Kauf in die Bibliothek übernehmen lässt (Vergabe „auf Abruf“ oder „bei
|
* Angebote für das Konto: was sich ohne Kauf in die Bibliothek übernehmen lässt (Regel des Angebots, ADR-56) und
|
||||||
* Registrierung“). Gekauft wird ausschließlich im Shop über Warenkorb oder „Jetzt kaufen“ und die Kasse.
|
* neue Stände zu bereits besessenen Artikeln. Gekauft wird ausschließlich im Shop über Warenkorb oder „Jetzt kaufen“
|
||||||
|
* und die Kasse.
|
||||||
*/
|
*/
|
||||||
public function offers(): View
|
public function offers(Request $request, OfferAccess $access, NewStands $stands): View
|
||||||
{
|
{
|
||||||
$offers = Offer::query()
|
$user = $request->user();
|
||||||
->whereHas('versions', fn ($query) => $query->where('status', OfferStatus::Aktiv)->where('holder_kind', 'person')->whereIn('grant_kind', ['auf_abruf', 'bei_registrierung']))
|
$shop = Shop::visible();
|
||||||
->with(['versions' => fn ($query) => $query->where('status', OfferStatus::Aktiv)->orderByDesc('number')])
|
|
||||||
->orderBy('name')
|
|
||||||
->get();
|
|
||||||
|
|
||||||
return view('member.offers', ['offers' => $offers, 'shop' => Shop::visible()]);
|
return view('member.offers', [
|
||||||
|
'offers' => $access->claimable($user),
|
||||||
|
'stands' => $stands->forUser($user),
|
||||||
|
'shop' => $shop,
|
||||||
|
'cards' => $shop ? app(ShopCatalog::class)->cards('', ['sort' => 'neu', 'limit' => 6]) : [],
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function claim(Request $request, Offer $offer, GrantIssuer $issuer): RedirectResponse
|
public function claim(Request $request, Offer $offer, GrantIssuer $issuer): RedirectResponse
|
||||||
|
|||||||
@@ -35,6 +35,12 @@ public function offers(): View|RedirectResponse
|
|||||||
return Shop::visible() ? redirect()->route('shop') : $this->show('angebote');
|
return Shop::visible() ? redirect()->route('shop') : $this->show('angebote');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Eine veröffentlichte CMS-Seite unter einer festen App-Adresse (der Shop unter /shop). */
|
||||||
|
public function showPage(Page $page): View
|
||||||
|
{
|
||||||
|
return $this->render($page, preview: false);
|
||||||
|
}
|
||||||
|
|
||||||
public function preview(PageRevision $revision): View
|
public function preview(PageRevision $revision): View
|
||||||
{
|
{
|
||||||
$page = $revision->page;
|
$page = $revision->page;
|
||||||
@@ -60,7 +66,9 @@ public function devices(PageRevision $revision): View
|
|||||||
|
|
||||||
public function sitemap(): Response
|
public function sitemap(): Response
|
||||||
{
|
{
|
||||||
$pages = Page::query()->whereNotNull('published_revision_id')->orderBy('path')->get();
|
// Der Shop gehört nicht in die Sitemap, solange man dort nicht kaufen kann (die Seiten sind dann noindex).
|
||||||
|
$pages = Page::query()->whereNotNull('published_revision_id')->orderBy('path')->get()
|
||||||
|
->reject(fn (Page $page): bool => $page->path === '/shop' && ! Shop::checkoutOpen());
|
||||||
$themes = Pillar::query()->published()->get();
|
$themes = Pillar::query()->published()->get();
|
||||||
|
|
||||||
return response()
|
return response()
|
||||||
|
|||||||
@@ -2,15 +2,19 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Domain\Cms\Page;
|
||||||
use App\Domain\Commerce\Shop;
|
use App\Domain\Commerce\Shop;
|
||||||
use App\Domain\Commerce\ShopCatalog;
|
use App\Domain\Commerce\ShopCatalog;
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\View\View;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Durchsuchbarer Shop: macht kaufbare Produkte auffindbar. Treffer öffnen dieselbe öffentliche Produktseite wie die
|
* Durchsuchbarer Shop: macht kaufbare Produkte auffindbar. Treffer öffnen dieselbe öffentliche Produktseite wie die
|
||||||
* Programmkacheln. Gelistet wird nur, was mindestens eine kaufbare Option hat; die Kacheln bildet ShopCatalog.
|
* Programmkacheln. Gelistet wird nur, was mindestens eine kaufbare Option hat; die Kacheln bildet ShopCatalog.
|
||||||
|
*
|
||||||
|
* Gibt es in der Webpräsenz eine veröffentlichte Seite „shop“, bestimmt sie den Aufbau (Banner, Grafiken, Texte und das
|
||||||
|
* Widget „Shop-Produkte“); sonst zeigt die Anwendung die Standardseite mit Suche und Kacheln (ADR-55).
|
||||||
*/
|
*/
|
||||||
class ShopController extends Controller
|
class ShopController extends Controller
|
||||||
{
|
{
|
||||||
@@ -23,8 +27,14 @@ public function closed(): View|RedirectResponse
|
|||||||
return Shop::checkoutOpen() ? redirect()->route('shop') : view('shop.closed');
|
return Shop::checkoutOpen() ? redirect()->route('shop') : view('shop.closed');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index(Request $request, ShopCatalog $catalog): View
|
public function index(Request $request, ShopCatalog $catalog, PageController $pages): View
|
||||||
{
|
{
|
||||||
|
$page = Page::query()->where('path', '/shop')->whereNotNull('published_revision_id')->first();
|
||||||
|
|
||||||
|
if ($page !== null) {
|
||||||
|
return $pages->showPage($page);
|
||||||
|
}
|
||||||
|
|
||||||
$term = trim((string) $request->query('suche', ''));
|
$term = trim((string) $request->query('suche', ''));
|
||||||
|
|
||||||
return view('shop.index', ['cards' => $catalog->cards($term), 'term' => $term]);
|
return view('shop.index', ['cards' => $catalog->cards($term), 'term' => $term]);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
use App\Domain\Cms\Widgets\Types\MediaCardWidget;
|
use App\Domain\Cms\Widgets\Types\MediaCardWidget;
|
||||||
use App\Domain\Cms\Widgets\Types\ProgramCardWidget;
|
use App\Domain\Cms\Widgets\Types\ProgramCardWidget;
|
||||||
use App\Domain\Cms\Widgets\Types\ProseWidget;
|
use App\Domain\Cms\Widgets\Types\ProseWidget;
|
||||||
|
use App\Domain\Cms\Widgets\Types\ShopProductsWidget;
|
||||||
use App\Domain\Cms\Widgets\Types\TopicCardWidget;
|
use App\Domain\Cms\Widgets\Types\TopicCardWidget;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@@ -34,6 +35,7 @@
|
|||||||
ProgramCardWidget::class,
|
ProgramCardWidget::class,
|
||||||
CallToActionWidget::class,
|
CallToActionWidget::class,
|
||||||
FaqWidget::class,
|
FaqWidget::class,
|
||||||
|
ShopProductsWidget::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -45,7 +47,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
| Früher vorbereiteter Warenkorbzugang. Seit Etappe 1 folgt der Eintrag in der Kopfzeile dem Shop
|
| Früher vorbereiteter Warenkorbzugang. Seit Etappe 1 folgt der Eintrag in der Kopfzeile dem Shop
|
||||||
| (App\Domain\Commerce\Shop::enabled: Testzahlung, nie in Produktion). Diese Werte werden nicht mehr gelesen.
|
| (App\Domain\Commerce\Shop::checkoutOpen). Diese Werte werden nicht mehr gelesen.
|
||||||
*/
|
*/
|
||||||
'cart' => [
|
'cart' => [
|
||||||
'enabled' => (bool) env('LUF_CART_ENABLED', false),
|
'enabled' => (bool) env('LUF_CART_ENABLED', false),
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Regeln für freie Artikel (ADR-56), rein ergänzend: Wer ein Angebot „auf Abruf“ übernehmen darf (alle Mitglieder,
|
||||||
|
* freigeschaltete Konten oder wer einen bestimmten Artikel besitzt) und die Freigaben je Konto. Freigaben werden nie
|
||||||
|
* gelöscht, nur entzogen; ein Angebot oder Konto mit Freigaben lässt sich nicht löschen (restrict).
|
||||||
|
*/
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('offers', function (Blueprint $table): void {
|
||||||
|
$table->string('claim_access', 20)->default('alle');
|
||||||
|
$table->foreignId('claim_requires_article_id')->nullable()->constrained('license_articles')->restrictOnDelete();
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create('offer_releases', function (Blueprint $table): void {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('offer_id')->constrained('offers')->restrictOnDelete();
|
||||||
|
$table->foreignId('user_id')->constrained('users')->restrictOnDelete();
|
||||||
|
$table->foreignId('granted_by')->nullable()->constrained('users')->nullOnDelete();
|
||||||
|
$table->timestamp('granted_at');
|
||||||
|
$table->timestamp('valid_until')->nullable();
|
||||||
|
$table->foreignId('revoked_by')->nullable()->constrained('users')->nullOnDelete();
|
||||||
|
$table->timestamp('revoked_at')->nullable();
|
||||||
|
$table->text('reason')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
$table->index(['offer_id', 'user_id']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('offer_releases');
|
||||||
|
|
||||||
|
Schema::table('offers', function (Blueprint $table): void {
|
||||||
|
$table->dropConstrainedForeignId('claim_requires_article_id');
|
||||||
|
$table->dropColumn('claim_access');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -26,8 +26,8 @@ ## Phasen
|
|||||||
|---|---|---|
|
|---|---|---|
|
||||||
| 1 | Aufräumen: Einzelkauf entfernen, zwei Schalter mit Hinweisseite, „Jetzt kaufen“, Menüpunkt „Shop“ nur bei sichtbarem Shop, `/angebote` leitet auf `/shop`, Mitgliederseite ohne Kauf | umgesetzt und auf `luf-test` abgenommen (ADR-53) |
|
| 1 | Aufräumen: Einzelkauf entfernen, zwei Schalter mit Hinweisseite, „Jetzt kaufen“, Menüpunkt „Shop“ nur bei sichtbarem Shop, `/angebote` leitet auf `/shop`, Mitgliederseite ohne Kauf | umgesetzt und auf `luf-test` abgenommen (ADR-53) |
|
||||||
| 2 | Kachel und Datenquelle: ein Dienst für Liste und Widget, Titelbild über die Website-Freigabe, Säulen und Materialart als Gruppen, Symbol je Materialart, Marker | umgesetzt (ADR-54) |
|
| 2 | Kachel und Datenquelle: ein Dienst für Liste und Widget, Titelbild über die Website-Freigabe, Säulen und Materialart als Gruppen, Symbol je Materialart, Marker | umgesetzt (ADR-54) |
|
||||||
| 3 | CMS: Seite „Shop“ mit Abschnitten um die Liste, Widget „Shop-Produkte“, Mitgliederseite „Für dich“ mit dem Widget darunter | offen |
|
| 3 | CMS: Seite „shop“ mit Abschnitten, Widget „Shop-Produkte“, Kacheln auf der Mitgliederseite (ADR-55) | umgesetzt; „Für dich“ folgt mit Phase 4 |
|
||||||
| 4 | Regelmodell für freie Artikel: für alle, besitzt einen Artikel, bestimmte Konten (Freigabe je Angebot und Konto, wie bei Rabattcodes) | offen |
|
| 4 | Regelmodell für freie Artikel: für alle, besitzt einen Artikel, bestimmte Konten (Freigabe je Angebot und Konto, wie bei Rabattcodes), „Für dich“ | umgesetzt (ADR-56) |
|
||||||
| 5 | Viele Produkte: Listenansicht, Filter, Sortierung, Seiten | offen |
|
| 5 | Viele Produkte: Listenansicht, Filter, Sortierung, Seiten | offen |
|
||||||
|
|
||||||
Jede Phase wird mit Tests, einer Sicherheitsdurchsicht und (bei Oberfläche) der Abnahme auf `luf-test` belegt (`docs/ux/verwaltung/abnahme/etappe-1.md`).
|
Jede Phase wird mit Tests, einer Sicherheitsdurchsicht und (bei Oberfläche) der Abnahme auf `luf-test` belegt (`docs/ux/verwaltung/abnahme/etappe-1.md`).
|
||||||
@@ -37,6 +37,6 @@ ## Randbedingungen, die der Plan benennt
|
|||||||
- **Daten, nicht Code:** Die CMS-Seite `/angebote` und ihr Menüpunkt liegen in der Datenbank. Auf `luf-test` und Prod entfernt sie Lars in der Webpräsenz; eine Migration löscht sie nicht (CLAUDE.md). Der Seeder legt sie für neue Installationen nicht mehr an.
|
- **Daten, nicht Code:** Die CMS-Seite `/angebote` und ihr Menüpunkt liegen in der Datenbank. Auf `luf-test` und Prod entfernt sie Lars in der Webpräsenz; eine Migration löscht sie nicht (CLAUDE.md). Der Seeder legt sie für neue Installationen nicht mehr an.
|
||||||
- **Private Medien:** Das Titelbild erscheint nur über die Website-Freigabe (`/website-medien/…`), nie über Mitgliedervorschauen.
|
- **Private Medien:** Das Titelbild erscheint nur über die Website-Freigabe (`/website-medien/…`), nie über Mitgliedervorschauen.
|
||||||
- **Kein Taxonomie-Ausbau:** Gruppen kommen aus Säulen (`PillarService`) und Materialart (`EditorialVocabulary`).
|
- **Kein Taxonomie-Ausbau:** Gruppen kommen aus Säulen (`PillarService`) und Materialart (`EditorialVocabulary`).
|
||||||
- **Bis Phase 4** kann jedes angemeldete Konto jedes Abrufangebot übernehmen (heutiges Verhalten). Neue Abrufangebote bis dahin nur anlegen, wenn das gewollt ist.
|
- **Regeln für freie Artikel (Phase 4)** gelten ab dem Deployment; ohne Einstellung bleibt die Regel „alle angemeldeten Mitglieder“, also das bisherige Verhalten.
|
||||||
- **Offene Bestellungen auf Prod** aus dem bisherigen Einzelkauf: Lesen nur mit Freigabe von Lars, Löschen entscheidet er.
|
- **Offene Bestellungen auf Prod** aus dem bisherigen Einzelkauf: Lesen nur mit Freigabe von Lars, Löschen entscheidet er.
|
||||||
- **Weiter offen (nicht Teil dieses Plans):** Dialog für Pakete, Teilbesitz bei Paketen, Aufteilung des Paketpreises im Journal, Steuer und Belege (OPEN-06), Rechtstexte, Stripe-Live.
|
- **Weiter offen (nicht Teil dieses Plans):** Dialog für Pakete, Teilbesitz bei Paketen, Aufteilung des Paketpreises im Journal, Steuer und Belege (OPEN-06), Rechtstexte, Stripe-Live.
|
||||||
@@ -810,3 +810,30 @@ ## ADR-54 – Shopkachel: Titelbild, Säulen, Materialart mit Symbol und Marker
|
|||||||
- **Marker.** Neue Spalte `license_articles.shop_markers`. „Neu“ (erstes Angebot als Kauf) und „Aktualisiert“ (neuer Stand, nie zusammen mit „Neu“) folgen automatisch für `shop.marker_days` (30) Tage und lassen sich am Artikel fest an- oder abschalten; „Beliebt“ setzt die Redaktion von Hand, bis es Verkaufszahlen gibt. Ein Marker trägt immer sein Wort. Die Aktion „Marker ändern“ im Abschnitt „Im Shop verkaufen“ speichert nur die Marker, nicht die Redaktion des Artikels. Sterne und Kundenbewertungen folgen später und sind nicht vorbereitet.
|
- **Marker.** Neue Spalte `license_articles.shop_markers`. „Neu“ (erstes Angebot als Kauf) und „Aktualisiert“ (neuer Stand, nie zusammen mit „Neu“) folgen automatisch für `shop.marker_days` (30) Tage und lassen sich am Artikel fest an- oder abschalten; „Beliebt“ setzt die Redaktion von Hand, bis es Verkaufszahlen gibt. Ein Marker trägt immer sein Wort. Die Aktion „Marker ändern“ im Abschnitt „Im Shop verkaufen“ speichert nur die Marker, nicht die Redaktion des Artikels. Sterne und Kundenbewertungen folgen später und sind nicht vorbereitet.
|
||||||
**Folgen.** Zwei neue, leer zulässige Spalten; ein Rollback des Codes lässt sie unbenutzt liegen. Ohne Pflege erscheint die Kachel wie bisher, nur mit Platzhalter statt Bild.
|
**Folgen.** Zwei neue, leer zulässige Spalten; ein Rollback des Codes lässt sie unbenutzt liegen. Ohne Pflege erscheint die Kachel wie bisher, nur mit Platzhalter statt Bild.
|
||||||
**Quelle.** Anfrage von Lars vom 26.11.2026; ADR-30, ADR-40, ADR-52, ADR-53.
|
**Quelle.** Anfrage von Lars vom 26.11.2026; ADR-30, ADR-40, ADR-52, ADR-53.
|
||||||
|
|
||||||
|
## ADR-55 – Der Shop im CMS: Seite „shop“ der Webpräsenz und das Widget „Shop-Produkte“
|
||||||
|
|
||||||
|
**Status am 26.11.2026:** Umgesetzt auf `feature/shop-aufraeumen` (Phase 3 des Plans `docs/analysen/shop-umbauplan-2026-11-26.md`); Abnahme auf luf-test siehe `docs/ux/verwaltung/abnahme/etappe-1.md`, Abschnitt „Shop im CMS“. Die Produktivfreigabe bleibt bei Lars.
|
||||||
|
**Kontext.** Der Shop (`/shop`) war eine feste Seite der Anwendung ohne Banner, Grafiken oder Texte der Redaktion. Lars wollte den Shop bis zu einem gewissen Grad im CMS verwalten (Banner, grafische Elemente) und die Kacheln als Widget, ohne den Shop umzubauen.
|
||||||
|
**Entscheidung (Auftrag von Lars, 26.11.2026).**
|
||||||
|
- **`/shop` bleibt eine Route der Anwendung** (Schalter, Produktseiten und Kasse hängen daran). Gibt es in der Webpräsenz eine **veröffentlichte Seite mit dem Pfad `/shop`**, rendert die Anwendung sie mit denselben Abschnitten wie jede CMS-Seite (Banner, Grafiken, Texte); ohne sie zeigt `/shop` die Standardseite mit Suche und Kacheln. Es gibt keine Migration; die Redaktion legt die Seite an, wenn sie sie will.
|
||||||
|
- **Widget „Shop-Produkte“ (`shop_products`).** Eine eigene Art, keine Variante der Programmkarte (ADR-39 verbietet dort Preis und Kauf). Es zeigt die Kacheln aus `ShopCatalog`, optional gefiltert nach Säule und Materialart, sortiert (alphabetisch, neueste zuerst, Preis aufsteigend), begrenzt (3 bis 24) und mit Suchfeld. Es speichert nur Darstellungswahl und Filter; Titel, Bild, Preis und Marker kommen zur Laufzeit. Es ist auf jeder CMS-Seite einsetzbar und rendert **nichts**, solange der Shop nicht sichtbar ist (öffentlich leer, in der Vorschau mit Hinweis).
|
||||||
|
- **Sitemap und Indexierung.** Die Seite `/shop` steht nicht in der Sitemap, solange nicht gekauft werden kann; die Shopseiten sind dann `noindex` (ADR-53).
|
||||||
|
- **Mitgliederseite „Angebote“.** Sie zeigt unter dem Abruf kostenloser Angebote die sechs neuesten Produkte als Kacheln aus derselben Datenquelle und „Zum Shop“, wenn der Shop sichtbar ist.
|
||||||
|
- **Suche.** Der Suchbegriff wird auf 100 Zeichen gekürzt und maskiert ausgegeben.
|
||||||
|
**Alternativen.** Der Shop als reine CMS-Seite (verworfen: Suche, Schalter und Produktseiten hingen dann an Widgets und Seitenpfaden; mehr Umbau, mehr Risiko). Feste Bannerfelder in der Anwendung (verworfen: eine zweite Verwaltung neben dem CMS).
|
||||||
|
**Folgen.** Eine neue Widget-Art in `config/cms.php`; keine Daten, kein Schema. Wer die Seite `/shop` in der Webpräsenz anlegt, muss das Widget einsetzen, sonst zeigt `/shop` keine Produkte.
|
||||||
|
**Quelle.** Anfrage von Lars vom 26.11.2026; ADR-30, ADR-38, ADR-39, ADR-53, ADR-54.
|
||||||
|
|
||||||
|
## ADR-56 – Regeln für freie Artikel und „Für dich“ im Mitgliederbereich
|
||||||
|
|
||||||
|
**Status am 26.11.2026:** Umgesetzt auf `feature/shop-aufraeumen` (Phase 4 des Plans `docs/analysen/shop-umbauplan-2026-11-26.md`); Abnahme siehe `docs/ux/verwaltung/abnahme/etappe-1.md`, Abschnitt „Regeln für freie Artikel“. Die Produktivfreigabe bleibt bei Lars.
|
||||||
|
**Kontext.** Jedes angemeldete Konto konnte jedes Angebot „auf Abruf“ übernehmen (`GrantIssuer::claim` prüfte nur Vergabeart und Inhaberart). Freie Artikel sollen aber nach Regeln vergeben werden können, auch an bestimmte Konten, ähnlich den Rabattcodes. Die Mitgliederseite „Angebote“ soll zeigen, was für das Konto bereitliegt.
|
||||||
|
**Entscheidung (Auftrag von Lars, 26.11.2026).**
|
||||||
|
- **Drei Regeln je Angebot auf Abruf** (`offers.claim_access`): alle angemeldeten Mitglieder (Vorgabe, bisheriges Verhalten), nur ausdrücklich freigeschaltete Konten, Mitglieder, die einen bestimmten anderen Artikel besitzen (`offers.claim_requires_article_id`, gültige aktive Berechtigung des Kontos auf diesen Artikel). Die Regel begrenzt nur den freien Abruf; sie vergibt nichts. Vergaben „bei Registrierung“ gehen weiter automatisch an neue Konten und kennen keine Regel; Käufe laufen über die Kasse.
|
||||||
|
- **Serverseitig geprüft.** `OfferAccess::assertMayClaim` läuft in `GrantIssuer::claim`; ein Konto ohne Berechtigung bekommt nichts, auch wenn es die Adresse kennt. Die Meldung nennt die Regel nicht. Die Seite „Angebote“ zeigt ein Angebot nur, wenn das Konto es abrufen darf und noch nicht übernommen hat (`OfferAccess::claimable`).
|
||||||
|
- **Freigaben je Angebot und Konto** (`offer_releases`), nach dem Muster der Rabattcode-Freigaben (ADR-47): Grundlage, optionales Ende, Freigabe und Entzug mit Person und Zeitpunkt, **nie gelöscht, nur entzogen**; eine Freigabe für ein Angebot ist keine für ein anderes. Ein bereits übernommenes Angebot bleibt nach dem Entzug in der Bibliothek. Angebot und Konto mit Freigaben lassen sich nicht löschen (restrict). Gepflegt wird im Angebot (Katalogverwalter): „Regel für den Abruf“, „Konto freischalten“, „Entziehen“.
|
||||||
|
- **„Für dich“ (Mitgliederseite „Angebote“).** Oben „Neu für dich“: neue Stände zu Artikeln, die das Konto besitzt, 90 Tage nach der Veröffentlichung (`NewStands`). Nach der Updatepolitik (ADR-09, OPEN-01) stehen sie dem Inhaber ohne Aufpreis zu und liegen schon in der Bibliothek; die Liste vergibt nichts. Danach „Zum Übernehmen“ (Angebote nach der Regel), darunter der Shop mit den neuesten Produkten (ADR-55).
|
||||||
|
**Nicht Teil dieses Schritts.** Keine Benachrichtigung per E-Mail bei einer Freigabe (das Konto sieht sie bei seinem nächsten Besuch); Gruppen und „Konto seit …“ als weitere Regeln; ein Ende des Abrufs je Angebot (dafür gibt es das Beenden der Fassung).
|
||||||
|
**Folgen.** Eine additive Migration (zwei Spalten an `offers`, Tabelle `offer_releases`). **Bis zum Deployment gilt weiter die Regel „alle“** für jedes Angebot auf Abruf; die Vorgabe ändert kein bestehendes Verhalten. Wer ein Angebot auf Abruf nur bestimmten Konten geben will, stellt die Regel um, bevor er es aktiviert.
|
||||||
|
**Quelle.** Anfrage von Lars vom 26.11.2026; ADR-09, ADR-47, ADR-52, ADR-55.
|
||||||
@@ -82,6 +82,7 @@ ## 4. Registrierte Widget-Arten
|
|||||||
| `program_card` | Programm- oder Modulkarte, Kit v1.7 | 1 | `adaptive`, `stacked` | 1–4 | `auto` (Vorgabe), `fill` | `refs.composition`, `refs.image` |
|
| `program_card` | Programm- oder Modulkarte, Kit v1.7 | 1 | `adaptive`, `stacked` | 1–4 | `auto` (Vorgabe), `fill` | `refs.composition`, `refs.image` |
|
||||||
| `call_to_action` | Handlungsaufruf | 1 | `standard` | 1–4 | `auto` (Vorgabe), `fill` (Abschnittshöhe füllen) | – |
|
| `call_to_action` | Handlungsaufruf | 1 | `standard` | 1–4 | `auto` (Vorgabe), `fill` (Abschnittshöhe füllen) | – |
|
||||||
| `faq` | FAQ | 1 | `standard` | 2–4 | – | – |
|
| `faq` | FAQ | 1 | `standard` | 2–4 | – | – |
|
||||||
|
| `shop_products` | Shop-Produkte (Kacheln aus `ShopCatalog`, ADR-55) | 1 | `kacheln` | 2–4 | – | – (Filter `data.pillar`, `data.kind`; Einstellungen `sort`, `limit`, `search`) |
|
||||||
|
|
||||||
Darstellungsklassen an der Widget-Hülle: `widget widget-<typ> widget-variant-<variante>` und, wenn die Art Höhen anbietet, `widget-height-<höhe>`. Premium-Ansichten: `lf-hero lf-hero--{photo-split|editorial-solid} lf-hero--height-<höhe> lf-hero--accent-<akzent>` und `lf-bt lf-bt--{cream|clear|navy} lf-bt--image-{left|right} lf-bt--height-<höhe>`.
|
Darstellungsklassen an der Widget-Hülle: `widget widget-<typ> widget-variant-<variante>` und, wenn die Art Höhen anbietet, `widget-height-<höhe>`. Premium-Ansichten: `lf-hero lf-hero--{photo-split|editorial-solid} lf-hero--height-<höhe> lf-hero--accent-<akzent>` und `lf-bt lf-bt--{cream|clear|navy} lf-bt--image-{left|right} lf-bt--height-<höhe>`.
|
||||||
|
|
||||||
|
|||||||
@@ -186,6 +186,8 @@ ## Verkaufsstart: Freigabe und Betrieb (Stand 24.11.2026, vorbereitet, nicht fre
|
|||||||
|
|
||||||
**Shopkachel (ADR-54):** Migration `2026_12_01_100000_add_shop_presentation_fields`, rein ergänzend (Spalten `editorial_content_kinds.symbol` und `license_articles.shop_markers`, beide leer zulässig; bei einem Rollback des Codes bleiben sie ungenutzt liegen). Titelbilder erscheinen nur mit Website-Freigabe des Mediums.
|
**Shopkachel (ADR-54):** Migration `2026_12_01_100000_add_shop_presentation_fields`, rein ergänzend (Spalten `editorial_content_kinds.symbol` und `license_articles.shop_markers`, beide leer zulässig; bei einem Rollback des Codes bleiben sie ungenutzt liegen). Titelbilder erscheinen nur mit Website-Freigabe des Mediums.
|
||||||
|
|
||||||
|
**Regeln für freie Artikel (ADR-56):** Migration `2026_12_01_110000_add_offer_claim_rules`, rein ergänzend (`offers.claim_access` mit Vorgabe `alle`, `offers.claim_requires_article_id`, Tabelle `offer_releases` ohne Kaskade). Bestehende Angebote auf Abruf behalten das bisherige Verhalten; bei einem Rollback des Codes bleiben Spalten und Tabelle liegen, die Regeln gelten dann nicht mehr (jedes Konto kann abrufen). **Vor einem Rollback prüfen**, ob ein Angebot auf Abruf nur für bestimmte Konten gedacht war.
|
||||||
|
|
||||||
Weitere Einstellungen: `SHOP_INVOICE` (Standard **aus**: Kauf auf Rechnung für Organisationen wird Mitgliedern erst angeboten, wenn der Prozess vollständig ist; die Umsetzung bleibt erhalten, vorhandene Rechnungsbestellungen bleiben in der Verwaltung bearbeitbar; `true` schaltet die Option im Checkout ein), `SHOP_PRICE_NOTE` (Preis- und Steuerhinweis im Warenkorb, Standard „Alle Preise in Euro.“), `STRIPE_TAX_RATE_ID` (im Preis enthaltener Steuersatz; Steuerstatus offen, OPEN-06). Die Verwaltungsseite **Verkauf → Verkaufsstart** zeigt den Zustand ohne Schlüssel.
|
Weitere Einstellungen: `SHOP_INVOICE` (Standard **aus**: Kauf auf Rechnung für Organisationen wird Mitgliedern erst angeboten, wenn der Prozess vollständig ist; die Umsetzung bleibt erhalten, vorhandene Rechnungsbestellungen bleiben in der Verwaltung bearbeitbar; `true` schaltet die Option im Checkout ein), `SHOP_PRICE_NOTE` (Preis- und Steuerhinweis im Warenkorb, Standard „Alle Preise in Euro.“), `STRIPE_TAX_RATE_ID` (im Preis enthaltener Steuersatz; Steuerstatus offen, OPEN-06). Die Verwaltungsseite **Verkauf → Verkaufsstart** zeigt den Zustand ohne Schlüssel.
|
||||||
|
|
||||||
- **Erstattung bei Stripe:** `Checkout::refund` ruft vor dem Entzug der Rechte `POST /v1/refunds` (Vollbetrag, Idempotenzschlüssel `luf-refund-<Bestellung>-<Zahlung>`) auf; schlägt das fehl, bleibt die Bestellung unverändert. Dafür muss der API-Schlüssel das Recht „Refunds: write“ haben (bei eingeschränktem Schlüssel `rk_…` prüfen). Die Zahlungsabsicht (`payment_intent`) wird aus der signierten Meldung gespeichert, sonst bei Stripe abgefragt.
|
- **Erstattung bei Stripe:** `Checkout::refund` ruft vor dem Entzug der Rechte `POST /v1/refunds` (Vollbetrag, Idempotenzschlüssel `luf-refund-<Bestellung>-<Zahlung>`) auf; schlägt das fehl, bleibt die Bestellung unverändert. Dafür muss der API-Schlüssel das Recht „Refunds: write“ haben (bei eingeschränktem Schlüssel `rk_…` prüfen). Die Zahlungsabsicht (`payment_intent`) wird aus der signierten Meldung gespeichert, sonst bei Stripe abgefragt.
|
||||||
|
|||||||
@@ -59,6 +59,34 @@ ## Produktseite je Lizenzartikel (25.11.2026, auf `luf-test`)
|
|||||||
3. **Altbestand mit mehreren Positionen und Programmseite** im Browser: durch Test belegt, auf `luf-test` gibt es keinen solchen Fall.
|
3. **Altbestand mit mehreren Positionen und Programmseite** im Browser: durch Test belegt, auf `luf-test` gibt es keinen solchen Fall.
|
||||||
4. **Der Dialog selbst** ist unverändert lang (Eignung, Nutzerkreis, Vergabe, Preis, „Programmfassung, die abgedeckt sein muss“, Positionen). Die Vereinfachung mit mehreren Optionen je Artikel (Rechteprofil mit Preis) folgt als nächster Schritt.
|
4. **Der Dialog selbst** ist unverändert lang (Eignung, Nutzerkreis, Vergabe, Preis, „Programmfassung, die abgedeckt sein muss“, Positionen). Die Vereinfachung mit mehreren Optionen je Artikel (Rechteprofil mit Preis) folgt als nächster Schritt.
|
||||||
|
|
||||||
|
## Shopkachel: Titelbild, Säulen, Materialart mit Symbol, Marker (26.11.2026, auf `luf-test` und lokal)
|
||||||
|
|
||||||
|
**Geprüfter Stand:** Commit `0ac7088` auf `develop`; `CI Feature / test`, `Deploy Test / test` und `Deploy Test / deploy` **success** (öffentliche Gitea-Statusabfrage). Entscheidung: ADR-54, Plan `docs/analysen/shop-umbauplan-2026-11-26.md`, Phase 2.
|
||||||
|
|
||||||
|
**Auslöser.** Die Kachel zeigte nur Titel, Kurztext und „ab Preis“: kein Titelbild, keine Gruppen, keine Materialart, keine Marker.
|
||||||
|
|
||||||
|
**Tests.** `ShopTilesTest` (18 Tests): ohne freigegebenes Titelbild ein Platzhalter und kein Bild; ein nicht freigegebenes Titelbild erscheint nie (kein Bild, keine Adresse, kein Titel des Mediums im Quelltext); ein freigegebenes erscheint als schmückendes Bild mit leerem `alt` und `loading="lazy"`; ein nicht freigegebenes erstes Bild wird zugunsten des nächsten freigegebenen übersprungen; ein Film dient nie als Titelbild; nur veröffentlichte Säulen erscheinen, die Suche findet über Säule und Materialart; Materialart und Symbol erscheinen ohne Bild, ein unbekannter Symbolschlüssel wird ignoriert und nicht ausgegeben; das Symbol wird in den Stammdaten gespeichert, ein ungültiges verworfen; „Neu“ erscheint automatisch für 30 Tage nach dem ersten Angebot, „Aktualisiert“ nach einem neuen Stand (nie zusammen mit „Neu“), die Einstellung der Redaktion hat Vorrang und „Beliebt“ ist nur von Hand; eine unzulässige Einstellung wird abgelehnt und Vorgaben greifen; Marker tragen ihr Wort und eine Ansage für Bildschirmleser; die Aktion „Marker ändern“ speichert nur die Marker und lässt die Redaktion unberührt; nur der Katalogverwalter erreicht sie (Redakteur und Mitglied ohne Rolle bekommen 403); Shopseite und Datenquelle zeigen dieselben Produkte in derselben Reihenfolge; ein archivierter Artikel und ein Artikel ohne Option stehen nicht im Shop. Die Gesamtsuite (1043 Tests) lief lokal ohne andere Fehler als die bekannten Symbolfehler der lokalen `vendor`-Kopie; das CI-Gate ist grün.
|
||||||
|
|
||||||
|
**Sicherheitsdurchsicht (Phase 2).** Das Titelbild kommt nur über `WebsiteMedia::present` (Freigabe, Pfadmuster, Datei im öffentlichen Speicher) und wird über `/website-medien/{id}` ausgeliefert, nie über Mitgliedervorschauen oder `originals`. Alle Texte der Kachel sind maskiert; der Symbolschlüssel wird an der Materialart und noch einmal beim Ausgeben gegen den Katalog geprüft. Die Marker-Aktion ist auf den Katalogverwalter beschränkt und prüft jede Einstellung gegen eine feste Liste. Die Migration ist rein ergänzend (zwei leer zulässige Spalten).
|
||||||
|
|
||||||
|
**Geprüft im echten Browser.** Chromium über Playwright (Skripte nicht im Repository). Auf `luf-test` gibt es kein Medium mit Website-Freigabe am Artikel; die Kachel mit Bild, Säulen, Symbol und mehreren Markern wurde deshalb lokal mit der Demo-Datenbank geprüft.
|
||||||
|
|
||||||
|
| Fall | Ort | Ergebnis | Belege |
|
||||||
|
|---|---|---|---|
|
||||||
|
| Kacheln mit Bild, Platzhalter mit Symbol, Marker, Säulen (1280, 768, 390 px) | lokal | drei Kacheln: Titelbild, Symbol-Tafel und Paket ohne Bild; Marker „Neu“, „Beliebt“, „Aktualisiert“ mit Wort; Säulen als Chips; kein Überlauf; ein Tabstopp je Kachel, Enter auf dem Titel öffnet die Produktseite | [01](etappe-1/shop-kachel/01-lokal-kacheln-1280.jpg), [02](etappe-1/shop-kachel/02-lokal-kacheln-390.jpg) |
|
||||||
|
| Kachel im Shop, 1280 und 390 px | `luf-test` | Platzhalter, „Neu“ (erstes Angebot jünger als 30 Tage), Preis und Optionen; kein Überlauf; Enter auf dem Titel öffnet die Produktseite | [03](etappe-1/shop-kachel/03-luf-test-kachel-1280.jpg), [04](etappe-1/shop-kachel/04-luf-test-kachel-390.jpg) |
|
||||||
|
| „Marker ändern“ am Artikel | `luf-test` | Dialog mit den drei Markern; „Beliebt“ auf „Anzeigen“ stellt das Wort auf die Kachel, das Zurücksetzen nimmt es wieder weg | [05](etappe-1/shop-kachel/05-luf-test-dialog-marker.jpg), [06](etappe-1/shop-kachel/06-luf-test-kachel-beliebt.jpg) |
|
||||||
|
| Materialart bearbeiten | `luf-test` | das Formular bietet „Symbol im Shop“ an | [07](etappe-1/shop-kachel/07-luf-test-materialart-symbol.jpg) |
|
||||||
|
|
||||||
|
**Zustand von `luf-test` danach:** Die Option „Einzellizenz Abstand“ am Artikel „Programm Abstand“ wurde für den Lauf aktiv gesetzt (Fassung 6) und wieder aus dem Verkauf genommen; `/shop/4` antwortet 404. Der Marker „Beliebt“ ist zurückgesetzt. Im Shop steht außerdem ein weiterer Artikel (Kennung 10, „ab 12,00 €“), den ich nicht angefasst habe.
|
||||||
|
|
||||||
|
**Nicht geprüft (mit Grund):**
|
||||||
|
|
||||||
|
1. **Titelbild auf `luf-test`:** Dort ist am Artikel kein Bild mit Website-Freigabe gepflegt; geprüft durch Tests und lokal. Die Bildpflege selbst (Präsentationsmedien) ist unverändert.
|
||||||
|
2. **Symbolwähler bei der Materialart im Browser:** Das Feld ist im Formular sichtbar; die Auswahl eines Symbols und das Speichern sind durch Test belegt, nicht im Browser durchgespielt.
|
||||||
|
3. **Paketkacheln ohne Bild und ohne Symbol:** Pakete haben keine Materialart; sie zeigen eine leere Tafel. Ein Bild oder Symbol für Pakete gibt es noch nicht (offen).
|
||||||
|
4. **Zoom und Bildschirmleser** nicht geprüft.
|
||||||
|
|
||||||
## Shop aufräumen: zwei Schalter, Kauf nur über die Kasse, „Jetzt kaufen“ (26.11.2026, `luf-test` und lokal)
|
## Shop aufräumen: zwei Schalter, Kauf nur über die Kasse, „Jetzt kaufen“ (26.11.2026, `luf-test` und lokal)
|
||||||
|
|
||||||
**Geprüfter Stand:** Commit `3d76062` auf `develop` (zuvor `CI Feature / test` auf `feature/shop-aufraeumen`); `CI Feature / test`, `Deploy Test / test` und `Deploy Test / deploy` **success** (öffentliche Gitea-Statusabfrage). Entscheidung: ADR-53, Plan `docs/analysen/shop-umbauplan-2026-11-26.md`, Phase 1.
|
**Geprüfter Stand:** Commit `3d76062` auf `develop` (zuvor `CI Feature / test` auf `feature/shop-aufraeumen`); `CI Feature / test`, `Deploy Test / test` und `Deploy Test / deploy` **success** (öffentliche Gitea-Statusabfrage). Entscheidung: ADR-53, Plan `docs/analysen/shop-umbauplan-2026-11-26.md`, Phase 1.
|
||||||
|
|||||||
|
After Width: | Height: | Size: 70 KiB |
|
After Width: | Height: | Size: 75 KiB |
|
After Width: | Height: | Size: 53 KiB |
|
After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 127 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 116 KiB |
@@ -1726,7 +1726,8 @@ .mb-offer {
|
|||||||
background: var(--color-surface-raised);
|
background: var(--color-surface-raised);
|
||||||
}
|
}
|
||||||
|
|
||||||
.mb-offer h2 {
|
.mb-offer h2,
|
||||||
|
.mb-offer h4 {
|
||||||
font-size: var(--text-h3);
|
font-size: var(--text-h3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,30 +5,58 @@
|
|||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<x-member.hero kicker="Zugang" title="Angebote">
|
<x-member.hero kicker="Zugang" title="Angebote">
|
||||||
Hier übernimmst du Angebote ohne Kauf in deine Bibliothek. Gekauft wird im Shop.
|
Hier findest du, was für dich bereitliegt: neue Stände deiner Artikel und Angebote ohne Kauf. Gekauft wird im Shop.
|
||||||
</x-member.hero>
|
</x-member.hero>
|
||||||
@if ($errors->any())
|
@if ($errors->any())
|
||||||
<div class="errors" role="alert">{{ $errors->first() }}</div>
|
<div class="errors" role="alert">{{ $errors->first() }}</div>
|
||||||
@endif
|
@endif
|
||||||
@if ($offers->isEmpty())
|
|
||||||
<div class="empty"><h2>Keine Angebote zum Übernehmen</h2><p>Gerade ist kein kostenloses Angebot für dich aktiv.</p></div>
|
<section class="mb-offers-foryou" aria-labelledby="angebote-fuer-dich">
|
||||||
@else
|
<h2 id="angebote-fuer-dich">Für dich</h2>
|
||||||
<ul class="mb-offers">
|
@if ($stands->isEmpty() && $offers->isEmpty())
|
||||||
@foreach ($offers as $offer)
|
<div class="empty"><h3>Gerade liegt nichts Neues für dich bereit</h3><p>Neue Stände deiner Artikel und freie Angebote erscheinen hier.</p></div>
|
||||||
@php $version = $offer->versions->first(); @endphp
|
@endif
|
||||||
@continue($version === null)
|
@if ($stands->isNotEmpty())
|
||||||
<li class="mb-offer">
|
<h3>Neu für dich</h3>
|
||||||
<h2>{{ $offer->name }}</h2>
|
<p class="lede">Zu diesen Artikeln gibt es einen neuen Stand. Er steht dir ohne Aufpreis zu und liegt schon in deiner Bibliothek.</p>
|
||||||
<p>Kostenlos abrufen</p>
|
<ul class="mb-offers">
|
||||||
<form method="post" action="{{ route('member.offers.claim', $offer) }}">
|
@foreach ($stands as $stand)
|
||||||
@csrf
|
<li class="mb-offer">
|
||||||
<button class="button" type="submit">In die Bibliothek</button>
|
<h4>{{ $stand['title'] }}</h4>
|
||||||
</form>
|
<p>Stand {{ $stand['number'] }} seit {{ $stand['since']->format('d.m.Y') }}</p>
|
||||||
</li>
|
<p><a class="button button-secondary" href="{{ route('member.grant', $stand['grant']) }}">In der Bibliothek ansehen<span class="sr-only">: {{ $stand['title'] }}</span></a></p>
|
||||||
@endforeach
|
</li>
|
||||||
</ul>
|
@endforeach
|
||||||
@endif
|
</ul>
|
||||||
|
@endif
|
||||||
|
@if ($offers->isNotEmpty())
|
||||||
|
<h3>Zum Übernehmen</h3>
|
||||||
|
<ul class="mb-offers">
|
||||||
|
@foreach ($offers as $offer)
|
||||||
|
<li class="mb-offer">
|
||||||
|
<h4>{{ $offer->name }}</h4>
|
||||||
|
<p>Kostenlos abrufen</p>
|
||||||
|
<form method="post" action="{{ route('member.offers.claim', $offer) }}">
|
||||||
|
@csrf
|
||||||
|
<button class="button" type="submit">In die Bibliothek<span class="sr-only">: {{ $offer->name }}</span></button>
|
||||||
|
</form>
|
||||||
|
</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
@endif
|
||||||
|
</section>
|
||||||
|
|
||||||
@if ($shop)
|
@if ($shop)
|
||||||
<p class="mb-offers-shop"><a class="button button-secondary" href="{{ route('shop') }}">Zum Shop</a></p>
|
<section class="mb-offers-shop" aria-labelledby="angebote-shop">
|
||||||
|
<h2 id="angebote-shop">Im Shop</h2>
|
||||||
|
@if ($cards !== [])
|
||||||
|
<ul class="shop-tiles">
|
||||||
|
@foreach ($cards as $card)
|
||||||
|
@include('shop.kachel', ['card' => $card])
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
@endif
|
||||||
|
<p><a class="button button-secondary" href="{{ route('shop') }}">Zum Shop</a></p>
|
||||||
|
</section>
|
||||||
@endif
|
@endif
|
||||||
@endsection
|
@endsection
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
{{--
|
||||||
|
Shop-Produkte (ADR-55). Die Kacheln kommen aus ShopCatalog, nichts davon wird im CMS gespeichert. Ist der Shop nicht
|
||||||
|
sichtbar, bleibt der Abschnitt öffentlich leer; die Redaktionsvorschau zeigt einen Hinweis.
|
||||||
|
--}}
|
||||||
|
@if ($shopVisible || $context->preview)
|
||||||
|
<div class="shop-products">
|
||||||
|
@if (filled($data['heading'] ?? null))
|
||||||
|
<h2>{{ $data['heading'] }}</h2>
|
||||||
|
@endif
|
||||||
|
@if (filled($data['intro'] ?? null))
|
||||||
|
<p class="lede">{{ $data['intro'] }}</p>
|
||||||
|
@endif
|
||||||
|
@unless ($shopVisible)
|
||||||
|
<p class="preview-note">Der Shop ist zurzeit nicht sichtbar. Öffentlich erscheint dieser Abschnitt nicht.</p>
|
||||||
|
@else
|
||||||
|
@if (($settings['search'] ?? 'aus') === 'an')
|
||||||
|
<form class="shop-search" method="get" action="{{ route('shop') }}" role="search">
|
||||||
|
<label for="shop-suche-{{ $widget['id'] ?? 'w' }}">Shop durchsuchen</label>
|
||||||
|
<input id="shop-suche-{{ $widget['id'] ?? 'w' }}" type="search" name="suche" value="{{ $term }}" autocomplete="off">
|
||||||
|
<button class="button" type="submit">Suchen</button>
|
||||||
|
@if ($term !== '')
|
||||||
|
<a class="button button-quiet" href="{{ route('shop') }}">Suche zurücksetzen</a>
|
||||||
|
@endif
|
||||||
|
</form>
|
||||||
|
@endif
|
||||||
|
@if ($cards === [])
|
||||||
|
<div class="empty">
|
||||||
|
<h3>{{ $term !== '' ? 'Keine Treffer' : 'Noch keine kaufbaren Produkte' }}</h3>
|
||||||
|
<p>{{ $term !== '' ? 'Zu „'.$term.'“ gibt es keine kaufbaren Produkte. Prüfe die Schreibweise oder setze die Suche zurück.' : 'Sobald ein Angebot aktiv ist, erscheint es hier.' }}</p>
|
||||||
|
</div>
|
||||||
|
@else
|
||||||
|
<p class="shop-count" role="status">{{ count($cards) }} {{ count($cards) === 1 ? 'Produkt' : 'Produkte' }}</p>
|
||||||
|
<ul class="shop-tiles">
|
||||||
|
@foreach ($cards as $card)
|
||||||
|
@include('shop.kachel', ['card' => $card])
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
@endif
|
||||||
|
@endunless
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
@@ -0,0 +1,391 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ArticleService;
|
||||||
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
|
use App\Domain\Catalog\LicenseArticle;
|
||||||
|
use App\Domain\Catalog\Offer;
|
||||||
|
use App\Domain\Catalog\OfferRelease;
|
||||||
|
use App\Domain\Catalog\OfferService;
|
||||||
|
use App\Domain\Catalog\RightsProfileVersion;
|
||||||
|
use App\Domain\Commerce\Checkout;
|
||||||
|
use App\Domain\Entitlement\Acquisition;
|
||||||
|
use App\Domain\Entitlement\Grant;
|
||||||
|
use App\Domain\Entitlement\GrantIssuer;
|
||||||
|
use App\Domain\Entitlement\GrantStatus;
|
||||||
|
use App\Domain\Entitlement\NewStands;
|
||||||
|
use App\Domain\Entitlement\OfferAccess;
|
||||||
|
use App\Filament\Resources\Offers\Pages\ViewOffer;
|
||||||
|
use App\Models\User;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Livewire\Livewire;
|
||||||
|
use Tests\Support\BuildsShop;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Regeln für freie Artikel (ADR-56): Wer ein Angebot „auf Abruf“ übernehmen darf (alle, freigeschaltete Konten, wer einen
|
||||||
|
* Artikel besitzt), serverseitig beim Abruf geprüft; Freigaben je Angebot und Konto, nie gelöscht; „Neu für dich“.
|
||||||
|
*/
|
||||||
|
class OfferClaimRulesTest extends TestCase
|
||||||
|
{
|
||||||
|
use BuildsShop;
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
|
||||||
|
$this->seedShop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function access(): OfferAccess
|
||||||
|
{
|
||||||
|
return app(OfferAccess::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function rights(): RightsProfileVersion
|
||||||
|
{
|
||||||
|
return RightsProfileVersion::query()->whereHas('profile', fn ($query) => $query->where('name', 'Privatlizenz ehrenamtlich'))->firstOrFail();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Ein freies Angebot auf Abruf mit eigenem Artikel. */
|
||||||
|
private function freeOffer(string $name = 'Gratis zum Start', string $kind = 'auf_abruf'): Offer
|
||||||
|
{
|
||||||
|
$article = app(ArticleService::class)->create('gratis-'.str($name)->slug());
|
||||||
|
app(ArticleService::class)->publishRelease($article, $this->article('shop-grenzen')->currentRelease->rootCompositionVersion, 'Erster Stand.');
|
||||||
|
$service = app(OfferService::class);
|
||||||
|
$offer = $service->create($name);
|
||||||
|
$service->activate($offer, [['target' => $article->fresh(), 'rights' => $this->rights()]], ['grant_kind' => $kind, 'holder_kind' => 'person']);
|
||||||
|
|
||||||
|
return $offer->fresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function keeper(): User
|
||||||
|
{
|
||||||
|
$keeper = User::factory()->katalogverwalter()->create();
|
||||||
|
$keeper->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||||
|
|
||||||
|
return $keeper;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function userWithoutProfile(): User
|
||||||
|
{
|
||||||
|
$user = User::factory()->create();
|
||||||
|
$user->forceFill(['party_id' => null])->save();
|
||||||
|
|
||||||
|
return $user->fresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function claim(User $user, Offer $offer)
|
||||||
|
{
|
||||||
|
return $this->actingAs($user)->post(route('member.offers.claim', $offer));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function taken(User $user): int
|
||||||
|
{
|
||||||
|
return Acquisition::query()->where('party_id', $user->party_id)->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- Regel „alle“ -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
public function test_by_default_every_member_sees_and_claims_a_free_offer_exactly_once(): void
|
||||||
|
{
|
||||||
|
$offer = $this->freeOffer();
|
||||||
|
$tina = $this->tina();
|
||||||
|
|
||||||
|
$this->assertSame('alle', $offer->claim_access);
|
||||||
|
$this->assertTrue($this->access()->mayClaim($tina, $offer));
|
||||||
|
$this->actingAs($tina)->get(route('member.offers'))->assertOk()->assertSee('Gratis zum Start');
|
||||||
|
|
||||||
|
$this->claim($tina, $offer)->assertRedirect(route('member.library'));
|
||||||
|
$this->claim($tina, $offer)->assertRedirect();
|
||||||
|
$this->assertSame(1, $this->taken($tina), 'Ein zweiter Abruf legt nichts doppelt an.');
|
||||||
|
$this->actingAs($tina)->get(route('member.offers'))->assertOk()->assertDontSee('In die Bibliothek');
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- Regel „nur freigeschaltete Konten“ --------------------------------------------------------------------------
|
||||||
|
|
||||||
|
public function test_a_released_only_offer_is_hidden_and_refused_for_everyone_else_on_the_server(): void
|
||||||
|
{
|
||||||
|
$offer = $this->freeOffer();
|
||||||
|
$this->access()->setRule($offer, OfferAccess::RELEASED);
|
||||||
|
$tina = $this->tina();
|
||||||
|
$max = $this->max();
|
||||||
|
$this->access()->release($offer->fresh(), $tina, $this->keeper());
|
||||||
|
|
||||||
|
$this->actingAs($tina)->get(route('member.offers'))->assertOk()->assertSee('Gratis zum Start');
|
||||||
|
$this->actingAs($max)->get(route('member.offers'))->assertOk()->assertDontSee('Gratis zum Start');
|
||||||
|
|
||||||
|
$this->claim($max, $offer)->assertRedirect()->assertSessionHasErrors('offer');
|
||||||
|
$this->assertSame(0, $this->taken($max), 'Ein nicht freigeschaltetes Konto bekommt nichts, auch mit der Adresse.');
|
||||||
|
$this->claim($tina, $offer)->assertRedirect(route('member.library'));
|
||||||
|
$this->assertSame(1, $this->taken($tina));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_release_counts_only_for_its_own_offer_and_account(): void
|
||||||
|
{
|
||||||
|
$first = $this->freeOffer('Erstes Angebot');
|
||||||
|
$second = $this->freeOffer('Zweites Angebot');
|
||||||
|
$this->access()->setRule($first, OfferAccess::RELEASED);
|
||||||
|
$this->access()->setRule($second, OfferAccess::RELEASED);
|
||||||
|
$this->access()->release($first->fresh(), $this->tina(), $this->keeper());
|
||||||
|
|
||||||
|
$this->assertTrue($this->access()->mayClaim($this->tina(), $first->fresh()));
|
||||||
|
$this->assertFalse($this->access()->mayClaim($this->tina(), $second->fresh()));
|
||||||
|
$this->assertFalse($this->access()->mayClaim($this->max(), $first->fresh()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_revoked_or_expired_release_no_longer_allows_the_claim_but_keeps_what_was_taken(): void
|
||||||
|
{
|
||||||
|
$offer = $this->freeOffer();
|
||||||
|
$this->access()->setRule($offer, OfferAccess::RELEASED);
|
||||||
|
$keeper = $this->keeper();
|
||||||
|
$tina = $this->tina();
|
||||||
|
$max = $this->max();
|
||||||
|
$releaseTina = $this->access()->release($offer->fresh(), $tina, $keeper, now()->addDays(2));
|
||||||
|
$releaseMax = $this->access()->release($offer->fresh(), $max, $keeper);
|
||||||
|
$this->claim($max, $offer)->assertRedirect(route('member.library'));
|
||||||
|
|
||||||
|
$this->access()->revoke($releaseMax, $keeper, 'Irrtum');
|
||||||
|
$this->assertSame(1, $this->taken($max), 'Ein bereits übernommenes Angebot bleibt nach dem Entzug.');
|
||||||
|
$this->assertNotNull(OfferRelease::query()->find($releaseMax->id)->revoked_at, 'Die Freigabe bleibt mit dem Entzug gespeichert.');
|
||||||
|
|
||||||
|
$this->travel(3)->days();
|
||||||
|
$this->assertFalse($this->access()->mayClaim($tina, $offer->fresh()), 'Nach dem Ende der Freigabe ist der Abruf gesperrt.');
|
||||||
|
$this->claim($tina, $offer)->assertRedirect()->assertSessionHasErrors('offer');
|
||||||
|
$this->assertSame(0, $this->taken($tina));
|
||||||
|
$this->assertSame(2, OfferRelease::query()->count(), 'Freigaben werden nie gelöscht.');
|
||||||
|
$this->assertNotNull($releaseTina->fresh());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_releases_are_validated(): void
|
||||||
|
{
|
||||||
|
$offer = $this->freeOffer();
|
||||||
|
$keeper = $this->keeper();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->access()->release($offer, $this->tina(), $keeper);
|
||||||
|
$this->fail('Bei der Regel „alle“ gibt es keine Freigaben.');
|
||||||
|
} catch (DomainRuleException $exception) {
|
||||||
|
$this->assertStringContainsString('nur freigeschaltete Konten', $exception->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->access()->setRule($offer, OfferAccess::RELEASED);
|
||||||
|
$offer = $offer->fresh();
|
||||||
|
$this->access()->release($offer, $this->tina(), $keeper);
|
||||||
|
|
||||||
|
foreach ([
|
||||||
|
'doppelt' => fn () => $this->access()->release($offer, $this->tina(), $keeper),
|
||||||
|
'Vergangenheit' => fn () => $this->access()->release($offer, $this->max(), $keeper, now()->subDay()),
|
||||||
|
'ohne Profil' => fn () => $this->access()->release($offer, $this->userWithoutProfile(), $keeper),
|
||||||
|
] as $name => $attempt) {
|
||||||
|
try {
|
||||||
|
$attempt();
|
||||||
|
$this->fail('Diese Freigabe muss abgelehnt werden: '.$name);
|
||||||
|
} catch (DomainRuleException) {
|
||||||
|
$this->assertTrue(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertSame(1, OfferRelease::query()->count());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- Regel „besitzt einen Artikel“ -------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
private function buy(User $user, Offer $offer): void
|
||||||
|
{
|
||||||
|
$order = $this->orderOf($user, [$offer]);
|
||||||
|
app(Checkout::class)->confirmTestPayment($order, 'test-'.$order->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_an_owner_rule_opens_the_offer_only_for_accounts_with_a_valid_grant_on_the_article(): void
|
||||||
|
{
|
||||||
|
$offer = $this->freeOffer();
|
||||||
|
$article = $this->article('shop-konflikte');
|
||||||
|
$this->access()->setRule($offer, OfferAccess::OWNERS, $article->id);
|
||||||
|
$offer = $offer->fresh();
|
||||||
|
$tina = $this->tina();
|
||||||
|
|
||||||
|
$this->assertFalse($this->access()->mayClaim($tina, $offer));
|
||||||
|
$this->claim($tina, $offer)->assertRedirect()->assertSessionHasErrors('offer');
|
||||||
|
$this->assertSame(0, $this->taken($tina));
|
||||||
|
|
||||||
|
$this->buy($tina, $this->privateKonflikte());
|
||||||
|
$this->assertTrue($this->access()->mayClaim($tina, $offer));
|
||||||
|
$this->actingAs($tina)->get(route('member.offers'))->assertOk()->assertSee('Gratis zum Start');
|
||||||
|
$this->assertFalse($this->access()->mayClaim($this->max(), $offer), 'Der Besitz gilt je Konto.');
|
||||||
|
|
||||||
|
Grant::query()->where('license_article_id', $article->id)->update(['status' => GrantStatus::Widerrufen]);
|
||||||
|
$this->assertFalse($this->access()->mayClaim($tina, $offer), 'Eine widerrufene Berechtigung zählt nicht als Besitz.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_rule_itself_is_validated_and_clears_a_stale_article(): void
|
||||||
|
{
|
||||||
|
$offer = $this->freeOffer();
|
||||||
|
$article = $this->article('shop-konflikte');
|
||||||
|
|
||||||
|
foreach ([['unbekannt', null], [OfferAccess::OWNERS, null], [OfferAccess::OWNERS, 999999]] as [$access, $articleId]) {
|
||||||
|
try {
|
||||||
|
$this->access()->setRule($offer, $access, $articleId);
|
||||||
|
$this->fail('Diese Regel muss abgelehnt werden.');
|
||||||
|
} catch (DomainRuleException) {
|
||||||
|
$this->assertSame('alle', $offer->fresh()->claim_access);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$article->forceFill(['archived_at' => now()])->save();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->access()->setRule($offer, OfferAccess::OWNERS, $article->id);
|
||||||
|
$this->fail('Ein archivierter Artikel ist keine Voraussetzung.');
|
||||||
|
} catch (DomainRuleException) {
|
||||||
|
$this->assertNull($offer->fresh()->claim_requires_article_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$article->forceFill(['archived_at' => null])->save();
|
||||||
|
$this->access()->setRule($offer, OfferAccess::OWNERS, $article->id);
|
||||||
|
$this->assertSame($article->id, $offer->fresh()->claim_requires_article_id);
|
||||||
|
$this->access()->setRule($offer->fresh(), OfferAccess::ALL, $article->id);
|
||||||
|
$this->assertNull($offer->fresh()->claim_requires_article_id, 'Eine andere Regel löscht den Artikel.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- Was die Regel nicht betrifft --------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
public function test_on_registration_offers_ignore_the_rule_and_stay_listed(): void
|
||||||
|
{
|
||||||
|
$offer = $this->freeOffer('Zur Registrierung', 'bei_registrierung');
|
||||||
|
$this->access()->setRule($offer, OfferAccess::RELEASED);
|
||||||
|
$max = $this->max();
|
||||||
|
|
||||||
|
$this->assertTrue($this->access()->mayClaim($max, $offer->fresh()));
|
||||||
|
$this->assertTrue($this->access()->claimable($max)->contains('id', $offer->id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_purchase_offer_or_an_ended_offer_cannot_be_claimed_for_free(): void
|
||||||
|
{
|
||||||
|
$purchase = $this->privateKonflikte();
|
||||||
|
$tina = $this->tina();
|
||||||
|
|
||||||
|
$this->assertFalse($this->access()->mayClaim($tina, $purchase));
|
||||||
|
$this->claim($tina, $purchase)->assertRedirect()->assertSessionHasErrors('offer');
|
||||||
|
|
||||||
|
$offer = $this->freeOffer();
|
||||||
|
app(OfferService::class)->end($offer);
|
||||||
|
$this->assertFalse($this->access()->mayClaim($tina, $offer->fresh()));
|
||||||
|
$this->assertSame(0, $this->taken($tina));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_issuer_enforces_the_rule_even_without_the_page(): void
|
||||||
|
{
|
||||||
|
$offer = $this->freeOffer();
|
||||||
|
$this->access()->setRule($offer, OfferAccess::RELEASED);
|
||||||
|
|
||||||
|
$this->expectException(DomainRuleException::class);
|
||||||
|
app(GrantIssuer::class)->claim($this->max(), $offer->fresh());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- Verwaltung --------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
public function test_the_keeper_sets_the_rule_releases_and_revokes_on_the_offer_page(): void
|
||||||
|
{
|
||||||
|
$offer = $this->freeOffer();
|
||||||
|
$tina = $this->tina();
|
||||||
|
|
||||||
|
$page = Livewire::actingAs($this->keeper(), 'staff')->test(ViewOffer::class, ['record' => $offer->getKey()]);
|
||||||
|
$page->assertSee('Wer darf abrufen')->assertSee('Alle angemeldeten Mitglieder');
|
||||||
|
$page->callAction('claimRule', ['claim_access' => OfferAccess::RELEASED, 'claim_requires_article_id' => null])->assertHasNoActionErrors();
|
||||||
|
$this->assertSame('konten', $offer->fresh()->claim_access);
|
||||||
|
|
||||||
|
$page->assertSee('Freigeschaltete Konten')->callAction('release', ['user_id' => $tina->id, 'valid_until' => null, 'reason' => 'Seminar am 12.11.2026'])->assertHasNoActionErrors();
|
||||||
|
$release = OfferRelease::query()->firstOrFail();
|
||||||
|
$this->assertSame($tina->id, $release->user_id);
|
||||||
|
$this->assertTrue($this->access()->mayClaim($tina, $offer->fresh()));
|
||||||
|
$page->assertSee('Seminar am 12.11.2026');
|
||||||
|
|
||||||
|
$page->callAction('revoke', ['reason' => 'Irrtum'], ['release' => $release->id])->assertHasNoActionErrors();
|
||||||
|
$this->assertNotNull($release->fresh()->revoked_at);
|
||||||
|
$this->assertFalse($this->access()->mayClaim($tina, $offer->fresh()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_rule_actions_exist_only_for_offers_on_demand_and_only_for_the_keeper(): void
|
||||||
|
{
|
||||||
|
$purchase = $this->privateKonflikte();
|
||||||
|
Livewire::actingAs($this->keeper(), 'staff')->test(ViewOffer::class, ['record' => $purchase->getKey()])
|
||||||
|
->assertDontSee('Wer darf abrufen')
|
||||||
|
->assertActionHidden('claimRule');
|
||||||
|
|
||||||
|
$offer = $this->freeOffer();
|
||||||
|
$redakteur = User::factory()->redakteur()->create();
|
||||||
|
$redakteur->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||||
|
Livewire::actingAs($redakteur, 'staff')->test(ViewOffer::class, ['record' => $offer->getKey()])->assertForbidden();
|
||||||
|
$this->assertSame('alle', $offer->fresh()->claim_access);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_release_of_another_offer_cannot_be_revoked_through_this_offer(): void
|
||||||
|
{
|
||||||
|
$first = $this->freeOffer('Erstes');
|
||||||
|
$second = $this->freeOffer('Zweites');
|
||||||
|
$this->access()->setRule($first, OfferAccess::RELEASED);
|
||||||
|
$this->access()->setRule($second, OfferAccess::RELEASED);
|
||||||
|
$foreign = $this->access()->release($first->fresh(), $this->tina(), $this->keeper());
|
||||||
|
|
||||||
|
try {
|
||||||
|
Livewire::actingAs($this->keeper(), 'staff')->test(ViewOffer::class, ['record' => $second->getKey()])
|
||||||
|
->callAction('revoke', ['reason' => 'x'], ['release' => $foreign->id]);
|
||||||
|
} catch (\Throwable) {
|
||||||
|
// Die Freigabe eines anderen Angebots wird nicht gefunden.
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertNull($foreign->fresh()->revoked_at);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- Neu für dich ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
public function test_a_new_stand_of_an_owned_article_is_listed_for_ninety_days_and_only_for_the_owner(): void
|
||||||
|
{
|
||||||
|
$tina = $this->tina();
|
||||||
|
$article = $this->article('shop-konflikte');
|
||||||
|
$this->buy($tina, $this->privateKonflikte());
|
||||||
|
$this->assertCount(0, app(NewStands::class)->forUser($tina), 'Ohne neuen Stand gibt es nichts zu zeigen.');
|
||||||
|
|
||||||
|
app(ArticleService::class)->publishRelease($article, $article->fresh()->currentRelease->rootCompositionVersion, 'Neuer Stand mit Ergänzungen.');
|
||||||
|
$list = app(NewStands::class)->forUser($tina);
|
||||||
|
|
||||||
|
$this->assertCount(1, $list);
|
||||||
|
$this->assertSame(2, $list[0]['number']);
|
||||||
|
$this->assertCount(0, app(NewStands::class)->forUser($this->max()), 'Wer den Artikel nicht besitzt, sieht keinen neuen Stand.');
|
||||||
|
$this->actingAs($tina)->get(route('member.offers'))->assertOk()->assertSee('Neu für dich')->assertSee('Stand 2')->assertSee(route('member.grant', $list[0]['grant']), false);
|
||||||
|
|
||||||
|
$this->travel(91)->days();
|
||||||
|
$this->assertCount(0, app(NewStands::class)->forUser($tina), 'Nach 90 Tagen verschwindet der Hinweis.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_withdrawn_grant_shows_no_new_stand(): void
|
||||||
|
{
|
||||||
|
$tina = $this->tina();
|
||||||
|
$article = $this->article('shop-konflikte');
|
||||||
|
$this->buy($tina, $this->privateKonflikte());
|
||||||
|
app(ArticleService::class)->publishRelease($article, $article->fresh()->currentRelease->rootCompositionVersion, 'Neuer Stand.');
|
||||||
|
Grant::query()->where('license_article_id', $article->id)->update(['status' => GrantStatus::Widerrufen]);
|
||||||
|
|
||||||
|
$this->assertCount(0, app(NewStands::class)->forUser($tina));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_member_offers_page_shows_an_honest_empty_state(): void
|
||||||
|
{
|
||||||
|
$this->actingAs($this->max())->get(route('member.offers'))->assertOk()->assertSee('Gerade liegt nichts Neues für dich bereit');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_article_title_helper_is_the_label_in_the_rule_form(): void
|
||||||
|
{
|
||||||
|
$offer = $this->freeOffer();
|
||||||
|
$this->access()->setRule($offer, OfferAccess::OWNERS, $this->article('shop-konflikte')->id);
|
||||||
|
|
||||||
|
Livewire::actingAs($this->keeper(), 'staff')->test(ViewOffer::class, ['record' => $offer->getKey()])
|
||||||
|
->assertSee('Mitglieder, die einen bestimmten Artikel besitzen')
|
||||||
|
->assertSee('Konflikte im Training');
|
||||||
|
$this->assertInstanceOf(LicenseArticle::class, $this->article('shop-konflikte'));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,223 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\EditorialContentKind;
|
||||||
|
use App\Domain\Catalog\PillarService;
|
||||||
|
use App\Domain\Cms\Page;
|
||||||
|
use App\Domain\Cms\PageService;
|
||||||
|
use App\Domain\Cms\Widgets\RenderContext;
|
||||||
|
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||||
|
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||||
|
use App\Domain\Commerce\Shop;
|
||||||
|
use App\Domain\Commerce\ShopCatalog;
|
||||||
|
use App\Filament\Resources\Pages\Pages\CreatePage;
|
||||||
|
use App\Filament\Resources\Pages\Pages\EditPage;
|
||||||
|
use App\Models\User;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Livewire\Livewire;
|
||||||
|
use Tests\Support\BuildsShop;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Der Shop im CMS (ADR-55): Die Seite „shop“ der Webpräsenz bestimmt den Aufbau von /shop; das Widget „Shop-Produkte“
|
||||||
|
* zeigt die Kacheln aus derselben Datenquelle, mit Filter, Reihenfolge und Anzahl, und nichts, solange der Shop nicht
|
||||||
|
* sichtbar ist.
|
||||||
|
*/
|
||||||
|
class ShopCmsTest extends TestCase
|
||||||
|
{
|
||||||
|
use BuildsShop;
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
|
||||||
|
$this->seedShop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function editor(): User
|
||||||
|
{
|
||||||
|
$editor = User::factory()->redakteur()->create();
|
||||||
|
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||||
|
|
||||||
|
return $editor;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function widget(array $data = [], array $settings = []): array
|
||||||
|
{
|
||||||
|
return ['type' => 'shop_products', 'v' => 1, 'variant' => 'kacheln', 'settings' => $settings, 'data' => $data];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function publish(string $path, array $sections): Page
|
||||||
|
{
|
||||||
|
$page = Page::query()->firstOrCreate(['path' => $path]);
|
||||||
|
$service = app(PageService::class);
|
||||||
|
$service->publish($page, $service->saveRevision($page, $sections, null, null, null));
|
||||||
|
|
||||||
|
return $page->fresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function section(array $widget): array
|
||||||
|
{
|
||||||
|
return ['layout' => 'u4', 'style' => [], 'slots' => [$widget]];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function banner(string $text): array
|
||||||
|
{
|
||||||
|
return ['layout' => 'u4', 'style' => [], 'slots' => [['type' => 'heading', 'v' => 1, 'variant' => 'standard', 'settings' => [], 'data' => ['heading' => $text], 'refs' => []]]];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_widget_is_registered_with_an_honest_contract(): void
|
||||||
|
{
|
||||||
|
$type = app(WidgetRegistry::class)->get('shop_products');
|
||||||
|
|
||||||
|
$this->assertSame('Shop-Produkte', $type->label());
|
||||||
|
$this->assertContains(4, $type->supportedUnits());
|
||||||
|
$this->assertNotSame([], $type->schematic());
|
||||||
|
$this->assertArrayHasKey('kacheln', $type->variants());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_editor_offers_the_widget_saves_its_choices_and_reopens_the_page(): void
|
||||||
|
{
|
||||||
|
$widget = ['type' => 'shop_products', 'data' => ['variant' => 'kacheln', 'data' => ['heading' => 'Alle Produkte', 'pillar' => null, 'kind' => null], 'settings' => ['sort' => 'preis', 'limit' => 'n6', 'search' => 'an']]];
|
||||||
|
$slots = [(string) Str::uuid() => ['widget' => [(string) Str::uuid() => $widget]]];
|
||||||
|
|
||||||
|
Livewire::actingAs($this->editor(), 'staff')
|
||||||
|
->test(CreatePage::class)
|
||||||
|
->fillForm(['path' => '/shop', 'seo_title' => 'Shop', 'sections' => [['id' => null, 'layout' => 'u4', 'style' => [], 'slots' => $slots]]])
|
||||||
|
->call('create')
|
||||||
|
->assertHasNoFormErrors();
|
||||||
|
|
||||||
|
$page = Page::query()->where('path', '/shop')->firstOrFail();
|
||||||
|
$saved = $page->latestRevision->sections[0]['slots'][0];
|
||||||
|
$this->assertSame('shop_products', $saved['type']);
|
||||||
|
$this->assertSame('kacheln', $saved['variant']);
|
||||||
|
$this->assertSame(['sort' => 'preis', 'limit' => 'n6', 'search' => 'an'], $saved['settings']);
|
||||||
|
|
||||||
|
Livewire::actingAs($this->editor(), 'staff')->test(EditPage::class, ['record' => $page->getKey()])->assertOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_widget_lists_the_products_with_tiles_on_any_page(): void
|
||||||
|
{
|
||||||
|
$this->publish('/empfehlungen', [$this->section($this->widget(['heading' => 'Unsere Produkte']))]);
|
||||||
|
|
||||||
|
$this->get('/empfehlungen')->assertOk()
|
||||||
|
->assertSee('Unsere Produkte')
|
||||||
|
->assertSee('Konflikte im Training')
|
||||||
|
->assertSee('Grenzen setzen im Verein')
|
||||||
|
->assertSee('class="shop-tile"', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_shop_page_of_the_web_presence_shapes_the_shop_with_banner_and_widget(): void
|
||||||
|
{
|
||||||
|
$this->publish('/shop', [$this->banner('Willkommen im Shop'), $this->section($this->widget([], ['search' => 'an']))]);
|
||||||
|
|
||||||
|
$this->get(route('shop'))->assertOk()
|
||||||
|
->assertSee('Willkommen im Shop')
|
||||||
|
->assertSee('Konflikte im Training')
|
||||||
|
->assertSee('Shop durchsuchen');
|
||||||
|
$this->get(route('shop', ['suche' => 'Grenzen']))->assertOk()
|
||||||
|
->assertSee(route('shop.article', $this->article('shop-grenzen')), false)
|
||||||
|
->assertDontSee(route('shop.article', $this->article('shop-konflikte')), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_without_a_cms_page_the_application_default_shop_stays(): void
|
||||||
|
{
|
||||||
|
$this->get(route('shop'))->assertOk()->assertSee('Shop durchsuchen')->assertSee('Konflikte im Training');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_an_unpublished_shop_page_does_not_replace_the_default(): void
|
||||||
|
{
|
||||||
|
Page::query()->create(['path' => '/shop']);
|
||||||
|
|
||||||
|
$this->get(route('shop'))->assertOk()->assertSee('Shop durchsuchen');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_widget_hides_itself_and_the_shop_page_is_gone_while_the_shop_is_not_visible(): void
|
||||||
|
{
|
||||||
|
$this->publish('/shop', [$this->banner('Willkommen im Shop'), $this->section($this->widget())]);
|
||||||
|
$this->publish('/empfehlungen', [$this->banner('Seite'), $this->section($this->widget(['heading' => 'Unsere Produkte']))]);
|
||||||
|
$this->app['env'] = 'production';
|
||||||
|
config(['services.payment.driver' => 'stripe', 'services.stripe.secret' => 'sk_live_nur_fuer_tests', 'shop.public' => false, 'shop.live_release' => false]);
|
||||||
|
|
||||||
|
$this->assertFalse(Shop::visible());
|
||||||
|
$this->get('/shop')->assertNotFound();
|
||||||
|
$this->get('/empfehlungen')->assertOk()->assertDontSee('Unsere Produkte')->assertDontSee('shop-tile');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_shop_page_is_left_out_of_the_sitemap_while_nobody_can_buy(): void
|
||||||
|
{
|
||||||
|
$this->publish('/shop', [$this->section($this->widget())]);
|
||||||
|
$this->get('/sitemap.xml')->assertOk()->assertSee(url('/shop'), false);
|
||||||
|
|
||||||
|
$this->app['env'] = 'production';
|
||||||
|
config(['services.payment.driver' => 'stripe', 'services.stripe.secret' => 'sk_live_nur_fuer_tests', 'shop.public' => true, 'shop.live_release' => false]);
|
||||||
|
$this->assertTrue(Shop::visible());
|
||||||
|
$this->get('/sitemap.xml')->assertOk()->assertDontSee(url('/shop'), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_widget_limit_setting_cuts_the_list(): void
|
||||||
|
{
|
||||||
|
$this->publish('/zwei-produkte', [$this->section($this->widget([], ['limit' => 'n3', 'sort' => 'name']))]);
|
||||||
|
$this->get('/zwei-produkte')->assertOk()->assertSee('3 Produkte');
|
||||||
|
|
||||||
|
$widget = app(WidgetRegistry::class)->get('shop_products');
|
||||||
|
$cards = $widget->resolve(['data' => [], 'settings' => ['limit' => 'n2']], RenderContext::publicPage())['cards'];
|
||||||
|
$this->assertCount(2, $cards);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_widget_filters_by_pillar_and_kind_sorts_and_limits(): void
|
||||||
|
{
|
||||||
|
$service = app(PillarService::class);
|
||||||
|
$pillar = $service->create('Grenzen und Wertschätzung');
|
||||||
|
$service->present($pillar, 'Grenzen und Wertschätzung', 'grenzen-wertschaetzung', null, true, 10);
|
||||||
|
$service->assign($this->article('shop-grenzen'), [$pillar->id]);
|
||||||
|
|
||||||
|
$this->publish('/nur-grenzen', [$this->section($this->widget(['pillar' => $pillar->id]))]);
|
||||||
|
$this->get('/nur-grenzen')->assertOk()->assertSee('Grenzen setzen im Verein')->assertDontSee('Konflikte im Training');
|
||||||
|
|
||||||
|
$names = fn (array $options): array => array_column(app(ShopCatalog::class)->cards('', $options), 'title');
|
||||||
|
$this->assertSame(['Grenzen setzen im Verein', 'Konflikte im Training', 'Starterpaket'], $names(['sort' => 'name']));
|
||||||
|
$this->assertSame(['Grenzen setzen im Verein', 'Konflikte im Training', 'Starterpaket'], $names(['sort' => 'preis']), 'Preis aufsteigend: 29, 49, 59 Euro');
|
||||||
|
$this->assertCount(2, $names(['limit' => 2]));
|
||||||
|
$this->assertSame([], $names(['pillar' => 999999]));
|
||||||
|
|
||||||
|
$kind = EditorialContentKind::query()->where('slug', 'programm')->firstOrFail();
|
||||||
|
$this->article('shop-konflikte')->forceFill(['editorial_content_kind_id' => $kind->id])->save();
|
||||||
|
$this->assertSame(['Konflikte im Training'], $names(['kind' => $kind->id]));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_very_long_search_term_is_cut_and_never_breaks_the_page(): void
|
||||||
|
{
|
||||||
|
$term = str_repeat('Grenzen ', 500);
|
||||||
|
|
||||||
|
$this->get(route('shop', ['suche' => $term]))->assertOk();
|
||||||
|
$this->assertSame([], app(ShopCatalog::class)->cards(str_repeat('x', 5000)));
|
||||||
|
$this->get(route('shop', ['suche' => '<script>alert(1)</script>']))->assertOk()->assertDontSee('<script>alert(1)</script>', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_widget_cleaning_drops_unknown_pillars_and_kinds_and_reports_them(): void
|
||||||
|
{
|
||||||
|
$type = app(WidgetRegistry::class)->get('shop_products');
|
||||||
|
$errors = new WidgetErrors;
|
||||||
|
|
||||||
|
[$data] = $type->clean(['heading' => ' Titel ', 'pillar' => 999999, 'kind' => 999999], [], $errors);
|
||||||
|
|
||||||
|
$this->assertSame('Titel', $data['heading']);
|
||||||
|
$this->assertNull($data['pillar']);
|
||||||
|
$this->assertNull($data['kind']);
|
||||||
|
$this->assertNotEmpty($errors->all());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_member_offers_page_shows_the_newest_products_as_tiles_below_the_free_offers(): void
|
||||||
|
{
|
||||||
|
$this->actingAs($this->tina())->get(route('member.offers'))->assertOk()
|
||||||
|
->assertSee('Im Shop')
|
||||||
|
->assertSee('class="shop-tile"', false)
|
||||||
|
->assertSee('Konflikte im Training')
|
||||||
|
->assertSee(route('shop'), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,7 +28,7 @@ public function test_all_configured_widgets_are_registered_with_complete_contrac
|
|||||||
$types = $this->registry()->all();
|
$types = $this->registry()->all();
|
||||||
|
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
['hero', 'heading', 'prose', 'image_text', 'cards', 'features', 'catalog_cards', 'topic_card', 'media_card', 'program_card', 'call_to_action', 'faq'],
|
['hero', 'heading', 'prose', 'image_text', 'cards', 'features', 'catalog_cards', 'topic_card', 'media_card', 'program_card', 'call_to_action', 'faq', 'shop_products'],
|
||||||
array_keys($types),
|
array_keys($types),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||