diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-08-09 03:33:55 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-08-09 03:33:55 +0200 |
| commit | 20c735b0c5a2db9b8984848253ad99332d6211a8 (patch) | |
| tree | a4ae71c53c403c1a7740db624e43fd3163e37ab7 /app/controllers/assets_controller.rb | |
| parent | 5203b80f47786b8adc169e80d89cd69159c44b62 (diff) | |
Attach assets to the draft instead of to every lifecycle row
Node#attach_asset! writes to the node's draft alone, creating one from the
head when none is pending. It refuses when another user holds the lock, and
when an autosave already exists
The asset_attach verb goes with it. create_new_draft names the editor on the
draft it creates and the publish entry's asset delta reports the attachment.
Diffstat (limited to 'app/controllers/assets_controller.rb')
| -rw-r--r-- | app/controllers/assets_controller.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb index f8a7d1e4..d86370f4 100644 --- a/app/controllers/assets_controller.rb +++ b/app/controllers/assets_controller.rb | |||
| @@ -111,8 +111,10 @@ class AssetsController < ApplicationController | |||
| 111 | flash[:notice] = | 111 | flash[:notice] = |
| 112 | if result[:attached].zero? | 112 | if result[:attached].zero? |
| 113 | t("flash.assets.already_attached", :title => node.title) | 113 | t("flash.assets.already_attached", :title => node.title) |
| 114 | elsif result[:draft_created] | ||
| 115 | t("flash.assets.attached_new_draft", :title => node.title) | ||
| 114 | else | 116 | else |
| 115 | t("flash.assets.attached", :title => node.title) | 117 | t("flash.assets.attached_to_draft", :title => node.title) |
| 116 | end | 118 | end |
| 117 | case result[:headline] | 119 | case result[:headline] |
| 118 | when :set then flash[:notice] += " " + t("flash.common.now_headline") | 120 | when :set then flash[:notice] += " " + t("flash.common.now_headline") |
| @@ -122,5 +124,8 @@ class AssetsController < ApplicationController | |||
| 122 | rescue LockedByAnotherUser | 124 | rescue LockedByAnotherUser |
| 123 | flash[:locked_by] = node.lock_owner&.login | 125 | flash[:locked_by] = node.lock_owner&.login |
| 124 | flash[:locked_node_path] = node_path(node) | 126 | flash[:locked_node_path] = node_path(node) |
| 127 | rescue ActiveRecord::RecordInvalid => e | ||
| 128 | flash[:error] = e.record.errors.full_messages.to_sentence | ||
| 129 | flash[:resolve_node_path] = node_path(node) | ||
| 125 | end | 130 | end |
| 126 | end | 131 | end |
