@@ -0,0 +1,14 | |||||
|
1 | <h2><%=l(:label_news_new)%></h2> | |||
|
2 | ||||
|
3 | <% labelled_tabular_form_for :news, @news, :url => { :controller => 'news', :action => 'new', :project_id => @project }, | |||
|
4 | :html => { :id => 'news-form' } do |f| %> | |||
|
5 | <%= render :partial => 'news/form', :locals => { :f => f } %> | |||
|
6 | <%= submit_tag l(:button_create) %> | |||
|
7 | <%= link_to_remote l(:label_preview), | |||
|
8 | { :url => { :controller => 'news', :action => 'preview' }, | |||
|
9 | :method => 'post', | |||
|
10 | :update => 'preview', | |||
|
11 | :with => "Form.serialize('news-form')" | |||
|
12 | }, :accesskey => accesskey(:preview) %> | |||
|
13 | <% end %> | |||
|
14 | <div id="preview" class="wiki"></div> |
@@ -1,82 +1,107 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006 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. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | class NewsController < ApplicationController |
|
18 | class NewsController < ApplicationController | |
19 | layout 'base' |
|
19 | layout 'base' | |
20 |
before_filter :find_ |
|
20 | before_filter :find_news, :except => [:new, :index, :preview] | |
|
21 | before_filter :find_project, :only => :new | |||
|
22 | before_filter :authorize, :except => [:index, :preview] | |||
21 | before_filter :find_optional_project, :only => :index |
|
23 | before_filter :find_optional_project, :only => :index | |
22 | accept_key_auth :index |
|
24 | accept_key_auth :index | |
23 |
|
25 | |||
24 | def index |
|
26 | def index | |
25 | @news_pages, @newss = paginate :news, |
|
27 | @news_pages, @newss = paginate :news, | |
26 | :per_page => 10, |
|
28 | :per_page => 10, | |
27 | :conditions => (@project ? {:project_id => @project.id} : Project.visible_by(User.current)), |
|
29 | :conditions => (@project ? {:project_id => @project.id} : Project.visible_by(User.current)), | |
28 | :include => [:author, :project], |
|
30 | :include => [:author, :project], | |
29 | :order => "#{News.table_name}.created_on DESC" |
|
31 | :order => "#{News.table_name}.created_on DESC" | |
30 | respond_to do |format| |
|
32 | respond_to do |format| | |
31 | format.html { render :layout => false if request.xhr? } |
|
33 | format.html { render :layout => false if request.xhr? } | |
32 | format.atom { render_feed(@newss, :title => (@project ? @project.name : Setting.app_title) + ": #{l(:label_news_plural)}") } |
|
34 | format.atom { render_feed(@newss, :title => (@project ? @project.name : Setting.app_title) + ": #{l(:label_news_plural)}") } | |
33 | end |
|
35 | end | |
34 | end |
|
36 | end | |
35 |
|
37 | |||
36 | def show |
|
38 | def show | |
37 | end |
|
39 | end | |
38 |
|
40 | |||
|
41 | def new | |||
|
42 | @news = News.new(:project => @project, :author => User.current) | |||
|
43 | if request.post? | |||
|
44 | @news.attributes = params[:news] | |||
|
45 | if @news.save | |||
|
46 | flash[:notice] = l(:notice_successful_create) | |||
|
47 | Mailer.deliver_news_added(@news) if Setting.notified_events.include?('news_added') | |||
|
48 | redirect_to :controller => 'news', :action => 'index', :project_id => @project | |||
|
49 | end | |||
|
50 | end | |||
|
51 | end | |||
|
52 | ||||
39 | def edit |
|
53 | def edit | |
40 | if request.post? and @news.update_attributes(params[:news]) |
|
54 | if request.post? and @news.update_attributes(params[:news]) | |
41 | flash[:notice] = l(:notice_successful_update) |
|
55 | flash[:notice] = l(:notice_successful_update) | |
42 | redirect_to :action => 'show', :id => @news |
|
56 | redirect_to :action => 'show', :id => @news | |
43 | end |
|
57 | end | |
44 | end |
|
58 | end | |
45 |
|
59 | |||
46 | def add_comment |
|
60 | def add_comment | |
47 | @comment = Comment.new(params[:comment]) |
|
61 | @comment = Comment.new(params[:comment]) | |
48 | @comment.author = User.current |
|
62 | @comment.author = User.current | |
49 | if @news.comments << @comment |
|
63 | if @news.comments << @comment | |
50 | flash[:notice] = l(:label_comment_added) |
|
64 | flash[:notice] = l(:label_comment_added) | |
51 | redirect_to :action => 'show', :id => @news |
|
65 | redirect_to :action => 'show', :id => @news | |
52 | else |
|
66 | else | |
53 | render :action => 'show' |
|
67 | render :action => 'show' | |
54 | end |
|
68 | end | |
55 | end |
|
69 | end | |
56 |
|
70 | |||
57 | def destroy_comment |
|
71 | def destroy_comment | |
58 | @news.comments.find(params[:comment_id]).destroy |
|
72 | @news.comments.find(params[:comment_id]).destroy | |
59 | redirect_to :action => 'show', :id => @news |
|
73 | redirect_to :action => 'show', :id => @news | |
60 | end |
|
74 | end | |
61 |
|
75 | |||
62 | def destroy |
|
76 | def destroy | |
63 | @news.destroy |
|
77 | @news.destroy | |
64 | redirect_to :action => 'index', :project_id => @project |
|
78 | redirect_to :action => 'index', :project_id => @project | |
65 | end |
|
79 | end | |
66 |
|
80 | |||
|
81 | def preview | |||
|
82 | @text = (params[:news] ? params[:news][:description] : nil) | |||
|
83 | render :partial => 'common/preview' | |||
|
84 | end | |||
|
85 | ||||
67 | private |
|
86 | private | |
68 |
def find_ |
|
87 | def find_news | |
69 | @news = News.find(params[:id]) |
|
88 | @news = News.find(params[:id]) | |
70 | @project = @news.project |
|
89 | @project = @news.project | |
71 | rescue ActiveRecord::RecordNotFound |
|
90 | rescue ActiveRecord::RecordNotFound | |
72 | render_404 |
|
91 | render_404 | |
73 | end |
|
92 | end | |
74 |
|
93 | |||
|
94 | def find_project | |||
|
95 | @project = Project.find(params[:project_id]) | |||
|
96 | rescue ActiveRecord::RecordNotFound | |||
|
97 | render_404 | |||
|
98 | end | |||
|
99 | ||||
75 | def find_optional_project |
|
100 | def find_optional_project | |
76 | return true unless params[:project_id] |
|
101 | return true unless params[:project_id] | |
77 | @project = Project.find(params[:project_id]) |
|
102 | @project = Project.find(params[:project_id]) | |
78 | authorize |
|
103 | authorize | |
79 | rescue ActiveRecord::RecordNotFound |
|
104 | rescue ActiveRecord::RecordNotFound | |
80 | render_404 |
|
105 | render_404 | |
81 | end |
|
106 | end | |
82 | end |
|
107 | end |
@@ -1,484 +1,471 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2007 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. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | class ProjectsController < ApplicationController |
|
18 | class ProjectsController < ApplicationController | |
19 | layout 'base' |
|
19 | layout 'base' | |
20 | menu_item :overview |
|
20 | menu_item :overview | |
21 | menu_item :activity, :only => :activity |
|
21 | menu_item :activity, :only => :activity | |
22 | menu_item :roadmap, :only => :roadmap |
|
22 | menu_item :roadmap, :only => :roadmap | |
23 | menu_item :files, :only => [:list_files, :add_file] |
|
23 | menu_item :files, :only => [:list_files, :add_file] | |
24 | menu_item :settings, :only => :settings |
|
24 | menu_item :settings, :only => :settings | |
25 | menu_item :issues, :only => [:bulk_edit_issues, :changelog, :move_issues] |
|
25 | menu_item :issues, :only => [:bulk_edit_issues, :changelog, :move_issues] | |
26 |
|
26 | |||
27 | before_filter :find_project, :except => [ :index, :list, :add ] |
|
27 | before_filter :find_project, :except => [ :index, :list, :add ] | |
28 | before_filter :authorize, :except => [ :index, :list, :add, :archive, :unarchive, :destroy ] |
|
28 | before_filter :authorize, :except => [ :index, :list, :add, :archive, :unarchive, :destroy ] | |
29 | before_filter :require_admin, :only => [ :add, :archive, :unarchive, :destroy ] |
|
29 | before_filter :require_admin, :only => [ :add, :archive, :unarchive, :destroy ] | |
30 | accept_key_auth :activity, :calendar |
|
30 | accept_key_auth :activity, :calendar | |
31 |
|
31 | |||
32 | cache_sweeper :project_sweeper, :only => [ :add, :edit, :archive, :unarchive, :destroy ] |
|
32 | cache_sweeper :project_sweeper, :only => [ :add, :edit, :archive, :unarchive, :destroy ] | |
33 | cache_sweeper :version_sweeper, :only => [ :add_version ] |
|
33 | cache_sweeper :version_sweeper, :only => [ :add_version ] | |
34 |
|
34 | |||
35 | helper :sort |
|
35 | helper :sort | |
36 | include SortHelper |
|
36 | include SortHelper | |
37 | helper :custom_fields |
|
37 | helper :custom_fields | |
38 | include CustomFieldsHelper |
|
38 | include CustomFieldsHelper | |
39 | helper :ifpdf |
|
39 | helper :ifpdf | |
40 | include IfpdfHelper |
|
40 | include IfpdfHelper | |
41 | helper :issues |
|
41 | helper :issues | |
42 | helper IssuesHelper |
|
42 | helper IssuesHelper | |
43 | helper :queries |
|
43 | helper :queries | |
44 | include QueriesHelper |
|
44 | include QueriesHelper | |
45 | helper :repositories |
|
45 | helper :repositories | |
46 | include RepositoriesHelper |
|
46 | include RepositoriesHelper | |
47 | include ProjectsHelper |
|
47 | include ProjectsHelper | |
48 |
|
48 | |||
49 | def index |
|
49 | def index | |
50 | list |
|
50 | list | |
51 | render :action => 'list' unless request.xhr? |
|
51 | render :action => 'list' unless request.xhr? | |
52 | end |
|
52 | end | |
53 |
|
53 | |||
54 | # Lists visible projects |
|
54 | # Lists visible projects | |
55 | def list |
|
55 | def list | |
56 | projects = Project.find :all, |
|
56 | projects = Project.find :all, | |
57 | :conditions => Project.visible_by(User.current), |
|
57 | :conditions => Project.visible_by(User.current), | |
58 | :include => :parent |
|
58 | :include => :parent | |
59 | @project_tree = projects.group_by {|p| p.parent || p} |
|
59 | @project_tree = projects.group_by {|p| p.parent || p} | |
60 | @project_tree.each_key {|p| @project_tree[p] -= [p]} |
|
60 | @project_tree.each_key {|p| @project_tree[p] -= [p]} | |
61 | end |
|
61 | end | |
62 |
|
62 | |||
63 | # Add a new project |
|
63 | # Add a new project | |
64 | def add |
|
64 | def add | |
65 | @custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position") |
|
65 | @custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position") | |
66 | @trackers = Tracker.all |
|
66 | @trackers = Tracker.all | |
67 | @root_projects = Project.find(:all, |
|
67 | @root_projects = Project.find(:all, | |
68 | :conditions => "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}", |
|
68 | :conditions => "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}", | |
69 | :order => 'name') |
|
69 | :order => 'name') | |
70 | @project = Project.new(params[:project]) |
|
70 | @project = Project.new(params[:project]) | |
71 | @project.enabled_module_names = Redmine::AccessControl.available_project_modules |
|
71 | @project.enabled_module_names = Redmine::AccessControl.available_project_modules | |
72 | if request.get? |
|
72 | if request.get? | |
73 | @custom_values = ProjectCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| CustomValue.new(:custom_field => x, :customized => @project) } |
|
73 | @custom_values = ProjectCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| CustomValue.new(:custom_field => x, :customized => @project) } | |
74 | @project.trackers = Tracker.all |
|
74 | @project.trackers = Tracker.all | |
75 | else |
|
75 | else | |
76 | @project.custom_fields = CustomField.find(params[:custom_field_ids]) if params[:custom_field_ids] |
|
76 | @project.custom_fields = CustomField.find(params[:custom_field_ids]) if params[:custom_field_ids] | |
77 | @custom_values = ProjectCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => (params[:custom_fields] ? params["custom_fields"][x.id.to_s] : nil)) } |
|
77 | @custom_values = ProjectCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => (params[:custom_fields] ? params["custom_fields"][x.id.to_s] : nil)) } | |
78 | @project.custom_values = @custom_values |
|
78 | @project.custom_values = @custom_values | |
79 | if @project.save |
|
79 | if @project.save | |
80 | @project.enabled_module_names = params[:enabled_modules] |
|
80 | @project.enabled_module_names = params[:enabled_modules] | |
81 | flash[:notice] = l(:notice_successful_create) |
|
81 | flash[:notice] = l(:notice_successful_create) | |
82 | redirect_to :controller => 'admin', :action => 'projects' |
|
82 | redirect_to :controller => 'admin', :action => 'projects' | |
83 | end |
|
83 | end | |
84 | end |
|
84 | end | |
85 | end |
|
85 | end | |
86 |
|
86 | |||
87 | # Show @project |
|
87 | # Show @project | |
88 | def show |
|
88 | def show | |
89 | @custom_values = @project.custom_values.find(:all, :include => :custom_field, :order => "#{CustomField.table_name}.position") |
|
89 | @custom_values = @project.custom_values.find(:all, :include => :custom_field, :order => "#{CustomField.table_name}.position") | |
90 | @members_by_role = @project.members.find(:all, :include => [:user, :role], :order => 'position').group_by {|m| m.role} |
|
90 | @members_by_role = @project.members.find(:all, :include => [:user, :role], :order => 'position').group_by {|m| m.role} | |
91 | @subprojects = @project.active_children |
|
91 | @subprojects = @project.active_children | |
92 | @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC") |
|
92 | @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC") | |
93 | @trackers = @project.trackers |
|
93 | @trackers = @project.trackers | |
94 | @open_issues_by_tracker = Issue.count(:group => :tracker, :joins => "INNER JOIN #{IssueStatus.table_name} ON #{IssueStatus.table_name}.id = #{Issue.table_name}.status_id", :conditions => ["project_id=? and #{IssueStatus.table_name}.is_closed=?", @project.id, false]) |
|
94 | @open_issues_by_tracker = Issue.count(:group => :tracker, :joins => "INNER JOIN #{IssueStatus.table_name} ON #{IssueStatus.table_name}.id = #{Issue.table_name}.status_id", :conditions => ["project_id=? and #{IssueStatus.table_name}.is_closed=?", @project.id, false]) | |
95 | @total_issues_by_tracker = Issue.count(:group => :tracker, :conditions => ["project_id=?", @project.id]) |
|
95 | @total_issues_by_tracker = Issue.count(:group => :tracker, :conditions => ["project_id=?", @project.id]) | |
96 | @total_hours = @project.time_entries.sum(:hours) |
|
96 | @total_hours = @project.time_entries.sum(:hours) | |
97 | @key = User.current.rss_key |
|
97 | @key = User.current.rss_key | |
98 | end |
|
98 | end | |
99 |
|
99 | |||
100 | def settings |
|
100 | def settings | |
101 | @root_projects = Project.find(:all, |
|
101 | @root_projects = Project.find(:all, | |
102 | :conditions => ["parent_id IS NULL AND status = #{Project::STATUS_ACTIVE} AND id <> ?", @project.id], |
|
102 | :conditions => ["parent_id IS NULL AND status = #{Project::STATUS_ACTIVE} AND id <> ?", @project.id], | |
103 | :order => 'name') |
|
103 | :order => 'name') | |
104 | @custom_fields = IssueCustomField.find(:all) |
|
104 | @custom_fields = IssueCustomField.find(:all) | |
105 | @issue_category ||= IssueCategory.new |
|
105 | @issue_category ||= IssueCategory.new | |
106 | @member ||= @project.members.new |
|
106 | @member ||= @project.members.new | |
107 | @trackers = Tracker.all |
|
107 | @trackers = Tracker.all | |
108 | @custom_values ||= ProjectCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) } |
|
108 | @custom_values ||= ProjectCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) } | |
109 | @repository ||= @project.repository |
|
109 | @repository ||= @project.repository | |
110 | @wiki ||= @project.wiki |
|
110 | @wiki ||= @project.wiki | |
111 | end |
|
111 | end | |
112 |
|
112 | |||
113 | # Edit @project |
|
113 | # Edit @project | |
114 | def edit |
|
114 | def edit | |
115 | if request.post? |
|
115 | if request.post? | |
116 | if params[:custom_fields] |
|
116 | if params[:custom_fields] | |
117 | @custom_values = ProjectCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) } |
|
117 | @custom_values = ProjectCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) } | |
118 | @project.custom_values = @custom_values |
|
118 | @project.custom_values = @custom_values | |
119 | end |
|
119 | end | |
120 | @project.attributes = params[:project] |
|
120 | @project.attributes = params[:project] | |
121 | if @project.save |
|
121 | if @project.save | |
122 | flash[:notice] = l(:notice_successful_update) |
|
122 | flash[:notice] = l(:notice_successful_update) | |
123 | redirect_to :action => 'settings', :id => @project |
|
123 | redirect_to :action => 'settings', :id => @project | |
124 | else |
|
124 | else | |
125 | settings |
|
125 | settings | |
126 | render :action => 'settings' |
|
126 | render :action => 'settings' | |
127 | end |
|
127 | end | |
128 | end |
|
128 | end | |
129 | end |
|
129 | end | |
130 |
|
130 | |||
131 | def modules |
|
131 | def modules | |
132 | @project.enabled_module_names = params[:enabled_modules] |
|
132 | @project.enabled_module_names = params[:enabled_modules] | |
133 | redirect_to :action => 'settings', :id => @project, :tab => 'modules' |
|
133 | redirect_to :action => 'settings', :id => @project, :tab => 'modules' | |
134 | end |
|
134 | end | |
135 |
|
135 | |||
136 | def archive |
|
136 | def archive | |
137 | @project.archive if request.post? && @project.active? |
|
137 | @project.archive if request.post? && @project.active? | |
138 | redirect_to :controller => 'admin', :action => 'projects' |
|
138 | redirect_to :controller => 'admin', :action => 'projects' | |
139 | end |
|
139 | end | |
140 |
|
140 | |||
141 | def unarchive |
|
141 | def unarchive | |
142 | @project.unarchive if request.post? && !@project.active? |
|
142 | @project.unarchive if request.post? && !@project.active? | |
143 | redirect_to :controller => 'admin', :action => 'projects' |
|
143 | redirect_to :controller => 'admin', :action => 'projects' | |
144 | end |
|
144 | end | |
145 |
|
145 | |||
146 | # Delete @project |
|
146 | # Delete @project | |
147 | def destroy |
|
147 | def destroy | |
148 | @project_to_destroy = @project |
|
148 | @project_to_destroy = @project | |
149 | if request.post? and params[:confirm] |
|
149 | if request.post? and params[:confirm] | |
150 | @project_to_destroy.destroy |
|
150 | @project_to_destroy.destroy | |
151 | redirect_to :controller => 'admin', :action => 'projects' |
|
151 | redirect_to :controller => 'admin', :action => 'projects' | |
152 | end |
|
152 | end | |
153 | # hide project in layout |
|
153 | # hide project in layout | |
154 | @project = nil |
|
154 | @project = nil | |
155 | end |
|
155 | end | |
156 |
|
156 | |||
157 | # Add a new issue category to @project |
|
157 | # Add a new issue category to @project | |
158 | def add_issue_category |
|
158 | def add_issue_category | |
159 | @category = @project.issue_categories.build(params[:category]) |
|
159 | @category = @project.issue_categories.build(params[:category]) | |
160 | if request.post? and @category.save |
|
160 | if request.post? and @category.save | |
161 | respond_to do |format| |
|
161 | respond_to do |format| | |
162 | format.html do |
|
162 | format.html do | |
163 | flash[:notice] = l(:notice_successful_create) |
|
163 | flash[:notice] = l(:notice_successful_create) | |
164 | redirect_to :action => 'settings', :tab => 'categories', :id => @project |
|
164 | redirect_to :action => 'settings', :tab => 'categories', :id => @project | |
165 | end |
|
165 | end | |
166 | format.js do |
|
166 | format.js do | |
167 | # IE doesn't support the replace_html rjs method for select box options |
|
167 | # IE doesn't support the replace_html rjs method for select box options | |
168 | render(:update) {|page| page.replace "issue_category_id", |
|
168 | render(:update) {|page| page.replace "issue_category_id", | |
169 | content_tag('select', '<option></option>' + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]') |
|
169 | content_tag('select', '<option></option>' + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]') | |
170 | } |
|
170 | } | |
171 | end |
|
171 | end | |
172 | end |
|
172 | end | |
173 | end |
|
173 | end | |
174 | end |
|
174 | end | |
175 |
|
175 | |||
176 | # Add a new version to @project |
|
176 | # Add a new version to @project | |
177 | def add_version |
|
177 | def add_version | |
178 | @version = @project.versions.build(params[:version]) |
|
178 | @version = @project.versions.build(params[:version]) | |
179 | if request.post? and @version.save |
|
179 | if request.post? and @version.save | |
180 | flash[:notice] = l(:notice_successful_create) |
|
180 | flash[:notice] = l(:notice_successful_create) | |
181 | redirect_to :action => 'settings', :tab => 'versions', :id => @project |
|
181 | redirect_to :action => 'settings', :tab => 'versions', :id => @project | |
182 | end |
|
182 | end | |
183 | end |
|
183 | end | |
184 |
|
184 | |||
185 | # Bulk edit issues |
|
185 | # Bulk edit issues | |
186 | def bulk_edit_issues |
|
186 | def bulk_edit_issues | |
187 | if request.post? |
|
187 | if request.post? | |
188 | status = params[:status_id].blank? ? nil : IssueStatus.find_by_id(params[:status_id]) |
|
188 | status = params[:status_id].blank? ? nil : IssueStatus.find_by_id(params[:status_id]) | |
189 | priority = params[:priority_id].blank? ? nil : Enumeration.find_by_id(params[:priority_id]) |
|
189 | priority = params[:priority_id].blank? ? nil : Enumeration.find_by_id(params[:priority_id]) | |
190 | assigned_to = params[:assigned_to_id].blank? ? nil : User.find_by_id(params[:assigned_to_id]) |
|
190 | assigned_to = params[:assigned_to_id].blank? ? nil : User.find_by_id(params[:assigned_to_id]) | |
191 | category = params[:category_id].blank? ? nil : @project.issue_categories.find_by_id(params[:category_id]) |
|
191 | category = params[:category_id].blank? ? nil : @project.issue_categories.find_by_id(params[:category_id]) | |
192 | fixed_version = params[:fixed_version_id].blank? ? nil : @project.versions.find_by_id(params[:fixed_version_id]) |
|
192 | fixed_version = params[:fixed_version_id].blank? ? nil : @project.versions.find_by_id(params[:fixed_version_id]) | |
193 | issues = @project.issues.find_all_by_id(params[:issue_ids]) |
|
193 | issues = @project.issues.find_all_by_id(params[:issue_ids]) | |
194 | unsaved_issue_ids = [] |
|
194 | unsaved_issue_ids = [] | |
195 | issues.each do |issue| |
|
195 | issues.each do |issue| | |
196 | journal = issue.init_journal(User.current, params[:notes]) |
|
196 | journal = issue.init_journal(User.current, params[:notes]) | |
197 | issue.priority = priority if priority |
|
197 | issue.priority = priority if priority | |
198 | issue.assigned_to = assigned_to if assigned_to || params[:assigned_to_id] == 'none' |
|
198 | issue.assigned_to = assigned_to if assigned_to || params[:assigned_to_id] == 'none' | |
199 | issue.category = category if category |
|
199 | issue.category = category if category | |
200 | issue.fixed_version = fixed_version if fixed_version |
|
200 | issue.fixed_version = fixed_version if fixed_version | |
201 | issue.start_date = params[:start_date] unless params[:start_date].blank? |
|
201 | issue.start_date = params[:start_date] unless params[:start_date].blank? | |
202 | issue.due_date = params[:due_date] unless params[:due_date].blank? |
|
202 | issue.due_date = params[:due_date] unless params[:due_date].blank? | |
203 | issue.done_ratio = params[:done_ratio] unless params[:done_ratio].blank? |
|
203 | issue.done_ratio = params[:done_ratio] unless params[:done_ratio].blank? | |
204 | # Don't save any change to the issue if the user is not authorized to apply the requested status |
|
204 | # Don't save any change to the issue if the user is not authorized to apply the requested status | |
205 | if (status.nil? || (issue.status.new_status_allowed_to?(status, current_role, issue.tracker) && issue.status = status)) && issue.save |
|
205 | if (status.nil? || (issue.status.new_status_allowed_to?(status, current_role, issue.tracker) && issue.status = status)) && issue.save | |
206 | # Send notification for each issue (if changed) |
|
206 | # Send notification for each issue (if changed) | |
207 | Mailer.deliver_issue_edit(journal) if journal.details.any? && Setting.notified_events.include?('issue_updated') |
|
207 | Mailer.deliver_issue_edit(journal) if journal.details.any? && Setting.notified_events.include?('issue_updated') | |
208 | else |
|
208 | else | |
209 | # Keep unsaved issue ids to display them in flash error |
|
209 | # Keep unsaved issue ids to display them in flash error | |
210 | unsaved_issue_ids << issue.id |
|
210 | unsaved_issue_ids << issue.id | |
211 | end |
|
211 | end | |
212 | end |
|
212 | end | |
213 | if unsaved_issue_ids.empty? |
|
213 | if unsaved_issue_ids.empty? | |
214 | flash[:notice] = l(:notice_successful_update) unless issues.empty? |
|
214 | flash[:notice] = l(:notice_successful_update) unless issues.empty? | |
215 | else |
|
215 | else | |
216 | flash[:error] = l(:notice_failed_to_save_issues, unsaved_issue_ids.size, issues.size, '#' + unsaved_issue_ids.join(', #')) |
|
216 | flash[:error] = l(:notice_failed_to_save_issues, unsaved_issue_ids.size, issues.size, '#' + unsaved_issue_ids.join(', #')) | |
217 | end |
|
217 | end | |
218 | redirect_to :controller => 'issues', :action => 'index', :project_id => @project |
|
218 | redirect_to :controller => 'issues', :action => 'index', :project_id => @project | |
219 | return |
|
219 | return | |
220 | end |
|
220 | end | |
221 | # Find potential statuses the user could be allowed to switch issues to |
|
221 | # Find potential statuses the user could be allowed to switch issues to | |
222 | @available_statuses = Workflow.find(:all, :include => :new_status, |
|
222 | @available_statuses = Workflow.find(:all, :include => :new_status, | |
223 | :conditions => {:role_id => current_role.id}).collect(&:new_status).compact.uniq |
|
223 | :conditions => {:role_id => current_role.id}).collect(&:new_status).compact.uniq | |
224 | render :update do |page| |
|
224 | render :update do |page| | |
225 | page.hide 'query_form' |
|
225 | page.hide 'query_form' | |
226 | page.replace_html 'bulk-edit', :partial => 'issues/bulk_edit_form' |
|
226 | page.replace_html 'bulk-edit', :partial => 'issues/bulk_edit_form' | |
227 | end |
|
227 | end | |
228 | end |
|
228 | end | |
229 |
|
229 | |||
230 | def move_issues |
|
230 | def move_issues | |
231 | @issues = @project.issues.find(params[:issue_ids]) if params[:issue_ids] |
|
231 | @issues = @project.issues.find(params[:issue_ids]) if params[:issue_ids] | |
232 | redirect_to :controller => 'issues', :action => 'index', :project_id => @project and return unless @issues |
|
232 | redirect_to :controller => 'issues', :action => 'index', :project_id => @project and return unless @issues | |
233 |
|
233 | |||
234 | @projects = [] |
|
234 | @projects = [] | |
235 | # find projects to which the user is allowed to move the issue |
|
235 | # find projects to which the user is allowed to move the issue | |
236 | if User.current.admin? |
|
236 | if User.current.admin? | |
237 | # admin is allowed to move issues to any active (visible) project |
|
237 | # admin is allowed to move issues to any active (visible) project | |
238 | @projects = Project.find(:all, :conditions => Project.visible_by(User.current), :order => 'name') |
|
238 | @projects = Project.find(:all, :conditions => Project.visible_by(User.current), :order => 'name') | |
239 | else |
|
239 | else | |
240 | User.current.memberships.each {|m| @projects << m.project if m.role.allowed_to?(:move_issues)} |
|
240 | User.current.memberships.each {|m| @projects << m.project if m.role.allowed_to?(:move_issues)} | |
241 | end |
|
241 | end | |
242 | @target_project = @projects.detect {|p| p.id.to_s == params[:new_project_id]} if params[:new_project_id] |
|
242 | @target_project = @projects.detect {|p| p.id.to_s == params[:new_project_id]} if params[:new_project_id] | |
243 | @target_project ||= @project |
|
243 | @target_project ||= @project | |
244 | @trackers = @target_project.trackers |
|
244 | @trackers = @target_project.trackers | |
245 | if request.post? |
|
245 | if request.post? | |
246 | new_tracker = params[:new_tracker_id].blank? ? nil : @target_project.trackers.find_by_id(params[:new_tracker_id]) |
|
246 | new_tracker = params[:new_tracker_id].blank? ? nil : @target_project.trackers.find_by_id(params[:new_tracker_id]) | |
247 | unsaved_issue_ids = [] |
|
247 | unsaved_issue_ids = [] | |
248 | @issues.each do |issue| |
|
248 | @issues.each do |issue| | |
249 | unsaved_issue_ids << issue.id unless issue.move_to(@target_project, new_tracker) |
|
249 | unsaved_issue_ids << issue.id unless issue.move_to(@target_project, new_tracker) | |
250 | end |
|
250 | end | |
251 | if unsaved_issue_ids.empty? |
|
251 | if unsaved_issue_ids.empty? | |
252 | flash[:notice] = l(:notice_successful_update) unless @issues.empty? |
|
252 | flash[:notice] = l(:notice_successful_update) unless @issues.empty? | |
253 | else |
|
253 | else | |
254 | flash[:error] = l(:notice_failed_to_save_issues, unsaved_issue_ids.size, @issues.size, '#' + unsaved_issue_ids.join(', #')) |
|
254 | flash[:error] = l(:notice_failed_to_save_issues, unsaved_issue_ids.size, @issues.size, '#' + unsaved_issue_ids.join(', #')) | |
255 | end |
|
255 | end | |
256 | redirect_to :controller => 'issues', :action => 'index', :project_id => @project |
|
256 | redirect_to :controller => 'issues', :action => 'index', :project_id => @project | |
257 | return |
|
257 | return | |
258 | end |
|
258 | end | |
259 | render :layout => false if request.xhr? |
|
259 | render :layout => false if request.xhr? | |
260 | end |
|
260 | end | |
261 |
|
261 | |||
262 | # Add a news to @project |
|
|||
263 | def add_news |
|
|||
264 | @news = News.new(:project => @project, :author => User.current) |
|
|||
265 | if request.post? |
|
|||
266 | @news.attributes = params[:news] |
|
|||
267 | if @news.save |
|
|||
268 | flash[:notice] = l(:notice_successful_create) |
|
|||
269 | Mailer.deliver_news_added(@news) if Setting.notified_events.include?('news_added') |
|
|||
270 | redirect_to :controller => 'news', :action => 'index', :project_id => @project |
|
|||
271 | end |
|
|||
272 | end |
|
|||
273 | end |
|
|||
274 |
|
||||
275 | def add_file |
|
262 | def add_file | |
276 | if request.post? |
|
263 | if request.post? | |
277 | @version = @project.versions.find_by_id(params[:version_id]) |
|
264 | @version = @project.versions.find_by_id(params[:version_id]) | |
278 | attachments = attach_files(@version, params[:attachments]) |
|
265 | attachments = attach_files(@version, params[:attachments]) | |
279 | Mailer.deliver_attachments_added(attachments) if !attachments.empty? && Setting.notified_events.include?('file_added') |
|
266 | Mailer.deliver_attachments_added(attachments) if !attachments.empty? && Setting.notified_events.include?('file_added') | |
280 | redirect_to :controller => 'projects', :action => 'list_files', :id => @project |
|
267 | redirect_to :controller => 'projects', :action => 'list_files', :id => @project | |
281 | end |
|
268 | end | |
282 | @versions = @project.versions.sort |
|
269 | @versions = @project.versions.sort | |
283 | end |
|
270 | end | |
284 |
|
271 | |||
285 | def list_files |
|
272 | def list_files | |
286 | @versions = @project.versions.sort |
|
273 | @versions = @project.versions.sort | |
287 | end |
|
274 | end | |
288 |
|
275 | |||
289 | # Show changelog for @project |
|
276 | # Show changelog for @project | |
290 | def changelog |
|
277 | def changelog | |
291 | @trackers = @project.trackers.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position') |
|
278 | @trackers = @project.trackers.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position') | |
292 | retrieve_selected_tracker_ids(@trackers) |
|
279 | retrieve_selected_tracker_ids(@trackers) | |
293 | @versions = @project.versions.sort |
|
280 | @versions = @project.versions.sort | |
294 | end |
|
281 | end | |
295 |
|
282 | |||
296 | def roadmap |
|
283 | def roadmap | |
297 | @trackers = @project.trackers.find(:all, :conditions => ["is_in_roadmap=?", true]) |
|
284 | @trackers = @project.trackers.find(:all, :conditions => ["is_in_roadmap=?", true]) | |
298 | retrieve_selected_tracker_ids(@trackers) |
|
285 | retrieve_selected_tracker_ids(@trackers) | |
299 | @versions = @project.versions.sort |
|
286 | @versions = @project.versions.sort | |
300 | @versions = @versions.select {|v| !v.completed? } unless params[:completed] |
|
287 | @versions = @versions.select {|v| !v.completed? } unless params[:completed] | |
301 | end |
|
288 | end | |
302 |
|
289 | |||
303 | def activity |
|
290 | def activity | |
304 | if params[:year] and params[:year].to_i > 1900 |
|
291 | if params[:year] and params[:year].to_i > 1900 | |
305 | @year = params[:year].to_i |
|
292 | @year = params[:year].to_i | |
306 | if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13 |
|
293 | if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13 | |
307 | @month = params[:month].to_i |
|
294 | @month = params[:month].to_i | |
308 | end |
|
295 | end | |
309 | end |
|
296 | end | |
310 | @year ||= Date.today.year |
|
297 | @year ||= Date.today.year | |
311 | @month ||= Date.today.month |
|
298 | @month ||= Date.today.month | |
312 |
|
299 | |||
313 | case params[:format] |
|
300 | case params[:format] | |
314 | when 'atom' |
|
301 | when 'atom' | |
315 | # 30 last days |
|
302 | # 30 last days | |
316 | @date_from = Date.today - 30 |
|
303 | @date_from = Date.today - 30 | |
317 | @date_to = Date.today + 1 |
|
304 | @date_to = Date.today + 1 | |
318 | else |
|
305 | else | |
319 | # current month |
|
306 | # current month | |
320 | @date_from = Date.civil(@year, @month, 1) |
|
307 | @date_from = Date.civil(@year, @month, 1) | |
321 | @date_to = @date_from >> 1 |
|
308 | @date_to = @date_from >> 1 | |
322 | end |
|
309 | end | |
323 |
|
310 | |||
324 | @event_types = %w(issues news files documents changesets wiki_pages messages) |
|
311 | @event_types = %w(issues news files documents changesets wiki_pages messages) | |
325 | @event_types.delete('wiki_pages') unless @project.wiki |
|
312 | @event_types.delete('wiki_pages') unless @project.wiki | |
326 | @event_types.delete('changesets') unless @project.repository |
|
313 | @event_types.delete('changesets') unless @project.repository | |
327 | @event_types.delete('messages') unless @project.boards.any? |
|
314 | @event_types.delete('messages') unless @project.boards.any? | |
328 | # only show what the user is allowed to view |
|
315 | # only show what the user is allowed to view | |
329 | @event_types = @event_types.select {|o| User.current.allowed_to?("view_#{o}".to_sym, @project)} |
|
316 | @event_types = @event_types.select {|o| User.current.allowed_to?("view_#{o}".to_sym, @project)} | |
330 |
|
317 | |||
331 | @scope = @event_types.select {|t| params["show_#{t}"]} |
|
318 | @scope = @event_types.select {|t| params["show_#{t}"]} | |
332 | # default events if none is specified in parameters |
|
319 | # default events if none is specified in parameters | |
333 | @scope = (@event_types - %w(wiki_pages messages))if @scope.empty? |
|
320 | @scope = (@event_types - %w(wiki_pages messages))if @scope.empty? | |
334 |
|
321 | |||
335 | @events = [] |
|
322 | @events = [] | |
336 |
|
323 | |||
337 | if @scope.include?('issues') |
|
324 | if @scope.include?('issues') | |
338 | @events += @project.issues.find(:all, :include => [:author, :tracker], :conditions => ["#{Issue.table_name}.created_on>=? and #{Issue.table_name}.created_on<=?", @date_from, @date_to] ) |
|
325 | @events += @project.issues.find(:all, :include => [:author, :tracker], :conditions => ["#{Issue.table_name}.created_on>=? and #{Issue.table_name}.created_on<=?", @date_from, @date_to] ) | |
339 | @events += @project.issues_status_changes(@date_from, @date_to) |
|
326 | @events += @project.issues_status_changes(@date_from, @date_to) | |
340 | end |
|
327 | end | |
341 |
|
328 | |||
342 | if @scope.include?('news') |
|
329 | if @scope.include?('news') | |
343 | @events += @project.news.find(:all, :conditions => ["#{News.table_name}.created_on>=? and #{News.table_name}.created_on<=?", @date_from, @date_to], :include => :author ) |
|
330 | @events += @project.news.find(:all, :conditions => ["#{News.table_name}.created_on>=? and #{News.table_name}.created_on<=?", @date_from, @date_to], :include => :author ) | |
344 | end |
|
331 | end | |
345 |
|
332 | |||
346 | if @scope.include?('files') |
|
333 | if @scope.include?('files') | |
347 | @events += Attachment.find(:all, :select => "#{Attachment.table_name}.*", :joins => "LEFT JOIN #{Version.table_name} ON #{Version.table_name}.id = #{Attachment.table_name}.container_id", :conditions => ["#{Attachment.table_name}.container_type='Version' and #{Version.table_name}.project_id=? and #{Attachment.table_name}.created_on>=? and #{Attachment.table_name}.created_on<=?", @project.id, @date_from, @date_to], :include => :author ) |
|
334 | @events += Attachment.find(:all, :select => "#{Attachment.table_name}.*", :joins => "LEFT JOIN #{Version.table_name} ON #{Version.table_name}.id = #{Attachment.table_name}.container_id", :conditions => ["#{Attachment.table_name}.container_type='Version' and #{Version.table_name}.project_id=? and #{Attachment.table_name}.created_on>=? and #{Attachment.table_name}.created_on<=?", @project.id, @date_from, @date_to], :include => :author ) | |
348 | end |
|
335 | end | |
349 |
|
336 | |||
350 | if @scope.include?('documents') |
|
337 | if @scope.include?('documents') | |
351 | @events += @project.documents.find(:all, :conditions => ["#{Document.table_name}.created_on>=? and #{Document.table_name}.created_on<=?", @date_from, @date_to] ) |
|
338 | @events += @project.documents.find(:all, :conditions => ["#{Document.table_name}.created_on>=? and #{Document.table_name}.created_on<=?", @date_from, @date_to] ) | |
352 | @events += Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN #{Document.table_name} ON #{Document.table_name}.id = #{Attachment.table_name}.container_id", :conditions => ["#{Attachment.table_name}.container_type='Document' and #{Document.table_name}.project_id=? and #{Attachment.table_name}.created_on>=? and #{Attachment.table_name}.created_on<=?", @project.id, @date_from, @date_to], :include => :author ) |
|
339 | @events += Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN #{Document.table_name} ON #{Document.table_name}.id = #{Attachment.table_name}.container_id", :conditions => ["#{Attachment.table_name}.container_type='Document' and #{Document.table_name}.project_id=? and #{Attachment.table_name}.created_on>=? and #{Attachment.table_name}.created_on<=?", @project.id, @date_from, @date_to], :include => :author ) | |
353 | end |
|
340 | end | |
354 |
|
341 | |||
355 | if @scope.include?('wiki_pages') |
|
342 | if @scope.include?('wiki_pages') | |
356 | select = "#{WikiContent.versioned_table_name}.updated_on, #{WikiContent.versioned_table_name}.comments, " + |
|
343 | select = "#{WikiContent.versioned_table_name}.updated_on, #{WikiContent.versioned_table_name}.comments, " + | |
357 | "#{WikiContent.versioned_table_name}.#{WikiContent.version_column}, #{WikiPage.table_name}.title, " + |
|
344 | "#{WikiContent.versioned_table_name}.#{WikiContent.version_column}, #{WikiPage.table_name}.title, " + | |
358 | "#{WikiContent.versioned_table_name}.page_id, #{WikiContent.versioned_table_name}.author_id, " + |
|
345 | "#{WikiContent.versioned_table_name}.page_id, #{WikiContent.versioned_table_name}.author_id, " + | |
359 | "#{WikiContent.versioned_table_name}.id" |
|
346 | "#{WikiContent.versioned_table_name}.id" | |
360 | joins = "LEFT JOIN #{WikiPage.table_name} ON #{WikiPage.table_name}.id = #{WikiContent.versioned_table_name}.page_id " + |
|
347 | joins = "LEFT JOIN #{WikiPage.table_name} ON #{WikiPage.table_name}.id = #{WikiContent.versioned_table_name}.page_id " + | |
361 | "LEFT JOIN #{Wiki.table_name} ON #{Wiki.table_name}.id = #{WikiPage.table_name}.wiki_id " |
|
348 | "LEFT JOIN #{Wiki.table_name} ON #{Wiki.table_name}.id = #{WikiPage.table_name}.wiki_id " | |
362 | conditions = ["#{Wiki.table_name}.project_id = ? AND #{WikiContent.versioned_table_name}.updated_on BETWEEN ? AND ?", |
|
349 | conditions = ["#{Wiki.table_name}.project_id = ? AND #{WikiContent.versioned_table_name}.updated_on BETWEEN ? AND ?", | |
363 | @project.id, @date_from, @date_to] |
|
350 | @project.id, @date_from, @date_to] | |
364 |
|
351 | |||
365 | @events += WikiContent.versioned_class.find(:all, :select => select, :joins => joins, :conditions => conditions) |
|
352 | @events += WikiContent.versioned_class.find(:all, :select => select, :joins => joins, :conditions => conditions) | |
366 | end |
|
353 | end | |
367 |
|
354 | |||
368 | if @scope.include?('changesets') |
|
355 | if @scope.include?('changesets') | |
369 | @events += Changeset.find(:all, :include => :repository, :conditions => ["#{Repository.table_name}.project_id = ? AND #{Changeset.table_name}.committed_on BETWEEN ? AND ?", @project.id, @date_from, @date_to]) |
|
356 | @events += Changeset.find(:all, :include => :repository, :conditions => ["#{Repository.table_name}.project_id = ? AND #{Changeset.table_name}.committed_on BETWEEN ? AND ?", @project.id, @date_from, @date_to]) | |
370 | end |
|
357 | end | |
371 |
|
358 | |||
372 | if @scope.include?('messages') |
|
359 | if @scope.include?('messages') | |
373 | @events += Message.find(:all, |
|
360 | @events += Message.find(:all, | |
374 | :include => [:board, :author], |
|
361 | :include => [:board, :author], | |
375 | :conditions => ["#{Board.table_name}.project_id=? AND #{Message.table_name}.parent_id IS NULL AND #{Message.table_name}.created_on BETWEEN ? AND ?", @project.id, @date_from, @date_to]) |
|
362 | :conditions => ["#{Board.table_name}.project_id=? AND #{Message.table_name}.parent_id IS NULL AND #{Message.table_name}.created_on BETWEEN ? AND ?", @project.id, @date_from, @date_to]) | |
376 | end |
|
363 | end | |
377 |
|
364 | |||
378 | @events_by_day = @events.group_by(&:event_date) |
|
365 | @events_by_day = @events.group_by(&:event_date) | |
379 |
|
366 | |||
380 | respond_to do |format| |
|
367 | respond_to do |format| | |
381 | format.html { render :layout => false if request.xhr? } |
|
368 | format.html { render :layout => false if request.xhr? } | |
382 | format.atom { render_feed(@events, :title => "#{@project.name}: #{l(:label_activity)}") } |
|
369 | format.atom { render_feed(@events, :title => "#{@project.name}: #{l(:label_activity)}") } | |
383 | end |
|
370 | end | |
384 | end |
|
371 | end | |
385 |
|
372 | |||
386 | def calendar |
|
373 | def calendar | |
387 | @trackers = @project.rolled_up_trackers |
|
374 | @trackers = @project.rolled_up_trackers | |
388 | retrieve_selected_tracker_ids(@trackers) |
|
375 | retrieve_selected_tracker_ids(@trackers) | |
389 |
|
376 | |||
390 | if params[:year] and params[:year].to_i > 1900 |
|
377 | if params[:year] and params[:year].to_i > 1900 | |
391 | @year = params[:year].to_i |
|
378 | @year = params[:year].to_i | |
392 | if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13 |
|
379 | if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13 | |
393 | @month = params[:month].to_i |
|
380 | @month = params[:month].to_i | |
394 | end |
|
381 | end | |
395 | end |
|
382 | end | |
396 | @year ||= Date.today.year |
|
383 | @year ||= Date.today.year | |
397 | @month ||= Date.today.month |
|
384 | @month ||= Date.today.month | |
398 | @calendar = Redmine::Helpers::Calendar.new(Date.civil(@year, @month, 1), current_language, :month) |
|
385 | @calendar = Redmine::Helpers::Calendar.new(Date.civil(@year, @month, 1), current_language, :month) | |
399 |
|
386 | |||
400 | events = [] |
|
387 | events = [] | |
401 | @project.issues_with_subprojects(params[:with_subprojects]) do |
|
388 | @project.issues_with_subprojects(params[:with_subprojects]) do | |
402 | events += Issue.find(:all, |
|
389 | events += Issue.find(:all, | |
403 | :include => [:tracker, :status, :assigned_to, :priority, :project], |
|
390 | :include => [:tracker, :status, :assigned_to, :priority, :project], | |
404 | :conditions => ["((start_date BETWEEN ? AND ?) OR (due_date BETWEEN ? AND ?)) AND #{Issue.table_name}.tracker_id IN (#{@selected_tracker_ids.join(',')})", @calendar.startdt, @calendar.enddt, @calendar.startdt, @calendar.enddt] |
|
391 | :conditions => ["((start_date BETWEEN ? AND ?) OR (due_date BETWEEN ? AND ?)) AND #{Issue.table_name}.tracker_id IN (#{@selected_tracker_ids.join(',')})", @calendar.startdt, @calendar.enddt, @calendar.startdt, @calendar.enddt] | |
405 | ) unless @selected_tracker_ids.empty? |
|
392 | ) unless @selected_tracker_ids.empty? | |
406 | end |
|
393 | end | |
407 | events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @calendar.startdt, @calendar.enddt]) |
|
394 | events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @calendar.startdt, @calendar.enddt]) | |
408 | @calendar.events = events |
|
395 | @calendar.events = events | |
409 |
|
396 | |||
410 | render :layout => false if request.xhr? |
|
397 | render :layout => false if request.xhr? | |
411 | end |
|
398 | end | |
412 |
|
399 | |||
413 | def gantt |
|
400 | def gantt | |
414 | @trackers = @project.rolled_up_trackers |
|
401 | @trackers = @project.rolled_up_trackers | |
415 | retrieve_selected_tracker_ids(@trackers) |
|
402 | retrieve_selected_tracker_ids(@trackers) | |
416 |
|
403 | |||
417 | if params[:year] and params[:year].to_i >0 |
|
404 | if params[:year] and params[:year].to_i >0 | |
418 | @year_from = params[:year].to_i |
|
405 | @year_from = params[:year].to_i | |
419 | if params[:month] and params[:month].to_i >=1 and params[:month].to_i <= 12 |
|
406 | if params[:month] and params[:month].to_i >=1 and params[:month].to_i <= 12 | |
420 | @month_from = params[:month].to_i |
|
407 | @month_from = params[:month].to_i | |
421 | else |
|
408 | else | |
422 | @month_from = 1 |
|
409 | @month_from = 1 | |
423 | end |
|
410 | end | |
424 | else |
|
411 | else | |
425 | @month_from ||= Date.today.month |
|
412 | @month_from ||= Date.today.month | |
426 | @year_from ||= Date.today.year |
|
413 | @year_from ||= Date.today.year | |
427 | end |
|
414 | end | |
428 |
|
415 | |||
429 | zoom = (params[:zoom] || User.current.pref[:gantt_zoom]).to_i |
|
416 | zoom = (params[:zoom] || User.current.pref[:gantt_zoom]).to_i | |
430 | @zoom = (zoom > 0 && zoom < 5) ? zoom : 2 |
|
417 | @zoom = (zoom > 0 && zoom < 5) ? zoom : 2 | |
431 | months = (params[:months] || User.current.pref[:gantt_months]).to_i |
|
418 | months = (params[:months] || User.current.pref[:gantt_months]).to_i | |
432 | @months = (months > 0 && months < 25) ? months : 6 |
|
419 | @months = (months > 0 && months < 25) ? months : 6 | |
433 |
|
420 | |||
434 | # Save gantt paramters as user preference (zoom and months count) |
|
421 | # Save gantt paramters as user preference (zoom and months count) | |
435 | if (User.current.logged? && (@zoom != User.current.pref[:gantt_zoom] || @months != User.current.pref[:gantt_months])) |
|
422 | if (User.current.logged? && (@zoom != User.current.pref[:gantt_zoom] || @months != User.current.pref[:gantt_months])) | |
436 | User.current.pref[:gantt_zoom], User.current.pref[:gantt_months] = @zoom, @months |
|
423 | User.current.pref[:gantt_zoom], User.current.pref[:gantt_months] = @zoom, @months | |
437 | User.current.preference.save |
|
424 | User.current.preference.save | |
438 | end |
|
425 | end | |
439 |
|
426 | |||
440 | @date_from = Date.civil(@year_from, @month_from, 1) |
|
427 | @date_from = Date.civil(@year_from, @month_from, 1) | |
441 | @date_to = (@date_from >> @months) - 1 |
|
428 | @date_to = (@date_from >> @months) - 1 | |
442 |
|
429 | |||
443 | @events = [] |
|
430 | @events = [] | |
444 | @project.issues_with_subprojects(params[:with_subprojects]) do |
|
431 | @project.issues_with_subprojects(params[:with_subprojects]) do | |
445 | @events += Issue.find(:all, |
|
432 | @events += Issue.find(:all, | |
446 | :order => "start_date, due_date", |
|
433 | :order => "start_date, due_date", | |
447 | :include => [:tracker, :status, :assigned_to, :priority, :project], |
|
434 | :include => [:tracker, :status, :assigned_to, :priority, :project], | |
448 | :conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_date<? and due_date>?)) and start_date is not null and due_date is not null and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')}))", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to] |
|
435 | :conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_date<? and due_date>?)) and start_date is not null and due_date is not null and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')}))", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to] | |
449 | ) unless @selected_tracker_ids.empty? |
|
436 | ) unless @selected_tracker_ids.empty? | |
450 | end |
|
437 | end | |
451 | @events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @date_from, @date_to]) |
|
438 | @events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @date_from, @date_to]) | |
452 | @events.sort! {|x,y| x.start_date <=> y.start_date } |
|
439 | @events.sort! {|x,y| x.start_date <=> y.start_date } | |
453 |
|
440 | |||
454 | if params[:format]=='pdf' |
|
441 | if params[:format]=='pdf' | |
455 | @options_for_rfpdf ||= {} |
|
442 | @options_for_rfpdf ||= {} | |
456 | @options_for_rfpdf[:file_name] = "#{@project.identifier}-gantt.pdf" |
|
443 | @options_for_rfpdf[:file_name] = "#{@project.identifier}-gantt.pdf" | |
457 | render :template => "projects/gantt.rfpdf", :layout => false |
|
444 | render :template => "projects/gantt.rfpdf", :layout => false | |
458 | elsif params[:format]=='png' && respond_to?('gantt_image') |
|
445 | elsif params[:format]=='png' && respond_to?('gantt_image') | |
459 | image = gantt_image(@events, @date_from, @months, @zoom) |
|
446 | image = gantt_image(@events, @date_from, @months, @zoom) | |
460 | image.format = 'PNG' |
|
447 | image.format = 'PNG' | |
461 | send_data(image.to_blob, :disposition => 'inline', :type => 'image/png', :filename => "#{@project.identifier}-gantt.png") |
|
448 | send_data(image.to_blob, :disposition => 'inline', :type => 'image/png', :filename => "#{@project.identifier}-gantt.png") | |
462 | else |
|
449 | else | |
463 | render :template => "projects/gantt.rhtml" |
|
450 | render :template => "projects/gantt.rhtml" | |
464 | end |
|
451 | end | |
465 | end |
|
452 | end | |
466 |
|
453 | |||
467 | private |
|
454 | private | |
468 | # Find project of id params[:id] |
|
455 | # Find project of id params[:id] | |
469 | # if not found, redirect to project list |
|
456 | # if not found, redirect to project list | |
470 | # Used as a before_filter |
|
457 | # Used as a before_filter | |
471 | def find_project |
|
458 | def find_project | |
472 | @project = Project.find(params[:id]) |
|
459 | @project = Project.find(params[:id]) | |
473 | rescue ActiveRecord::RecordNotFound |
|
460 | rescue ActiveRecord::RecordNotFound | |
474 | render_404 |
|
461 | render_404 | |
475 | end |
|
462 | end | |
476 |
|
463 | |||
477 | def retrieve_selected_tracker_ids(selectable_trackers) |
|
464 | def retrieve_selected_tracker_ids(selectable_trackers) | |
478 | if ids = params[:tracker_ids] |
|
465 | if ids = params[:tracker_ids] | |
479 | @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s } |
|
466 | @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s } | |
480 | else |
|
467 | else | |
481 | @selected_tracker_ids = selectable_trackers.collect {|t| t.id.to_s } |
|
468 | @selected_tracker_ids = selectable_trackers.collect {|t| t.id.to_s } | |
482 | end |
|
469 | end | |
483 | end |
|
470 | end | |
484 | end |
|
471 | end |
@@ -1,6 +1,14 | |||||
1 | <h2><%=l(:label_news)%></h2> |
|
1 | <h2><%=l(:label_news)%></h2> | |
2 |
|
2 | |||
3 |
<% labelled_tabular_form_for :news, @news, :url => { :action => "edit" } |
|
3 | <% labelled_tabular_form_for :news, @news, :url => { :action => "edit" }, | |
|
4 | :html => { :id => 'news-form' } do |f| %> | |||
4 | <%= render :partial => 'form', :locals => { :f => f } %> |
|
5 | <%= render :partial => 'form', :locals => { :f => f } %> | |
5 | <%= submit_tag l(:button_save) %> |
|
6 | <%= submit_tag l(:button_save) %> | |
6 | <% end %> No newline at end of file |
|
7 | <%= link_to_remote l(:label_preview), | |
|
8 | { :url => { :controller => 'news', :action => 'preview' }, | |||
|
9 | :method => 'post', | |||
|
10 | :update => 'preview', | |||
|
11 | :with => "Form.serialize('news-form')" | |||
|
12 | }, :accesskey => accesskey(:preview) %> | |||
|
13 | <% end %> | |||
|
14 | <div id="preview" class="wiki"></div> |
@@ -1,38 +1,46 | |||||
1 | <div class="contextual"> |
|
1 | <div class="contextual"> | |
2 | <%= link_to_if_authorized(l(:label_news_new), |
|
2 | <%= link_to_if_authorized(l(:label_news_new), | |
3 |
{:controller => ' |
|
3 | {:controller => 'news', :action => 'new', :project_id => @project}, | |
4 | :class => 'icon icon-add', |
|
4 | :class => 'icon icon-add', | |
5 | :onclick => 'Element.show("add-news"); return false;') if @project %> |
|
5 | :onclick => 'Element.show("add-news"); return false;') if @project %> | |
6 | </div> |
|
6 | </div> | |
7 |
|
7 | |||
8 | <div id="add-news" style="display:none;"> |
|
8 | <div id="add-news" style="display:none;"> | |
9 | <h2><%=l(:label_news_new)%></h2> |
|
9 | <h2><%=l(:label_news_new)%></h2> | |
10 |
<% labelled_tabular_form_for :news, @news, :url => { :controller => ' |
|
10 | <% labelled_tabular_form_for :news, @news, :url => { :controller => 'news', :action => 'new', :project_id => @project }, | |
|
11 | :html => { :id => 'news-form' } do |f| %> | |||
11 | <%= render :partial => 'news/form', :locals => { :f => f } %> |
|
12 | <%= render :partial => 'news/form', :locals => { :f => f } %> | |
12 | <%= submit_tag l(:button_create) %> |
|
13 | <%= submit_tag l(:button_create) %> | |
|
14 | <%= link_to_remote l(:label_preview), | |||
|
15 | { :url => { :controller => 'news', :action => 'preview' }, | |||
|
16 | :method => 'post', | |||
|
17 | :update => 'preview', | |||
|
18 | :with => "Form.serialize('news-form')" | |||
|
19 | }, :accesskey => accesskey(:preview) %> | | |||
13 | <%= link_to l(:button_cancel), "#", :onclick => 'Element.hide("add-news")' %> |
|
20 | <%= link_to l(:button_cancel), "#", :onclick => 'Element.hide("add-news")' %> | |
14 | <% end if @project %> |
|
21 | <% end if @project %> | |
|
22 | <div id="preview" class="wiki"></div> | |||
15 | </div> |
|
23 | </div> | |
16 |
|
24 | |||
17 | <h2><%=l(:label_news_plural)%></h2> |
|
25 | <h2><%=l(:label_news_plural)%></h2> | |
18 |
|
26 | |||
19 | <% if @newss.empty? %> |
|
27 | <% if @newss.empty? %> | |
20 | <p class="nodata"><%= l(:label_no_data) %></p> |
|
28 | <p class="nodata"><%= l(:label_no_data) %></p> | |
21 | <% else %> |
|
29 | <% else %> | |
22 | <% @newss.each do |news| %> |
|
30 | <% @newss.each do |news| %> | |
23 | <h3><%= link_to(h(news.project.name), :controller => 'projects', :action => 'show', :id => news.project) + ': ' unless news.project == @project %> |
|
31 | <h3><%= link_to(h(news.project.name), :controller => 'projects', :action => 'show', :id => news.project) + ': ' unless news.project == @project %> | |
24 | <%= link_to h(news.title), :controller => 'news', :action => 'show', :id => news %> |
|
32 | <%= link_to h(news.title), :controller => 'news', :action => 'show', :id => news %> | |
25 | <%= "(#{news.comments_count} #{lwr(:label_comment, news.comments_count).downcase})" if news.comments_count > 0 %></h3> |
|
33 | <%= "(#{news.comments_count} #{lwr(:label_comment, news.comments_count).downcase})" if news.comments_count > 0 %></h3> | |
26 | <p class="author"><%= authoring news.created_on, news.author %></p> |
|
34 | <p class="author"><%= authoring news.created_on, news.author %></p> | |
27 | <div class="wiki"> |
|
35 | <div class="wiki"> | |
28 | <%= textilizable(news.description) %> |
|
36 | <%= textilizable(news.description) %> | |
29 | </div> |
|
37 | </div> | |
30 | <% end %> |
|
38 | <% end %> | |
31 | <% end %> |
|
39 | <% end %> | |
32 | <p class="pagination"><%= pagination_links_full @news_pages %></p> |
|
40 | <p class="pagination"><%= pagination_links_full @news_pages %></p> | |
33 |
|
41 | |||
34 | <% content_for :header_tags do %> |
|
42 | <% content_for :header_tags do %> | |
35 | <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %> |
|
43 | <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %> | |
36 | <% end %> |
|
44 | <% end %> | |
37 |
|
45 | |||
38 | <% html_title(l(:label_news_plural)) -%> |
|
46 | <% html_title(l(:label_news_plural)) -%> |
@@ -1,48 +1,56 | |||||
1 | <div class="contextual"> |
|
1 | <div class="contextual"> | |
2 | <%= link_to_if_authorized l(:button_edit), |
|
2 | <%= link_to_if_authorized l(:button_edit), | |
3 | {:controller => 'news', :action => 'edit', :id => @news}, |
|
3 | {:controller => 'news', :action => 'edit', :id => @news}, | |
4 | :class => 'icon icon-edit', |
|
4 | :class => 'icon icon-edit', | |
5 | :accesskey => accesskey(:edit), |
|
5 | :accesskey => accesskey(:edit), | |
6 | :onclick => 'Element.show("edit-news"); return false;' %> |
|
6 | :onclick => 'Element.show("edit-news"); return false;' %> | |
7 | <%= link_to_if_authorized l(:button_delete), {:controller => 'news', :action => 'destroy', :id => @news}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> |
|
7 | <%= link_to_if_authorized l(:button_delete), {:controller => 'news', :action => 'destroy', :id => @news}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> | |
8 | </div> |
|
8 | </div> | |
9 |
|
9 | |||
10 | <h2><%=h @news.title %></h2> |
|
10 | <h2><%=h @news.title %></h2> | |
11 |
|
11 | |||
12 | <div id="edit-news" style="display:none;"> |
|
12 | <div id="edit-news" style="display:none;"> | |
13 |
<% labelled_tabular_form_for :news, @news, :url => { :action => "edit", :id => @news } |
|
13 | <% labelled_tabular_form_for :news, @news, :url => { :action => "edit", :id => @news }, | |
|
14 | :html => { :id => 'news-form' } do |f| %> | |||
14 | <%= render :partial => 'form', :locals => { :f => f } %> |
|
15 | <%= render :partial => 'form', :locals => { :f => f } %> | |
15 | <%= submit_tag l(:button_save) %> |
|
16 | <%= submit_tag l(:button_save) %> | |
|
17 | <%= link_to_remote l(:label_preview), | |||
|
18 | { :url => { :controller => 'news', :action => 'preview' }, | |||
|
19 | :method => 'post', | |||
|
20 | :update => 'preview', | |||
|
21 | :with => "Form.serialize('news-form')" | |||
|
22 | }, :accesskey => accesskey(:preview) %> | | |||
16 | <%= link_to l(:button_cancel), "#", :onclick => 'Element.hide("edit-news")' %> |
|
23 | <%= link_to l(:button_cancel), "#", :onclick => 'Element.hide("edit-news")' %> | |
17 | <% end %> |
|
24 | <% end %> | |
|
25 | <div id="preview" class="wiki"></div> | |||
18 | </div> |
|
26 | </div> | |
19 |
|
27 | |||
20 | <p><em><% unless @news.summary.empty? %><%=h @news.summary %><br /><% end %> |
|
28 | <p><em><% unless @news.summary.empty? %><%=h @news.summary %><br /><% end %> | |
21 | <span class="author"><%= authoring @news.created_on, @news.author %></span></em></p> |
|
29 | <span class="author"><%= authoring @news.created_on, @news.author %></span></em></p> | |
22 | <div class="wiki"> |
|
30 | <div class="wiki"> | |
23 | <%= textilizable(@news.description) %> |
|
31 | <%= textilizable(@news.description) %> | |
24 | </div> |
|
32 | </div> | |
25 | <br /> |
|
33 | <br /> | |
26 |
|
34 | |||
27 | <div id="comments" style="margin-bottom:16px;"> |
|
35 | <div id="comments" style="margin-bottom:16px;"> | |
28 | <h3 class="icon22 icon22-comment"><%= l(:label_comment_plural) %></h3> |
|
36 | <h3 class="icon22 icon22-comment"><%= l(:label_comment_plural) %></h3> | |
29 | <% @news.comments.each do |comment| %> |
|
37 | <% @news.comments.each do |comment| %> | |
30 | <% next if comment.new_record? %> |
|
38 | <% next if comment.new_record? %> | |
31 | <h4><%= authoring comment.created_on, comment.author %></h4> |
|
39 | <h4><%= authoring comment.created_on, comment.author %></h4> | |
32 | <div class="contextual"> |
|
40 | <div class="contextual"> | |
33 | <%= link_to_if_authorized l(:button_delete), {:controller => 'news', :action => 'destroy_comment', :id => @news, :comment_id => comment}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> |
|
41 | <%= link_to_if_authorized l(:button_delete), {:controller => 'news', :action => 'destroy_comment', :id => @news, :comment_id => comment}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> | |
34 | </div> |
|
42 | </div> | |
35 | <%= textilizable(comment.comments) %> |
|
43 | <%= textilizable(comment.comments) %> | |
36 | <% end if @news.comments_count > 0 %> |
|
44 | <% end if @news.comments_count > 0 %> | |
37 | </div> |
|
45 | </div> | |
38 |
|
46 | |||
39 | <% if authorize_for 'news', 'add_comment' %> |
|
47 | <% if authorize_for 'news', 'add_comment' %> | |
40 | <p><%= toggle_link l(:label_comment_add), "add_comment_form", :focus => "comment_comments" %></p> |
|
48 | <p><%= toggle_link l(:label_comment_add), "add_comment_form", :focus => "comment_comments" %></p> | |
41 | <% form_tag({:action => 'add_comment', :id => @news}, :id => "add_comment_form", :style => "display:none;") do %> |
|
49 | <% form_tag({:action => 'add_comment', :id => @news}, :id => "add_comment_form", :style => "display:none;") do %> | |
42 | <%= text_area 'comment', 'comments', :cols => 80, :rows => 15, :class => 'wiki-edit' %> |
|
50 | <%= text_area 'comment', 'comments', :cols => 80, :rows => 15, :class => 'wiki-edit' %> | |
43 | <%= wikitoolbar_for 'comment_comments' %> |
|
51 | <%= wikitoolbar_for 'comment_comments' %> | |
44 | <p><%= submit_tag l(:button_add) %></p> |
|
52 | <p><%= submit_tag l(:button_add) %></p> | |
45 | <% end %> |
|
53 | <% end %> | |
46 | <% end %> |
|
54 | <% end %> | |
47 |
|
55 | |||
48 | <% html_title @news.title -%> |
|
56 | <% html_title @news.title -%> |
@@ -1,111 +1,111 | |||||
1 | require 'redmine/access_control' |
|
1 | require 'redmine/access_control' | |
2 | require 'redmine/menu_manager' |
|
2 | require 'redmine/menu_manager' | |
3 | require 'redmine/mime_type' |
|
3 | require 'redmine/mime_type' | |
4 | require 'redmine/themes' |
|
4 | require 'redmine/themes' | |
5 | require 'redmine/plugin' |
|
5 | require 'redmine/plugin' | |
6 |
|
6 | |||
7 | begin |
|
7 | begin | |
8 | require_library_or_gem 'RMagick' unless Object.const_defined?(:Magick) |
|
8 | require_library_or_gem 'RMagick' unless Object.const_defined?(:Magick) | |
9 | rescue LoadError |
|
9 | rescue LoadError | |
10 | # RMagick is not available |
|
10 | # RMagick is not available | |
11 | end |
|
11 | end | |
12 |
|
12 | |||
13 | REDMINE_SUPPORTED_SCM = %w( Subversion Darcs Mercurial Cvs Bazaar ) |
|
13 | REDMINE_SUPPORTED_SCM = %w( Subversion Darcs Mercurial Cvs Bazaar ) | |
14 |
|
14 | |||
15 | # Permissions |
|
15 | # Permissions | |
16 | Redmine::AccessControl.map do |map| |
|
16 | Redmine::AccessControl.map do |map| | |
17 | map.permission :view_project, {:projects => [:show, :activity]}, :public => true |
|
17 | map.permission :view_project, {:projects => [:show, :activity]}, :public => true | |
18 | map.permission :search_project, {:search => :index}, :public => true |
|
18 | map.permission :search_project, {:search => :index}, :public => true | |
19 | map.permission :edit_project, {:projects => [:settings, :edit]}, :require => :member |
|
19 | map.permission :edit_project, {:projects => [:settings, :edit]}, :require => :member | |
20 | map.permission :select_project_modules, {:projects => :modules}, :require => :member |
|
20 | map.permission :select_project_modules, {:projects => :modules}, :require => :member | |
21 | map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy]}, :require => :member |
|
21 | map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy]}, :require => :member | |
22 | map.permission :manage_versions, {:projects => [:settings, :add_version], :versions => [:edit, :destroy]}, :require => :member |
|
22 | map.permission :manage_versions, {:projects => [:settings, :add_version], :versions => [:edit, :destroy]}, :require => :member | |
23 |
|
23 | |||
24 | map.project_module :issue_tracking do |map| |
|
24 | map.project_module :issue_tracking do |map| | |
25 | # Issue categories |
|
25 | # Issue categories | |
26 | map.permission :manage_categories, {:projects => [:settings, :add_issue_category], :issue_categories => [:edit, :destroy]}, :require => :member |
|
26 | map.permission :manage_categories, {:projects => [:settings, :add_issue_category], :issue_categories => [:edit, :destroy]}, :require => :member | |
27 | # Issues |
|
27 | # Issues | |
28 | map.permission :view_issues, {:projects => [:changelog, :roadmap], |
|
28 | map.permission :view_issues, {:projects => [:changelog, :roadmap], | |
29 | :issues => [:index, :changes, :show, :context_menu], |
|
29 | :issues => [:index, :changes, :show, :context_menu], | |
30 | :versions => [:show, :status_by], |
|
30 | :versions => [:show, :status_by], | |
31 | :queries => :index, |
|
31 | :queries => :index, | |
32 | :reports => :issue_report}, :public => true |
|
32 | :reports => :issue_report}, :public => true | |
33 | map.permission :add_issues, {:issues => :new} |
|
33 | map.permission :add_issues, {:issues => :new} | |
34 | map.permission :edit_issues, {:projects => :bulk_edit_issues, |
|
34 | map.permission :edit_issues, {:projects => :bulk_edit_issues, | |
35 | :issues => [:edit, :update, :destroy_attachment]} |
|
35 | :issues => [:edit, :update, :destroy_attachment]} | |
36 | map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]} |
|
36 | map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]} | |
37 | map.permission :add_issue_notes, {:issues => :update} |
|
37 | map.permission :add_issue_notes, {:issues => :update} | |
38 | map.permission :move_issues, {:projects => :move_issues}, :require => :loggedin |
|
38 | map.permission :move_issues, {:projects => :move_issues}, :require => :loggedin | |
39 | map.permission :delete_issues, {:issues => :destroy}, :require => :member |
|
39 | map.permission :delete_issues, {:issues => :destroy}, :require => :member | |
40 | # Queries |
|
40 | # Queries | |
41 | map.permission :manage_public_queries, {:queries => [:new, :edit, :destroy]}, :require => :member |
|
41 | map.permission :manage_public_queries, {:queries => [:new, :edit, :destroy]}, :require => :member | |
42 | map.permission :save_queries, {:queries => [:new, :edit, :destroy]}, :require => :loggedin |
|
42 | map.permission :save_queries, {:queries => [:new, :edit, :destroy]}, :require => :loggedin | |
43 | # Gantt & calendar |
|
43 | # Gantt & calendar | |
44 | map.permission :view_gantt, :projects => :gantt |
|
44 | map.permission :view_gantt, :projects => :gantt | |
45 | map.permission :view_calendar, :projects => :calendar |
|
45 | map.permission :view_calendar, :projects => :calendar | |
46 | end |
|
46 | end | |
47 |
|
47 | |||
48 | map.project_module :time_tracking do |map| |
|
48 | map.project_module :time_tracking do |map| | |
49 | map.permission :log_time, {:timelog => :edit}, :require => :loggedin |
|
49 | map.permission :log_time, {:timelog => :edit}, :require => :loggedin | |
50 | map.permission :view_time_entries, :timelog => [:details, :report] |
|
50 | map.permission :view_time_entries, :timelog => [:details, :report] | |
51 | end |
|
51 | end | |
52 |
|
52 | |||
53 | map.project_module :news do |map| |
|
53 | map.project_module :news do |map| | |
54 |
map.permission :manage_news, { |
|
54 | map.permission :manage_news, {:news => [:new, :edit, :destroy, :destroy_comment]}, :require => :member | |
55 | map.permission :view_news, {:news => [:index, :show]}, :public => true |
|
55 | map.permission :view_news, {:news => [:index, :show]}, :public => true | |
56 | map.permission :comment_news, {:news => :add_comment} |
|
56 | map.permission :comment_news, {:news => :add_comment} | |
57 | end |
|
57 | end | |
58 |
|
58 | |||
59 | map.project_module :documents do |map| |
|
59 | map.project_module :documents do |map| | |
60 | map.permission :manage_documents, {:documents => [:new, :edit, :destroy, :add_attachment, :destroy_attachment]}, :require => :loggedin |
|
60 | map.permission :manage_documents, {:documents => [:new, :edit, :destroy, :add_attachment, :destroy_attachment]}, :require => :loggedin | |
61 | map.permission :view_documents, :documents => [:index, :show, :download] |
|
61 | map.permission :view_documents, :documents => [:index, :show, :download] | |
62 | end |
|
62 | end | |
63 |
|
63 | |||
64 | map.project_module :files do |map| |
|
64 | map.project_module :files do |map| | |
65 | map.permission :manage_files, {:projects => :add_file, :versions => :destroy_file}, :require => :loggedin |
|
65 | map.permission :manage_files, {:projects => :add_file, :versions => :destroy_file}, :require => :loggedin | |
66 | map.permission :view_files, :projects => :list_files, :versions => :download |
|
66 | map.permission :view_files, :projects => :list_files, :versions => :download | |
67 | end |
|
67 | end | |
68 |
|
68 | |||
69 | map.project_module :wiki do |map| |
|
69 | map.project_module :wiki do |map| | |
70 | map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member |
|
70 | map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member | |
71 | map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member |
|
71 | map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member | |
72 | map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member |
|
72 | map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member | |
73 | map.permission :view_wiki_pages, :wiki => [:index, :history, :diff, :annotate, :special] |
|
73 | map.permission :view_wiki_pages, :wiki => [:index, :history, :diff, :annotate, :special] | |
74 | map.permission :edit_wiki_pages, :wiki => [:edit, :preview, :add_attachment, :destroy_attachment] |
|
74 | map.permission :edit_wiki_pages, :wiki => [:edit, :preview, :add_attachment, :destroy_attachment] | |
75 | end |
|
75 | end | |
76 |
|
76 | |||
77 | map.project_module :repository do |map| |
|
77 | map.project_module :repository do |map| | |
78 | map.permission :manage_repository, {:repositories => [:edit, :destroy]}, :require => :member |
|
78 | map.permission :manage_repository, {:repositories => [:edit, :destroy]}, :require => :member | |
79 | map.permission :browse_repository, :repositories => [:show, :browse, :entry, :annotate, :changes, :diff, :stats, :graph] |
|
79 | map.permission :browse_repository, :repositories => [:show, :browse, :entry, :annotate, :changes, :diff, :stats, :graph] | |
80 | map.permission :view_changesets, :repositories => [:show, :revisions, :revision] |
|
80 | map.permission :view_changesets, :repositories => [:show, :revisions, :revision] | |
81 | end |
|
81 | end | |
82 |
|
82 | |||
83 | map.project_module :boards do |map| |
|
83 | map.project_module :boards do |map| | |
84 | map.permission :manage_boards, {:boards => [:new, :edit, :destroy]}, :require => :member |
|
84 | map.permission :manage_boards, {:boards => [:new, :edit, :destroy]}, :require => :member | |
85 | map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true |
|
85 | map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true | |
86 | map.permission :add_messages, {:messages => [:new, :reply]} |
|
86 | map.permission :add_messages, {:messages => [:new, :reply]} | |
87 | map.permission :edit_messages, {:messages => :edit}, :require => :member |
|
87 | map.permission :edit_messages, {:messages => :edit}, :require => :member | |
88 | map.permission :delete_messages, {:messages => :destroy}, :require => :member |
|
88 | map.permission :delete_messages, {:messages => :destroy}, :require => :member | |
89 | end |
|
89 | end | |
90 | end |
|
90 | end | |
91 |
|
91 | |||
92 | # Project menu configuration |
|
92 | # Project menu configuration | |
93 | Redmine::MenuManager.map :project_menu do |menu| |
|
93 | Redmine::MenuManager.map :project_menu do |menu| | |
94 | menu.push :overview, { :controller => 'projects', :action => 'show' }, :caption => :label_overview |
|
94 | menu.push :overview, { :controller => 'projects', :action => 'show' }, :caption => :label_overview | |
95 | menu.push :activity, { :controller => 'projects', :action => 'activity' }, :caption => :label_activity |
|
95 | menu.push :activity, { :controller => 'projects', :action => 'activity' }, :caption => :label_activity | |
96 | menu.push :roadmap, { :controller => 'projects', :action => 'roadmap' }, |
|
96 | menu.push :roadmap, { :controller => 'projects', :action => 'roadmap' }, | |
97 | :if => Proc.new { |p| p.versions.any? }, :caption => :label_roadmap |
|
97 | :if => Proc.new { |p| p.versions.any? }, :caption => :label_roadmap | |
98 | menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural |
|
98 | menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural | |
99 | menu.push :new_issue, { :controller => 'issues', :action => 'new' }, :param => :project_id, :caption => :label_issue_new, |
|
99 | menu.push :new_issue, { :controller => 'issues', :action => 'new' }, :param => :project_id, :caption => :label_issue_new, | |
100 | :html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) } |
|
100 | :html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) } | |
101 | menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural |
|
101 | menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural | |
102 | menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural |
|
102 | menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural | |
103 | menu.push :wiki, { :controller => 'wiki', :action => 'index', :page => nil }, |
|
103 | menu.push :wiki, { :controller => 'wiki', :action => 'index', :page => nil }, | |
104 | :if => Proc.new { |p| p.wiki && !p.wiki.new_record? }, :caption => :label_wiki |
|
104 | :if => Proc.new { |p| p.wiki && !p.wiki.new_record? }, :caption => :label_wiki | |
105 | menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id, |
|
105 | menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id, | |
106 | :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural |
|
106 | :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural | |
107 | menu.push :files, { :controller => 'projects', :action => 'list_files' }, :caption => :label_attachment_plural |
|
107 | menu.push :files, { :controller => 'projects', :action => 'list_files' }, :caption => :label_attachment_plural | |
108 | menu.push :repository, { :controller => 'repositories', :action => 'show' }, |
|
108 | menu.push :repository, { :controller => 'repositories', :action => 'show' }, | |
109 | :if => Proc.new { |p| p.repository && !p.repository.new_record? }, :caption => :label_repository |
|
109 | :if => Proc.new { |p| p.repository && !p.repository.new_record? }, :caption => :label_repository | |
110 | menu.push :settings, { :controller => 'projects', :action => 'settings' }, :caption => :label_settings |
|
110 | menu.push :settings, { :controller => 'projects', :action => 'settings' }, :caption => :label_settings | |
111 | end |
|
111 | end |
@@ -1,48 +1,59 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2007 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. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.dirname(__FILE__) + '/../test_helper' |
|
18 | require File.dirname(__FILE__) + '/../test_helper' | |
19 | require 'news_controller' |
|
19 | require 'news_controller' | |
20 |
|
20 | |||
21 | # Re-raise errors caught by the controller. |
|
21 | # Re-raise errors caught by the controller. | |
22 | class NewsController; def rescue_action(e) raise e end; end |
|
22 | class NewsController; def rescue_action(e) raise e end; end | |
23 |
|
23 | |||
24 | class NewsControllerTest < Test::Unit::TestCase |
|
24 | class NewsControllerTest < Test::Unit::TestCase | |
25 | fixtures :projects, :users, :roles, :members, :enabled_modules |
|
25 | fixtures :projects, :users, :roles, :members, :enabled_modules | |
26 |
|
26 | |||
27 | def setup |
|
27 | def setup | |
28 | @controller = NewsController.new |
|
28 | @controller = NewsController.new | |
29 | @request = ActionController::TestRequest.new |
|
29 | @request = ActionController::TestRequest.new | |
30 | @response = ActionController::TestResponse.new |
|
30 | @response = ActionController::TestResponse.new | |
31 | User.current = nil |
|
31 | User.current = nil | |
32 | end |
|
32 | end | |
33 |
|
33 | |||
34 | def test_index |
|
34 | def test_index | |
35 | get :index |
|
35 | get :index | |
36 | assert_response :success |
|
36 | assert_response :success | |
37 | assert_template 'index' |
|
37 | assert_template 'index' | |
38 | assert_not_nil assigns(:newss) |
|
38 | assert_not_nil assigns(:newss) | |
39 | assert_nil assigns(:project) |
|
39 | assert_nil assigns(:project) | |
40 | end |
|
40 | end | |
41 |
|
41 | |||
42 | def test_index_with_project |
|
42 | def test_index_with_project | |
43 | get :index, :project_id => 1 |
|
43 | get :index, :project_id => 1 | |
44 | assert_response :success |
|
44 | assert_response :success | |
45 | assert_template 'index' |
|
45 | assert_template 'index' | |
46 | assert_not_nil assigns(:newss) |
|
46 | assert_not_nil assigns(:newss) | |
47 | end |
|
47 | end | |
|
48 | ||||
|
49 | def test_preview | |||
|
50 | get :preview, :project_id => 1, | |||
|
51 | :news => {:title => '', | |||
|
52 | :description => 'News description', | |||
|
53 | :summary => ''} | |||
|
54 | assert_response :success | |||
|
55 | assert_template 'common/_preview' | |||
|
56 | assert_tag :tag => 'fieldset', :attributes => { :class => 'preview' }, | |||
|
57 | :content => /News description/ | |||
|
58 | end | |||
48 | end |
|
59 | end |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now