Class: GroupsController

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

Instance Method Summary (collapse)

Methods inherited from ApplicationController

can_access?, permission_mappings, set_access_control

Instance Method Details

- (Object) create



26
27
28
29
30
# File 'frontend/app/controllers/groups_controller.rb', line 26

def create
  handle_crud(:instance => :group,
              :on_invalid => ->(){ render :action => "new" },
              :on_valid => ->(id){ redirect_to(:controller => :groups, :action => :index) })
end

- (Object) delete



50
51
52
53
54
55
# File 'frontend/app/controllers/groups_controller.rb', line 50

def delete
  group = JSONModel(:group).find(params[:id])
  group.delete

  redirect_to(:controller => :groups, :action => :index, :deleted_uri => group.uri)
end

- (Object) edit



21
22
23
# File 'frontend/app/controllers/groups_controller.rb', line 21

def edit
  @group = JSONModel(:group).find(params[:id])
end

- (Object) index



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

def index
  @groups = JSONModel(:group).all
end

- (Object) new



6
7
8
# File 'frontend/app/controllers/groups_controller.rb', line 6

def new
  @group = JSONModel(:group).new._always_valid!
end

- (Object) show



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

def show
  redirect_to :action => :index
end

- (Object) update



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'frontend/app/controllers/groups_controller.rb', line 33

def update
  params[:group][:grants_permissions] ||= []
  params[:group][:member_usernames] ||= []

  handle_crud(:instance => :group,
              :model => Accession,
              :obj => JSONModel(:group).find(params[:id]),
              :replace => false,
              :on_invalid => ->(){
                return render :action => "edit"
              },
              :on_valid => ->(id){
                redirect_to(:controller => :groups, :action => :index)
              })
end