Class: EgovUtils::GroupsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/egov_utils/groups_controller.rb

Instance Method Summary collapse

Instance Method Details

#add_usersObject



35
36
37
38
39
40
41
42
43
# File 'app/controllers/egov_utils/groups_controller.rb', line 35

def add_users
  render_404 and return unless @group.allow_member_assign?
  @users = User.active.assignable_to_group(@group).where(:id => (params[:user_id] || params[:user_ids])).to_a
  @group.users << @users
  respond_to do |format|
    format.html { redirect_to group_path(@group) }
    format.json { head :ok }
  end
end

#createObject



15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/egov_utils/groups_controller.rb', line 15

def create
  respond_to do |format|
    if @group.save
      format.html{ redirect_to egov_utils.users_path, notice: t('success_created') }
      format.json{ render json: @group, status: :created }
    else
      format.html{ render 'new' }
      format.json{ render json: @group.errors.full_messages, status: :unprocessable_entity }
    end
  end
end

#indexObject



8
9
10
# File 'app/controllers/egov_utils/groups_controller.rb', line 8

def index
  @groups = EgovUtils::Group.accessible_by(current_ability)
end

#new_usersObject



27
28
29
30
31
32
33
# File 'app/controllers/egov_utils/groups_controller.rb', line 27

def new_users
  @principals = EgovUtils::User.active.assignable_to_group(@group)
  respond_to do |format|
    format.html
    format.js { render_modal_js }
  end
end

#showObject



12
13
# File 'app/controllers/egov_utils/groups_controller.rb', line 12

def show
end