Module: Course::UsersControllerManagementConcern

Extended by:
ActiveSupport::Concern
Included in:
UsersController
Defined in:
app/controllers/concerns/course/users_controller_management_concern.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject

:nodoc:


18
19
20
21
22
23
24
25
26
# File 'app/controllers/concerns/course/users_controller_management_concern.rb', line 18

def destroy # :nodoc:
  if @course_user.destroy
    success = t('course.users.destroy.success', role: @course_user.role,
                                                email: @course_user.user.email)
    redirect_to delete_redirect_path, success: success
  else
    redirect_to delete_redirect_path, danger: @course_user.errors.full_messages.to_sentence
  end
end

#staffObject

:nodoc:


32
33
34
35
# File 'app/controllers/concerns/course/users_controller_management_concern.rb', line 32

def staff # :nodoc:
  @student_options = @course_users.students.order_alphabetically.pluck(:name, :id)
  @course_users = @course_users.staff.includes(user: :emails).order_alphabetically
end

#studentsObject

:nodoc:


28
29
30
# File 'app/controllers/concerns/course/users_controller_management_concern.rb', line 28

def students # :nodoc:
  @course_users = @course_users.students.includes(user: :emails).order_alphabetically
end

#updateObject

:nodoc:


10
11
12
13
14
15
16
# File 'app/controllers/concerns/course/users_controller_management_concern.rb', line 10

def update # :nodoc:
  if @course_user.update(course_user_params)
    flash.now[:success] = t('course.users.update.success', name: @course_user.name)
  else
    flash.now[:danger] = @course_user.errors.full_messages.to_sentence
  end
end

#upgrade_to_staffObject

:nodoc:


37
38
39
40
41
42
43
# File 'app/controllers/concerns/course/users_controller_management_concern.rb', line 37

def upgrade_to_staff # :nodoc:
  if @course_user.update(upgrade_to_staff_params)
    upgrade_to_staff_success
  else
    upgrade_to_staff_failure
  end
end