You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
class Admins::CoursesController < Admins::BaseController
|
|
|
|
before_action :find_course, except: [:index]
|
|
|
|
|
|
|
|
def index
|
|
|
|
default_sort('created_at', 'desc')
|
|
|
|
|
|
|
|
courses = Admins::CourseQuery.call(params)
|
|
|
|
@ended_courses = courses.where(is_end: 1).size
|
|
|
|
@processed_courses = courses.where(is_end: 0).size
|
|
|
|
@courses = paginate courses.includes(:school, :students, :attachments, :homework_commons, teacher: :user_extension)
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
if @course.is_delete == 0
|
|
|
|
@course.delete!
|
|
|
|
Tiding.create!(user_id: current_user.id, trigger_user_id: current_user.id, container_id: @course.id,
|
|
|
|
container_type: 'DeleteCourse', tiding_type: 'System', belong_container: @course, extra: @course.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def find_course
|
|
|
|
@course = Course.find_by!(id: params[:id])
|
|
|
|
end
|
|
|
|
end
|