diff options
Diffstat (limited to 'app/controllers/members_controller.rb')
-rw-r--r-- | app/controllers/members_controller.rb | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 6d5dd4733..ae2f57a13 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -17,15 +17,15 @@ class MembersController < ApplicationController model_object Member - before_filter :find_model_object, :except => [:new, :autocomplete_for_member] - before_filter :find_project_from_association, :except => [:new, :autocomplete_for_member] - before_filter :find_project, :only => [:new, :autocomplete_for_member] + before_filter :find_model_object, :except => [:create, :autocomplete] + before_filter :find_project_from_association, :except => [:create, :autocomplete] + before_filter :find_project_by_project_id, :only => [:create, :autocomplete] before_filter :authorize - def new + def create members = [] - if params[:member] && request.post? - attrs = params[:member].dup + if params[:membership] && request.post? + attrs = params[:membership].dup if (user_ids = attrs.delete(:user_ids)) user_ids.each do |user_id| members << Member.new(attrs.merge(:user_id => user_id)) @@ -63,8 +63,11 @@ class MembersController < ApplicationController end end - def edit - if request.post? and @member.update_attributes(params[:member]) + def update + if params[:membership] + @member.role_ids = params[:membership][:role_ids] + end + if request.put? && @member.save respond_to do |format| format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project } format.js { @@ -79,7 +82,7 @@ class MembersController < ApplicationController end def destroy - if request.post? && @member.deletable? + if request.delete? && @member.deletable? @member.destroy end respond_to do |format| @@ -92,7 +95,7 @@ class MembersController < ApplicationController end end - def autocomplete_for_member + def autocomplete @principals = Principal.active.like(params[:q]).find(:all, :limit => 100) - @project.principals render :layout => false end |