Class: Course::GroupsController

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

:nodoc:


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

def create #:nodoc:
  if @group.save
    redirect_to edit_course_group_path(current_course, @group),
                success: t('.success', name: @group.name)
  else
    render 'new'
  end
end

#destroyObject

:nodoc


38
39
40
41
42
43
44
45
# File 'app/controllers/course/groups_controller.rb', line 38

def destroy #:nodoc
  if @group.destroy
    redirect_to course_groups_path(current_course),
                success: t('.success', name: @group.name)
  else
    redirect_to course_groups_path, danger: @group.errors.full_messages.to_sentence
  end
end

#editObject

:nodoc:


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

def edit #:nodoc:
end

#indexObject

:nodoc:


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

def index #:nodoc:
  @groups = @groups.ordered_by_name.includes(group_users: { course_user: :course })
end

#newObject

:nodoc:


15
16
# File 'app/controllers/course/groups_controller.rb', line 15

def new #:nodoc:
end

#showObject

:nodoc:


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

def show #:nodoc:
  @group_users = @group.group_users.includes(:course_user)
  @group_managers, @group_users = @group_users.partition(&:manager?)
end

#updateObject

:nodoc:


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

def update #:nodoc:
  if @group.update_attributes(group_params)
    redirect_to course_groups_path(current_course), success: t('.success', name: @group.name)
  else
    render 'edit'
  end
end