2013-06-17 13:51:43 +00:00
|
|
|
class UsersGroupsController < ApplicationController
|
|
|
|
before_filter :group
|
|
|
|
|
|
|
|
# Authorize
|
|
|
|
before_filter :authorize_admin_group!
|
|
|
|
|
|
|
|
layout 'group'
|
|
|
|
|
|
|
|
def create
|
|
|
|
@group.add_users(params[:user_ids].split(','), params[:group_access])
|
|
|
|
|
2013-07-12 16:01:39 +00:00
|
|
|
redirect_to members_group_path(@group), notice: 'Users were successfully added.'
|
2013-06-17 13:51:43 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2013-08-06 15:45:45 +00:00
|
|
|
@member = @group.users_groups.find(params[:id])
|
|
|
|
@member.update_attributes(params[:users_group])
|
2013-06-17 13:51:43 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@users_group = @group.users_groups.find(params[:id])
|
2013-09-26 07:28:43 +00:00
|
|
|
@users_group.destroy
|
2013-06-17 13:51:43 +00:00
|
|
|
|
|
|
|
respond_to do |format|
|
2013-07-12 16:01:39 +00:00
|
|
|
format.html { redirect_to members_group_path(@group), notice: 'User was successfully removed from group.' }
|
2013-06-17 13:51:43 +00:00
|
|
|
format.js { render nothing: true }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def group
|
2014-01-19 18:55:59 +00:00
|
|
|
@group ||= Group.find_by(path: params[:group_id])
|
2013-06-17 13:51:43 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def authorize_admin_group!
|
|
|
|
unless can?(current_user, :manage_group, group)
|
|
|
|
return render_404
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|