修复加入课程逻辑判断有误的问题
This commit is contained in:
parent
27562c3d11
commit
59c143a9f1
|
@ -26,10 +26,13 @@ class CoursesController < ApplicationController
|
|||
def join
|
||||
if User.current.logged?
|
||||
course = Course.find_by_id params[:object_id]
|
||||
unless course
|
||||
@state = 4
|
||||
if course
|
||||
if course_endTime_timeout? course
|
||||
@state = 2
|
||||
else
|
||||
if User.current.member_of_course?(course)
|
||||
@state = 3
|
||||
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)
|
||||
|
@ -39,15 +42,16 @@ class CoursesController < ApplicationController
|
|||
else
|
||||
@state = 1
|
||||
end
|
||||
else
|
||||
@state = 3
|
||||
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