Class: Course::UserInvitationsController

Inherits:
ComponentController show all
Defined in:
app/controllers/course/user_invitations_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

#createObject


16
17
18
19
20
21
22
23
24
# File 'app/controllers/course/user_invitations_controller.rb', line 16

def create
  result = invite
  if result
    redirect_to course_user_invitations_path(current_course), success: create_success_message(*result)
  else
    propagate_errors
    render 'new'
  end
end

#destroyObject


26
27
28
29
30
31
32
33
34
# File 'app/controllers/course/user_invitations_controller.rb', line 26

def destroy
  if @invitation.destroy
    redirect_to course_user_invitations_path(current_course),
                success: t('.success', name: @invitation.name)
  else
    redirect_to course_user_invitations_path(current_course),
                danger: @invitation.errors.full_messages.to_sentence
  end
end

#indexObject


8
9
10
# File 'app/controllers/course/user_invitations_controller.rb', line 8

def index
  @invitations = current_course.invitations.order(name: :asc)
end

#newObject


12
13
14
# File 'app/controllers/course/user_invitations_controller.rb', line 12

def new
  current_course.invitations.build
end

#resend_invitationObject


36
37
38
39
40
41
42
43
44
# File 'app/controllers/course/user_invitations_controller.rb', line 36

def resend_invitation
  @invitation = load_invitations.first
  if @invitation && invitation_service.resend_invitation(load_invitations)
    flash.now[:success] = t('.success', email: @invitation.email)
  else
    flash.now[:danger] = t('.failure')
  end
  render 'reload_course_user_invitation'
end

#resend_invitationsObject


46
47
48
49
50
51
52
# File 'app/controllers/course/user_invitations_controller.rb', line 46

def resend_invitations
  if invitation_service.resend_invitation(load_invitations)
    redirect_to course_user_invitations_path(current_course), success: t('.success')
  else
    redirect_to course_user_invitations_path(current_course), danger: t('.failure')
  end
end

#toggle_registrationObject


54
55
56
57
58
59
60
61
62
# File 'app/controllers/course/user_invitations_controller.rb', line 54

def toggle_registration
  if enable_registration_code(registration_params)
    redirect_to invite_course_users_path(current_course, anchor: 'registration_code'),
                success: t('.success')
  else
    redirect_to invite_course_users_path(current_course, anchor: 'registration_code'),
                danger: t('.failure')
  end
end