Class: Admin::GroupsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/admin/groups_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject


23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/admin/groups_controller.rb', line 23

def create
  @group = Group.new(group_params)
  @group.name = @group.path.dup unless @group.name

  if @group.save
    @group.add_owner(current_user)
    redirect_to [:admin, @group], notice: 'Group was successfully created.'
  else
    render "new"
  end
end

#destroyObject


49
50
51
52
53
# File 'app/controllers/admin/groups_controller.rb', line 49

def destroy
  DestroyGroupService.new(@group, current_user).execute

  redirect_to admin_groups_path, notice: 'Group was successfully deleted.'
end

#editObject


20
21
# File 'app/controllers/admin/groups_controller.rb', line 20

def edit
end

#indexObject


4
5
6
7
8
9
# File 'app/controllers/admin/groups_controller.rb', line 4

def index
  @groups = Group.all
  @groups = @groups.sort(@sort = params[:sort])
  @groups = @groups.search(params[:name]) if params[:name].present?
  @groups = @groups.page(params[:page])
end

#members_updateObject


43
44
45
46
47
# File 'app/controllers/admin/groups_controller.rb', line 43

def members_update
  @group.add_users(params[:user_ids].split(','), params[:access_level], current_user)

  redirect_to [:admin, @group], notice: 'Users were successfully added.'
end

#newObject


16
17
18
# File 'app/controllers/admin/groups_controller.rb', line 16

def new
  @group = Group.new
end

#showObject


11
12
13
14
# File 'app/controllers/admin/groups_controller.rb', line 11

def show
  @members = @group.members.order("access_level DESC").page(params[:members_page])
  @projects = @group.projects.page(params[:projects_page])
end

#updateObject


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

def update
  if @group.update_attributes(group_params)
    redirect_to [:admin, @group], notice: 'Group was successfully updated.'
  else
    render "edit"
  end
end