socialforge/app/controllers/org_member_controller.rb

58 lines
1.3 KiB
Ruby
Raw Normal View History

2015-11-12 09:32:00 +08:00
class OrgMemberController < ApplicationController
def org_member_autocomplete
@org = Organization.find(params[:org])
@flag = params[:flag] || false
respond_to do |format|
format.js
end
end
def create
@org = Organization.find(params[:org])
if params[:membership].nil?
@fail_hint = l(:label_blank_user_lists_for_org)
else
member_ids = params[:membership][:user_ids]
role_id = params[:orgRole]
member_ids.each do |user_id|
2015-11-16 15:39:59 +08:00
member = OrgMember.create(:user_id=>user_id, :created_at => Time.now)
@org.org_members << member
OrgMemberRole.create(:org_member_id => member.id, :role_id => role_id)
end
2015-11-12 09:32:00 +08:00
end
respond_to do |format|
format.js
end
end
def update
@member = OrgMember.find(params[:id])
#@member.change_role params[:org_member][:role_ids]
@member_role = @member.org_member_roles[0]
@member_role.role_id = params[:org_member][:role_ids][0]
@member_role.save
@org = @member.organization
respond_to do |format|
format.js
end
end
def new
end
def destroy
member = OrgMember.find(params[:id])
@org = member.organization
member.destroy
respond_to do |format|
format.js
end
end
def index
end
end