frontend/app/controllers/gaku/class_groups_controller.rb in gaku-0.1.1 vs frontend/app/controllers/gaku/class_groups_controller.rb in gaku-0.2.0
- old
+ new
@@ -1,19 +1,16 @@
module Gaku
class ClassGroupsController < GakuController
- include StudentChooserController
+ # respond_to :js, only: %i( new create destroy recovery )
+ # respond_to :html, only: %i( index edit update soft_delete )
- #respond_to :js, only: %i( new create destroy recovery )
- #respond_to :html, only: %i( index edit update soft_delete )
-
respond_to :html, :js
before_action :set_courses
- before_action :set_class_group, only: %i( edit update destroy student_chooser )
+ before_action :set_class_group, only: %i( edit update destroy )
-
def destroy
@class_group.destroy
set_count
respond_with @class_group
end
@@ -29,11 +26,11 @@
set_count
respond_with @class_group
end
def edit
- @class_group_course_enrollment = ClassGroupCourseEnrollment.new
+ # @class_group_course_enrollment = ClassGroupCourseEnrollment.new
end
def update
@class_group.update(class_group_params)
respond_with @class_group, location: [:edit, @class_group]
@@ -49,27 +46,27 @@
@count = @semesters.count
render :with_semester, layout: 'gaku/layouts/index'
end
def without_semester
- @class_groups = ClassGroup.without_semester.includes(:semester_class_groups)
+ @class_groups = ClassGroup.without_semester.includes(:semester_connectors)
@count = @class_groups.count
render :without_semester, layout: 'gaku/layouts/index'
end
def advanced_search
- @semesters = Semester.with_class_group.collect{|p| [p.to_s, p.id]}
+ @semesters = Semester.with_class_group.map { |p| [p.to_s, p.id] }
@search = ClassGroup.search(params[:q])
results = @search.result(distinct: true)
@class_groups = results.page(params[:page])
end
def semester_advanced_search
@search = Semester.with_class_group.includes(:class_groups).search(params[:q])
results = @search.result(distinct: true)
@semesters = results.page(params[:page])
- @semesters_for_select = Semester.with_class_group.collect{|p| [p.to_s, p.id]}
+ @semesters_for_select = Semester.with_class_group.map { |p| [p.to_s, p.id] }
end
def search_semester
@search = Semester.includes(:class_groups).search(params[:q])
results = @search.result(distinct: true)
@@ -77,19 +74,18 @@
@count = results.count
render :with_semester, layout: 'gaku/layouts/index'
end
def search
- @semesters = Semester.with_class_group.collect{|p| [p.to_s, p.id]}
+ @semesters = Semester.with_class_group.map { |p| [p.to_s, p.id] }
@search = ClassGroup.without_semester.search(params[:q])
results = @search.result(distinct: true)
@class_groups = results.page(params[:page])
@count = results.count
render :without_semester, layout: 'gaku/layouts/index'
end
-
private
def class_group_params
params.require(:class_group).permit(attributes)
end
@@ -99,14 +95,26 @@
end
def set_class_group
@class_group = ClassGroup.find(params[:id])
set_notable
+ set_enrollmentable
+ set_semesterable
end
def set_notable
@notable = @class_group
@notable_resource = get_resource_name @notable
+ end
+
+ def set_enrollmentable
+ @enrollmentable = @class_group
+ @enrollmentable_resource = @enrollmentable.class.to_s.demodulize.underscore.dasherize
+ end
+
+ def set_semesterable
+ @semesterable = @class_group
+ @semesterable_resource = get_resource_name @semesterable
end
def set_count
@count = ClassGroup.count
end