Add theme slugs, kinds and link provenance (#192)

* add function for upgrading a user's plan in interactive Elixir

* Add theme slugs, kinds and link provenance

Themes gain a stable slug, an optional description and a kind so the app can
tell material, motif and technique labels apart. Slugs are generated from the
name on first save and keep their value when the theme is renamed, so links to
a theme stay valid.

Endgame-to-theme links now record their source (derived, curated or community)
and creation time. Existing links are backfilled as curated. A derived pass can
therefore replace only its own links, leaving human work untouched.

The admin index shows each theme's kind and its coverage across the library.
Creating a theme name requires the manage_themes capability, and members get an
unauthorized error instead, ahead of the suggestion flow.

Closes #185
This commit is contained in:
2026-11-17 20:46:43 +01:00
committed by GitHub
parent 7209923de7
commit 80cb033077
12 changed files with 545 additions and 27 deletions
@@ -11,8 +11,8 @@ defmodule ChesstrainerWeb.Admin.ThemeLive.IndexTest do
setup :register_and_log_in_admin
test "lists themes with their usage count", %{conn: conn} do
used_theme = theme_fixture(%{name: "Lucena"})
test "lists themes with their kind and coverage", %{conn: conn} do
used_theme = theme_fixture(%{name: "Lucena", kind: :technique})
unused_theme = theme_fixture(%{name: "Philidor"})
endgame = endgame_fixture()
{:ok, _} = Endgames.update_endgame(endgame, %{}, [used_theme])
@@ -20,8 +20,9 @@ defmodule ChesstrainerWeb.Admin.ThemeLive.IndexTest do
{:ok, view, _html} = live(conn, ~p"/admin/themes")
assert has_element?(view, "#theme-#{used_theme.id}")
assert has_element?(view, "#theme-usage-#{used_theme.id}", "1 endgame")
assert has_element?(view, "#theme-usage-#{unused_theme.id}", "0 endgames")
assert has_element?(view, "#theme-#{used_theme.id}", "technique")
assert has_element?(view, "#theme-usage-#{used_theme.id}", "1 of 1 endgame")
assert has_element?(view, "#theme-usage-#{unused_theme.id}", "0 of 1 endgame")
end
test "filters by name and category", %{conn: conn} do
@@ -57,7 +58,7 @@ defmodule ChesstrainerWeb.Admin.ThemeLive.IndexTest do
{:ok, view, html} = live(conn, ~p"/admin/themes")
assert html =~ "Used by 1 endgame"
assert html =~ "Used by 1 of 1 endgame"
assert html =~ "The endgames will be kept"
view |> element("#theme-#{theme.id} a", "Delete") |> render_click()