项目和课程中加入组织时,如果已经加入了某组织,就不要重复加入。
This commit is contained in:
parent
a3146c66ae
commit
2dc31637d8
|
@ -3,7 +3,9 @@ class OrgCoursesController < ApplicationController
|
|||
org_ids = params[:orgNames]
|
||||
@course = Course.find(params[:course_id])
|
||||
org_ids.each do |org_id|
|
||||
OrgCourse.create(:organization_id => org_id.to_i, :course_id => params[:course_id].to_i, :created_at => Time.now)
|
||||
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
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
|
|
|
@ -3,7 +3,9 @@ class OrgProjectsController < ApplicationController
|
|||
org_ids = params[:orgNames]
|
||||
@project = Project.find(params[:project_id])
|
||||
org_ids.each do |org_id|
|
||||
OrgProject.create(:organization_id => org_id.to_i, :project_id => params[:project_id].to_i, :created_at => Time.now)
|
||||
if OrgProject.where("organization_id =? and project_id =?", org_id.to_i, @project.id).count == 0
|
||||
OrgProject.create(:organization_id => org_id.to_i, :project_id => params[:project_id].to_i, :created_at => Time.now)
|
||||
end
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
|
|
Loading…
Reference in New Issue