From 6e695a4d1a372110eb0f59d8bb091fd59ab2269b Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 8 Jan 2011 10:14:00 +0000 Subject: Merged r4645 to r4651 from trunk. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.1-stable@4660 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/projects_controller.rb | 12 +-- app/models/project.rb | 5 +- app/views/projects/_form.rhtml | 19 ++++- app/views/projects/new.html.erb | 12 --- app/views/projects/settings/_modules.rhtml | 2 +- app/views/wiki/history.rhtml | 12 +-- public/javascripts/application.js | 18 ++++ public/stylesheets/application.css | 2 + test/fixtures/roles.yml | 1 + test/functional/projects_controller_test.rb | 31 ++++++- test/integration/api_test/projects_test.rb | 47 ++++++++++- test/unit/project_nested_set_test.rb | 126 ++++++++++++++++++++-------- 12 files changed, 223 insertions(+), 64 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 420801c01..459b54784 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -32,9 +32,6 @@ class ProjectsController < ApplicationController end end - # TODO: convert to PUT only - verify :method => [:post, :put], :only => :update, :render => {:nothing => true, :status => :method_not_allowed } - helper :sort include SortHelper helper :custom_fields @@ -71,13 +68,13 @@ class ProjectsController < ApplicationController @project = Project.new(params[:project]) end + verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed } def create @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position") @trackers = Tracker.all @project = Project.new @project.safe_attributes = params[:project] - @project.enabled_module_names = params[:enabled_modules] if params[:enabled_modules] if validate_parent_id && @project.save @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') # Add current user as a project member if he is not admin @@ -184,6 +181,8 @@ class ProjectsController < ApplicationController def edit end + # TODO: convert to PUT only + verify :method => [:post, :put], :only => :update, :render => {:nothing => true, :status => :method_not_allowed } def update @project.safe_attributes = params[:project] if validate_parent_id && @project.save @@ -205,9 +204,10 @@ class ProjectsController < ApplicationController end end end - + + verify :method => :post, :only => :modules, :render => {:nothing => true, :status => :method_not_allowed } def modules - @project.enabled_module_names = params[:enabled_modules] + @project.enabled_module_names = params[:enabled_module_names] flash[:notice] = l(:notice_successful_update) redirect_to :action => 'settings', :id => @project, :tab => 'modules' end diff --git a/app/models/project.rb b/app/models/project.rb index 891db8b8c..8315a48a5 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -66,7 +66,7 @@ class Project < ActiveRecord::Base :url => Proc.new {|o| {:controller => 'projects', :action => 'show', :id => o}}, :author => nil - attr_protected :status, :enabled_module_names + attr_protected :status validates_presence_of :name, :identifier validates_uniqueness_of :identifier @@ -533,6 +533,9 @@ class Project < ActiveRecord::Base 'tracker_ids', 'issue_custom_field_ids' + safe_attributes 'enabled_module_names', + :if => lambda {|project, user| project.new_record? || user.allowed_to?(:select_project_modules, project) } + # Returns an array of projects that are in this project's hierarchy # # Example: parents, children, siblings diff --git a/app/views/projects/_form.rhtml b/app/views/projects/_form.rhtml index e8045bf2c..9772a899c 100644 --- a/app/views/projects/_form.rhtml +++ b/app/views/projects/_form.rhtml @@ -23,8 +23,22 @@ <%= call_hook(:view_projects_form, :project => @project, :form => f) %> +<% if @project.new_record? %> +
<%= l(:label_module_plural) %> +<% Redmine::AccessControl.available_project_modules.each do |m| %> + +<% end %> +<%= hidden_field_tag 'project[enabled_module_names][]', '' %> +<%= javascript_tag 'observeProjectModules()' %> +
+<% end %> + +<% if @project.new_record? || @project.module_enabled?('issue_tracking') %> <% unless @trackers.empty? %> -
<%=l(:label_tracker_plural)%> +
<%=l(:label_tracker_plural)%> <% @trackers.each do |tracker| %>