diff options
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/admin_controller.rb | 18 | ||||
| -rw-r--r-- | app/controllers/nodes_controller.rb | 15 |
2 files changed, 30 insertions, 3 deletions
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 7c1375a..f3cc221 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb | |||
| @@ -6,12 +6,15 @@ class AdminController < ApplicationController | |||
| 6 | 6 | ||
| 7 | def index | 7 | def index |
| 8 | @drafts = Node.all( | 8 | @drafts = Node.all( |
| 9 | :limit => 20, | 9 | :limit => 50, |
| 10 | :order => "updated_at desc", | 10 | :order => "updated_at desc", |
| 11 | :conditions => ["draft_id IS NOT NULL"] | 11 | :conditions => ["draft_id IS NOT NULL"] |
| 12 | ) | 12 | ) |
| 13 | @drafts_count = Node.count( | ||
| 14 | :conditions => ["draft_id IS NOT NULL"] | ||
| 15 | ) | ||
| 13 | @recent_changes = Node.all( | 16 | @recent_changes = Node.all( |
| 14 | :limit => 20, | 17 | :limit => 50, |
| 15 | :order => "updated_at desc", | 18 | :order => "updated_at desc", |
| 16 | :conditions => [ | 19 | :conditions => [ |
| 17 | "updated_at < ? AND updated_at > ? AND parent_id IS NOT NULL", Time.now, Time.now-14.days | 20 | "updated_at < ? AND updated_at > ? AND parent_id IS NOT NULL", Time.now, Time.now-14.days |
| @@ -24,6 +27,17 @@ class AdminController < ApplicationController | |||
| 24 | @sitemap_depth[node.id] = level | 27 | @sitemap_depth[node.id] = level |
| 25 | end | 28 | end |
| 26 | @sitemap = all_nodes.to_a.sort! { |node1,node2| node1.lft <=> node2.lft }.delete_if { |node| node.update? } | 29 | @sitemap = all_nodes.to_a.sort! { |node1,node2| node1.lft <=> node2.lft }.delete_if { |node| node.update? } |
| 30 | |||
| 31 | @mypages = Page.all( | ||
| 32 | :conditions => [ "user_id = ? or editor_id = ?", @current_user, @current_user] | ||
| 33 | ) | ||
| 34 | |||
| 35 | @mynodes = Node.all( | ||
| 36 | :order => "updated_at desc", | ||
| 37 | :joins => :pages, | ||
| 38 | :conditions => [ "pages.user_id = ? or pages.editor_id = ?", @current_user, @current_user ] | ||
| 39 | ).uniq.first(50) | ||
| 40 | |||
| 27 | end | 41 | end |
| 28 | 42 | ||
| 29 | def search | 43 | def search |
diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index 4f72744..b8cd644 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb | |||
| @@ -25,6 +25,10 @@ class NodesController < ApplicationController | |||
| 25 | 25 | ||
| 26 | def new | 26 | def new |
| 27 | @node = Node.new params[:node] | 27 | @node = Node.new params[:node] |
| 28 | if params.has_key?(:parent_id) | ||
| 29 | @parent_id = params[:parent_id] | ||
| 30 | @parent_name = Node.find(@parent_id).title | ||
| 31 | end | ||
| 28 | end | 32 | end |
| 29 | 33 | ||
| 30 | def create | 34 | def create |
| @@ -33,9 +37,16 @@ class NodesController < ApplicationController | |||
| 33 | @node = Node.new | 37 | @node = Node.new |
| 34 | @node.parent_id = find_parent | 38 | @node.parent_id = find_parent |
| 35 | @node.slug = params[:title].parameterize.to_s | 39 | @node.slug = params[:title].parameterize.to_s |
| 36 | 40 | ||
| 37 | if @node.save | 41 | if @node.save |
| 38 | @node.draft.update_attributes(:title => params[:title]) | 42 | @node.draft.update_attributes(:title => params[:title]) |
| 43 | case params[:kind] | ||
| 44 | when "update" | ||
| 45 | @node.draft.tag_list.add("update") | ||
| 46 | when "press_release" | ||
| 47 | @node.draft.tag_list.add("update", "pressemitteilung") | ||
| 48 | end | ||
| 49 | @node.draft.save! | ||
| 39 | redirect_to(edit_node_path(@node)) | 50 | redirect_to(edit_node_path(@node)) |
| 40 | else | 51 | else |
| 41 | render :new | 52 | render :new |
| @@ -107,6 +118,8 @@ class NodesController < ApplicationController | |||
| 107 | Node.root.id | 118 | Node.root.id |
| 108 | when "update" | 119 | when "update" |
| 109 | Update.find_or_create_parent.id | 120 | Update.find_or_create_parent.id |
| 121 | when "press_release" | ||
| 122 | Update.find_or_create_parent.id | ||
| 110 | when "generic" | 123 | when "generic" |
| 111 | if params[:parent_id] && Node.find(params[:parent_id]) | 124 | if params[:parent_id] && Node.find(params[:parent_id]) |
| 112 | params[:parent_id] | 125 | params[:parent_id] |
