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
View File
@@ -55,6 +55,17 @@ defmodule Chesstrainer.Accounts.User do
|> validate_required([:role])
end
@doc """
A user changeset for changing the plan.
The plan is programmatic and must never be cast from user-supplied params.
"""
def plan_changeset(user, attrs) do
user
|> cast(attrs, [:plan])
|> validate_required([:plan])
end
@doc """
A user changeset for an admin-created invitation.