修复加入课程逻辑判断有误的问题
This commit is contained in:
parent
27562c3d11
commit
59c143a9f1
|
@ -26,28 +26,32 @@ class CoursesController < ApplicationController
|
|||
def join
|
||||
if User.current.logged?
|
||||
course = Course.find_by_id params[:object_id]
|
||||
unless course
|
||||
@state = 4
|
||||
else
|
||||
unless (allow_join(course) && User.current.member_of_course?(course))
|
||||
if params[:course_password] == course.password
|
||||
members = []
|
||||
members << Member.new(:role_ids => [10], :user_id => User.current.id)
|
||||
course.members << members
|
||||
StudentsForCourse.create(:student_id => User.current.id, :course_id => params[:object_id])
|
||||
@state = 0
|
||||
else
|
||||
@state = 1
|
||||
end
|
||||
if course
|
||||
if course_endTime_timeout? course
|
||||
@state = 2
|
||||
else
|
||||
@state = 3
|
||||
if User.current.member_of_course?(course)
|
||||
@state = 3
|
||||
else
|
||||
if params[:course_password] == course.password
|
||||
members = []
|
||||
members << Member.new(:role_ids => [10], :user_id => User.current.id)
|
||||
course.members << members
|
||||
StudentsForCourse.create(:student_id => User.current.id, :course_id => params[:object_id])
|
||||
@state = 0
|
||||
else
|
||||
@state = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
@state = 4
|
||||
end
|
||||
else
|
||||
@state = 5
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => Course.find(params[:object_id]), :object_id => params[:object_id]} }
|
||||
format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => course, :object_id => params[:object_id]} }
|
||||
end
|
||||
rescue Exception => e
|
||||
@state = 4
|
||||
|
|
Loading…
Reference in New Issue