This instance was upgraded to Heptapod 0.31.0 (final) today.

groups_controller.rb 1.25 KB
Newer Older
1
class Admin::GroupsController < Admin::ApplicationController
2
  before_filter :group, only: [:edit, :show, :update, :destroy, :project_update, :project_teams_update]
3
4

  def index
5
    @groups = Group.order('name ASC')
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
    @groups = @groups.search(params[:name]) if params[:name].present?
    @groups = @groups.page(params[:page]).per(20)
  end

  def show
  end

  def new
    @group = Group.new
  end

  def edit
  end

  def create
    @group = Group.new(params[:group])
22
    @group.path = @group.name.dup.parameterize if @group.name
23
24

    if @group.save
25
      @group.add_owner(current_user)
26
27
      redirect_to [:admin, @group], notice: 'Group was successfully created.'
    else
28
      render "new"
29
30
31
32
    end
  end

  def update
33
    if @group.update_attributes(params[:group])
34
35
      redirect_to [:admin, @group], notice: 'Group was successfully updated.'
    else
36
      render "edit"
37
38
39
    end
  end

40
  def project_teams_update
41
    @group.add_users(params[:user_ids].split(','), params[:group_access])
42

Kyle Kelley's avatar
Kyle Kelley committed
43
    redirect_to [:admin, @group], notice: 'Users were successfully added.'
44
45
  end

46
47
48
  def destroy
    @group.destroy

randx's avatar
randx committed
49
    redirect_to admin_groups_path, notice: 'Group was successfully deleted.'
50
51
52
53
54
  end

  private

  def group
skv's avatar
skv committed
55
    @group = Group.find_by(path: params[:id])
56
57
  end
end