From 529f81b28ed77c62acaa63fad957e751798f2440 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Fri, 31 Jul 2026 22:36:17 +0200 Subject: Warn before the gate refuses, and check restore destinations nodes#new marks the kinds that place under /updates, derived from each kind's own path_prefix. The three parent pickers mark candidates the current user cannot publish into; menu_search returns needs_redaktion per result, computed per user rather than as a bare restricted flag, and the menu-item picker opts out. restore_from_trash! checks its destination: the restore is the move, applied rather than staged, so no later publish would have caught it. The node returns as a draft either way. --- app/controllers/admin_controller.rb | 4 +++- app/models/node.rb | 3 +++ app/views/layouts/admin.html.erb | 2 +- app/views/nodes/new.html.erb | 6 +++++- 4 files changed, 12 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 3b8b3582..c23cec04 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -67,7 +67,9 @@ class AdminController < ApplicationController format.js do render( :json => @results.map do |node| - {:node_id => node.id, :title => node.title, :unique_name => node.unique_name, :node_path => node_path(node)} + { :node_id => node.id, :title => node.title, + :unique_name => node.unique_name, :node_path => node_path(node), + :needs_redaktion => !current_user.may_change_live?(node) } end ) diff --git a/app/models/node.rb b/app/models/node.rb index 188b6c17..d6fe32ff 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -375,6 +375,9 @@ class Node < ApplicationRecord raise ActiveRecord::RecordInvalid.new(self) end + guard_live_change!(current_user, + :target_path => [new_parent.unique_name.presence, slug].compact.join("/")) + ActiveRecord::Base.transaction do path_before = unique_name move_to_child_of(new_parent) diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index 97117710..43f09b96 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -18,7 +18,7 @@ <%= javascript_tag nonce: true do %> var ADMIN_SEARCH_URL = "<%= admin_search_path %>"; var ADMIN_MENU_SEARCH_URL = "<%= admin_menu_search_path %>"; - var ADMIN_STRINGS = <%= raw({ :lock_lost_prefix => t(".lock_lost_prefix"), :lock_lost_link => t(".lock_lost_link"), :insert_image => t(".insert_image"), :insert_image_tooltip => t(".insert_image_tooltip"), :copied => t(".copied") }.to_json) %>; + var ADMIN_STRINGS = <%= raw({ :lock_lost_prefix => t(".lock_lost_prefix"), :lock_lost_link => t(".lock_lost_link"), :insert_image => t(".insert_image"), :insert_image_tooltip => t(".insert_image_tooltip"), :copied => t(".copied"), :needs_redaktion => t(".needs_redaktion") }.to_json) %>; var PARAMETERIZE_PREVIEW_URL = "<%= parameterize_preview_nodes_path %>"; var DASHBOARD_SEARCH_URL = "<%= admin_dashboard_search_path %>"; <% end %> diff --git a/app/views/nodes/new.html.erb b/app/views/nodes/new.html.erb index b56bbeed..883909a6 100644 --- a/app/views/nodes/new.html.erb +++ b/app/views/nodes/new.html.erb @@ -12,13 +12,17 @@
<%= t(".type") %>
<% CccConventions::NODE_KINDS.each do |kind, config| %> + <% prefix = resolve_kind_text(config[:path_prefix]) %>

<%= radio_button_tag :kind, kind, kind == @selected_kind, - data: { path_prefix: resolve_kind_text(config[:path_prefix]) } %> + data: { path_prefix: prefix } %> <%= resolve_kind_text(config[:label]) %> <% if config[:hint] %> <%= resolve_kind_text(config[:hint]) %> <% end %> + <% unless current_user.may_change_live_at?(prefix) %> + <%= t(".restricted_kind") %> + <% end %>

<% end %>
-- cgit v1.3