comparison app/controllers/news_controller.rb @ 1295:622f24f53b42 redmine-2.3

Update to Redmine SVN revision 11972 on 2.3-stable branch
author Chris Cannam
date Fri, 14 Jun 2013 09:02:21 +0100
parents 433d4f72a19b
children e248c7af89ec
comparison
equal deleted inserted replaced
1294:3e4c3460b6ca 1295:622f24f53b42
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang 2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 # 3 #
4 # This program is free software; you can redistribute it and/or 4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 7 # of the License, or (at your option) any later version.
38 end 38 end
39 39
40 scope = @project ? @project.news.visible : News.visible 40 scope = @project ? @project.news.visible : News.visible
41 41
42 @news_count = scope.count 42 @news_count = scope.count
43 @news_pages = Paginator.new self, @news_count, @limit, params['page'] 43 @news_pages = Paginator.new @news_count, @limit, params['page']
44 @offset ||= @news_pages.current.offset 44 @offset ||= @news_pages.offset
45 @newss = scope.all(:include => [:author, :project], 45 @newss = scope.all(:include => [:author, :project],
46 :order => "#{News.table_name}.created_on DESC", 46 :order => "#{News.table_name}.created_on DESC",
47 :offset => @offset, 47 :offset => @offset,
48 :limit => @limit) 48 :limit => @limit)
49 49
71 @news.safe_attributes = params[:news] 71 @news.safe_attributes = params[:news]
72 @news.save_attachments(params[:attachments]) 72 @news.save_attachments(params[:attachments])
73 if @news.save 73 if @news.save
74 render_attachment_warning_if_needed(@news) 74 render_attachment_warning_if_needed(@news)
75 flash[:notice] = l(:notice_successful_create) 75 flash[:notice] = l(:notice_successful_create)
76 redirect_to :controller => 'news', :action => 'index', :project_id => @project 76 redirect_to project_news_index_path(@project)
77 else 77 else
78 render :action => 'new' 78 render :action => 'new'
79 end 79 end
80 end 80 end
81 81
86 @news.safe_attributes = params[:news] 86 @news.safe_attributes = params[:news]
87 @news.save_attachments(params[:attachments]) 87 @news.save_attachments(params[:attachments])
88 if @news.save 88 if @news.save
89 render_attachment_warning_if_needed(@news) 89 render_attachment_warning_if_needed(@news)
90 flash[:notice] = l(:notice_successful_update) 90 flash[:notice] = l(:notice_successful_update)
91 redirect_to :action => 'show', :id => @news 91 redirect_to news_path(@news)
92 else 92 else
93 render :action => 'edit' 93 render :action => 'edit'
94 end 94 end
95 end 95 end
96 96
97 def destroy 97 def destroy
98 @news.destroy 98 @news.destroy
99 redirect_to :action => 'index', :project_id => @project 99 redirect_to project_news_index_path(@project)
100 end 100 end
101 101
102 private 102 private
103 103
104 def find_optional_project 104 def find_optional_project