Class: GroupsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#archivesspace, can_access?, permission_mappings, set_access_control

Instance Method Details

#createObject



31
32
33
34
35
# File 'frontend/app/controllers/groups_controller.rb', line 31

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

#current_recordObject



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

def current_record
  @group
end

#deleteObject



55
56
57
58
59
60
# File 'frontend/app/controllers/groups_controller.rb', line 55

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

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

#editObject



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

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

#indexObject



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

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

#newObject



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

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

#showObject



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

def show
  redirect_to :action => :index
end

#updateObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'frontend/app/controllers/groups_controller.rb', line 38

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