Class: InstanceUserRoleRequestsController

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

Instance Method Summary collapse

Methods included from ApplicationSignInCallbacksConcern

#sign_in

Methods included from ApplicationPaginationConcern

#page_param

Methods included from ApplicationAnnouncementsConcern

#global_announcements, #unread_global_announcements

Methods included from ApplicationInstanceUserConcern

#current_instance_user

Methods included from ApplicationUserTimeZoneConcern

#set_time_zone

Methods included from ApplicationUserConcern

#handle_access_denied, #publicly_accessible?

Methods included from ApplicationComponentsConcern

#handle_component_not_found

Instance Method Details

#approveObject


35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/instance_user_role_requests_controller.rb', line 35

def approve
  @user_role_request.assign_attributes(user_role_request_params)

  @success, instance_user = @user_role_request.approve_and_destroy!
  if @success
    InstanceUserRoleRequestMailer.role_request_approved(instance_user).deliver_later
    flash.now[:success] = t('.success', user: instance_user.user.name, role: instance_user.role)
  else
    flash.now[:danger] = instance_user.errors.full_messages.to_sentence
  end
end

#createObject


14
15
16
17
18
19
20
21
22
# File 'app/controllers/instance_user_role_requests_controller.rb', line 14

def create
  @user_role_request.user = current_user
  if @user_role_request.save
    @user_role_request.send_new_request_email(current_tenant)
    redirect_to courses_path, success: t('.success')
  else
    render 'new'
  end
end

#destroyObject


47
48
49
# File 'app/controllers/instance_user_role_requests_controller.rb', line 47

def destroy
  redirect_to instance_user_role_requests_path, success: t('.success') if @user_role_request.destroy
end

#editObject


24
25
# File 'app/controllers/instance_user_role_requests_controller.rb', line 24

def edit
end

#indexObject


5
6
7
8
9
# File 'app/controllers/instance_user_role_requests_controller.rb', line 5

def index
  add_breadcrumb current_tenant.name, :admin_instance_admin_path
  add_breadcrumb :index, :instance_user_role_requests_path
  render layout: 'system_admin_instance'
end

#newObject


11
12
# File 'app/controllers/instance_user_role_requests_controller.rb', line 11

def new
end

#updateObject


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

def update
  if @user_role_request.update(user_role_request_params)
    redirect_to courses_path, success: t('.success')
  else
    render 'edit'
  end
end