diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-05 21:51:15 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-05 21:51:15 +0200 |
| commit | 51d491a3d67e8c9efde8019ecb8a8e1a8195ec99 (patch) | |
| tree | 6ed5d4efa659759aefcb1c4bcbd3cc21d12a7e79 /app/models | |
| parent | 1fa2f3821497d5529a6753cee84cf5ca679e8bcc (diff) | |
Add erfa/chaostreff node-kind creation conventions
lib/ccc_conventions.rb: NODE_KINDS registry replaces the kind-specific
branches previously scattered across nodes_controller#create (tags),
unique_path-position check). Each kind declares its parent lookup
(a Proc - Update's "update"/"press_release" continue to genuinely
find-or-create their year-folder via Update.find_or_create_parent;
erfa/chaostreff use a plain find_by_unique_name!, since their parent
nodes are fixed and a missing one should fail loudly, not be silently
created), its tags, and (new) its default template.
Node gains a default_template_name column (migration, with backfill
for existing update-tree nodes via node.update? - reusing that method
rather than re-deriving its unique_path check in raw SQL). Page#set_template
now inherits from node.default_template_name, falling back to the old
update?-based check only when the column is blank, and only fills in
template_name when nothing's already been explicitly chosen - a
deliberate change from the previous behavior, which unconditionally
overwrote template_name on every save regardless of manual selection.
Node#update? itself is unchanged and still used as-is by
admin_controller's sitemap filtering - a genuinely different, still
valid use of that check.
"generic" stays special-cased in the controller, parametrized by
params[:parent_id] at request time - doesn't fit "kind implies a fixed
lookup" and isn't in the registry.
nodes#new's four hardcoded radio buttons and nodes_controller's
kind-specific case/when branches are both replaced by iterating/looking
up this one registry - adding a new kind now means one new hash entry,
not four scattered edits.
Diffstat (limited to 'app/models')
| -rw-r--r-- | app/models/page.rb | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/app/models/page.rb b/app/models/page.rb index c982c2e..20461bf 100644 --- a/app/models/page.rb +++ b/app/models/page.rb | |||
| @@ -225,9 +225,8 @@ class Page < ApplicationRecord | |||
| 225 | end | 225 | end |
| 226 | 226 | ||
| 227 | def set_template | 227 | def set_template |
| 228 | if node && node.update? | 228 | return if template_name.present? |
| 229 | self.template_name = "update" | 229 | self.template_name = node&.default_template_name || (node&.update? ? "update" : nil) |
| 230 | end | ||
| 231 | end | 230 | end |
| 232 | 231 | ||
| 233 | def rewrite_links_in_body | 232 | def rewrite_links_in_body |
