2015-11-17 17:34:50 +08:00
|
|
|
class OrgCoursesController < ApplicationController
|
|
|
|
def create
|
|
|
|
org_ids = params[:orgNames]
|
|
|
|
@course = Course.find(params[:course_id])
|
|
|
|
org_ids.each do |org_id|
|
2015-11-24 17:29:58 +08:00
|
|
|
if OrgCourse.where("organization_id =? and course_id =?", org_id.to_i, params[:course_id].to_i).count == 0
|
|
|
|
OrgCourse.create(:organization_id => org_id.to_i, :course_id => params[:course_id].to_i, :created_at => Time.now)
|
|
|
|
end
|
2015-11-17 17:34:50 +08:00
|
|
|
end
|
|
|
|
respond_to do |format|
|
|
|
|
format.js
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@course = Course.find(params[:course_id])
|
|
|
|
@org_course = OrgCourse.find(params[:id])
|
|
|
|
@org_course.destroy
|
|
|
|
end
|
|
|
|
end
|