summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/nodes_controller.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb
index 87d2681..ce8f053 100644
--- a/app/controllers/nodes_controller.rb
+++ b/app/controllers/nodes_controller.rb
@@ -30,6 +30,7 @@ class NodesController < ApplicationController
30 @node = Node.new node_params 30 @node = Node.new node_params
31 @selected_kind = CccConventions::NODE_KINDS.key?(params[:kind]) ? params[:kind] : "generic" 31 @selected_kind = CccConventions::NODE_KINDS.key?(params[:kind]) ? params[:kind] : "generic"
32 @parent = Node.find(params[:parent_id]) if params.has_key?(:parent_id) 32 @parent = Node.find(params[:parent_id]) if params.has_key?(:parent_id)
33 @attach_asset = Asset.find(params[:asset_id]) if params.has_key?(:asset_id)
33 end 34 end
34 35
35 def create 36 def create
@@ -51,10 +52,19 @@ class NodesController < ApplicationController
51 :action => "create", 52 :action => "create",
52 :title => params[:title], :path => @node.unique_name) 53 :title => params[:title], :path => @node.unique_name)
53 54
55 if params[:asset_id].present? && (asset = Asset.find(params[:asset_id]))
56 result = @node.attach_asset!(asset, :user => current_user,
57 :headline => params[:asset_headline].present?)
58 flash[:notice] = "Page created with “#{asset.name}” attached."
59 flash[:notice] += " It is the page's headline." if result[:headline] == :set
60 flash[:error] = "This asset type cannot be a headline." if result[:headline] == :not_eligible
61 end
62
54 redirect_to(edit_node_path(@node)) 63 redirect_to(edit_node_path(@node))
55 else 64 else
56 @selected_kind = CccConventions::NODE_KINDS.key?(params[:kind]) ? params[:kind] : "generic" 65 @selected_kind = CccConventions::NODE_KINDS.key?(params[:kind]) ? params[:kind] : "generic"
57 @parent = Node.find(params[:parent_id]) if params.has_key?(:parent_id) 66 @parent = Node.find(params[:parent_id]) if params.has_key?(:parent_id)
67 @attach_asset = Asset.find(params[:asset_id]) if params.has_key?(:asset_id)
58 render :new 68 render :new
59 end 69 end
60 end 70 end