Revision 4069
Added by Eric Davis almost 15 years ago
trunk/app/controllers/projects_controller.rb | ||
---|---|---|
20 | 20 |
menu_item :roadmap, :only => :roadmap |
21 | 21 |
menu_item :settings, :only => :settings |
22 | 22 |
|
23 |
before_filter :find_project, :except => [ :index, :list, :add, :create, :copy ]
|
|
24 |
before_filter :authorize, :except => [ :index, :list, :add, :create, :copy, :archive, :unarchive, :destroy]
|
|
25 |
before_filter :authorize_global, :only => [:add, :create]
|
|
23 |
before_filter :find_project, :except => [ :index, :list, :new, :create, :copy ]
|
|
24 |
before_filter :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy]
|
|
25 |
before_filter :authorize_global, :only => [:new, :create]
|
|
26 | 26 |
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ] |
27 | 27 |
accept_key_auth :index |
28 | 28 |
|
... | ... | |
60 | 60 |
end |
61 | 61 |
end |
62 | 62 |
|
63 |
# Add a new project |
|
64 |
def add |
|
63 |
def new |
|
65 | 64 |
@issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position") |
66 | 65 |
@trackers = Tracker.all |
67 | 66 |
@project = Project.new(params[:project]) |
... | ... | |
95 | 94 |
end |
96 | 95 |
else |
97 | 96 |
respond_to do |format| |
98 |
format.html { render :action => 'add' }
|
|
97 |
format.html { render :action => 'new' }
|
|
99 | 98 |
format.xml { render :xml => @project.errors, :status => :unprocessable_entity } |
100 | 99 |
end |
101 | 100 |
end |
trunk/app/views/admin/projects.rhtml | ||
---|---|---|
1 | 1 |
<div class="contextual"> |
2 |
<%= link_to l(:label_project_new), {:controller => 'projects', :action => 'add'}, :class => 'icon icon-add' %>
|
|
2 |
<%= link_to l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add' %>
|
|
3 | 3 |
</div> |
4 | 4 |
|
5 | 5 |
<h2><%=l(:label_project_plural)%></h2> |
trunk/app/views/projects/add.rhtml | ||
---|---|---|
1 |
<h2><%=l(:label_project_new)%></h2> |
|
2 |
|
|
3 |
<% labelled_tabular_form_for :project, @project, :url => { :action => "create" } do |f| %> |
|
4 |
<%= render :partial => 'form', :locals => { :f => f } %> |
|
5 |
|
|
6 |
<fieldset class="box"><legend><%= l(:label_module_plural) %></legend> |
|
7 |
<% Redmine::AccessControl.available_project_modules.each do |m| %> |
|
8 |
<label class="floating"> |
|
9 |
<%= check_box_tag 'enabled_modules[]', m, @project.module_enabled?(m) %> |
|
10 |
<%= l_or_humanize(m, :prefix => "project_module_") %> |
|
11 |
</label> |
|
12 |
<% end %> |
|
13 |
</fieldset> |
|
14 |
|
|
15 |
<%= submit_tag l(:button_save) %> |
|
16 |
<%= javascript_tag "Form.Element.focus('project_name');" %> |
|
17 |
<% end %> |
|
18 | 0 |
trunk/app/views/projects/index.rhtml | ||
---|---|---|
3 | 3 |
<% end %> |
4 | 4 |
|
5 | 5 |
<div class="contextual"> |
6 |
<%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'add'}, :class => 'icon icon-add') + ' |' if User.current.allowed_to?(:add_project, nil, :global => true) %>
|
|
6 |
<%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add') + ' |' if User.current.allowed_to?(:add_project, nil, :global => true) %>
|
|
7 | 7 |
<%= link_to(l(:label_issue_view_all), { :controller => 'issues' }) + ' |' if User.current.allowed_to?(:view_issues, nil, :global => true) %> |
8 | 8 |
<%= link_to(l(:label_overall_spent_time), { :controller => 'time_entries' }) + ' |' if User.current.allowed_to?(:view_time_entries, nil, :global => true) %> |
9 | 9 |
<%= link_to l(:label_overall_activity), { :controller => 'activities', :action => 'index' }%> |
trunk/app/views/projects/new.html.erb | ||
---|---|---|
1 |
<h2><%=l(:label_project_new)%></h2> |
|
2 |
|
|
3 |
<% labelled_tabular_form_for :project, @project, :url => { :action => "create" } do |f| %> |
|
4 |
<%= render :partial => 'form', :locals => { :f => f } %> |
|
5 |
|
|
6 |
<fieldset class="box"><legend><%= l(:label_module_plural) %></legend> |
|
7 |
<% Redmine::AccessControl.available_project_modules.each do |m| %> |
|
8 |
<label class="floating"> |
|
9 |
<%= check_box_tag 'enabled_modules[]', m, @project.module_enabled?(m) %> |
|
10 |
<%= l_or_humanize(m, :prefix => "project_module_") %> |
|
11 |
</label> |
|
12 |
<% end %> |
|
13 |
</fieldset> |
|
14 |
|
|
15 |
<%= submit_tag l(:button_save) %> |
|
16 |
<%= javascript_tag "Form.Element.focus('project_name');" %> |
|
17 |
<% end %> |
|
0 | 18 |
trunk/config/routes.rb | ||
---|---|---|
177 | 177 |
projects.with_options :conditions => {:method => :get} do |project_views| |
178 | 178 |
project_views.connect 'projects', :action => 'index' |
179 | 179 |
project_views.connect 'projects.:format', :action => 'index' |
180 |
project_views.connect 'projects/new', :action => 'add'
|
|
180 |
project_views.connect 'projects/new', :action => 'new'
|
|
181 | 181 |
project_views.connect 'projects/:id', :action => 'show' |
182 | 182 |
project_views.connect 'projects/:id.:format', :action => 'show' |
183 | 183 |
project_views.connect 'projects/:id/:action', :action => /destroy|settings/ |
trunk/lib/redmine.rb | ||
---|---|---|
46 | 46 |
Redmine::AccessControl.map do |map| |
47 | 47 |
map.permission :view_project, {:projects => [:show], :activities => [:index]}, :public => true |
48 | 48 |
map.permission :search_project, {:search => :index}, :public => true |
49 |
map.permission :add_project, {:projects => [:add, :create]}, :require => :loggedin
|
|
49 |
map.permission :add_project, {:projects => [:new, :create]}, :require => :loggedin
|
|
50 | 50 |
map.permission :edit_project, {:projects => [:settings, :edit]}, :require => :member |
51 | 51 |
map.permission :select_project_modules, {:projects => :modules}, :require => :member |
52 | 52 |
map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy, :autocomplete_for_member]}, :require => :member |
53 | 53 |
map.permission :manage_versions, {:projects => :settings, :versions => [:new, :edit, :close_completed, :destroy]}, :require => :member |
54 |
map.permission :add_subprojects, {:projects => [:add, :create]}, :require => :member
|
|
54 |
map.permission :add_subprojects, {:projects => [:new, :create]}, :require => :member
|
|
55 | 55 |
|
56 | 56 |
map.project_module :issue_tracking do |map| |
57 | 57 |
# Issue categories |
trunk/test/functional/projects_controller_test.rb | ||
---|---|---|
87 | 87 |
end |
88 | 88 |
end |
89 | 89 |
|
90 |
context "#add" do
|
|
90 |
context "#new" do
|
|
91 | 91 |
context "by admin user" do |
92 | 92 |
setup do |
93 | 93 |
@request.session[:user_id] = 1 |
94 | 94 |
end |
95 | 95 |
|
96 | 96 |
should "accept get" do |
97 |
get :add
|
|
97 |
get :new
|
|
98 | 98 |
assert_response :success |
99 |
assert_template 'add'
|
|
99 |
assert_template 'new'
|
|
100 | 100 |
end |
101 | 101 |
|
102 | 102 |
end |
... | ... | |
108 | 108 |
end |
109 | 109 |
|
110 | 110 |
should "accept get" do |
111 |
get :add
|
|
111 |
get :new
|
|
112 | 112 |
assert_response :success |
113 |
assert_template 'add'
|
|
113 |
assert_template 'new'
|
|
114 | 114 |
assert_no_tag :select, :attributes => {:name => 'project[parent_id]'} |
115 | 115 |
end |
116 | 116 |
end |
... | ... | |
123 | 123 |
end |
124 | 124 |
|
125 | 125 |
should "accept get" do |
126 |
get :add, :parent_id => 'ecookbook'
|
|
126 |
get :new, :parent_id => 'ecookbook'
|
|
127 | 127 |
assert_response :success |
128 |
assert_template 'add'
|
|
128 |
assert_template 'new'
|
|
129 | 129 |
# parent project selected |
130 | 130 |
assert_tag :select, :attributes => {:name => 'project[parent_id]'}, |
131 | 131 |
:child => {:tag => 'option', :attributes => {:value => '1', :selected => 'selected'}} |
trunk/test/integration/routing_test.rb | ||
---|---|---|
166 | 166 |
should_route :get, "/projects", :controller => 'projects', :action => 'index' |
167 | 167 |
should_route :get, "/projects.atom", :controller => 'projects', :action => 'index', :format => 'atom' |
168 | 168 |
should_route :get, "/projects.xml", :controller => 'projects', :action => 'index', :format => 'xml' |
169 |
should_route :get, "/projects/new", :controller => 'projects', :action => 'add'
|
|
169 |
should_route :get, "/projects/new", :controller => 'projects', :action => 'new'
|
|
170 | 170 |
should_route :get, "/projects/test", :controller => 'projects', :action => 'show', :id => 'test' |
171 | 171 |
should_route :get, "/projects/1.xml", :controller => 'projects', :action => 'show', :id => '1', :format => 'xml' |
172 | 172 |
should_route :get, "/projects/4223/settings", :controller => 'projects', :action => 'settings', :id => '4223' |
Also available in: Unified diff
Refactor: rename method ProjectsController#add to ProjectsController#new