修复加入课程逻辑判断有误的问题
This commit is contained in:
parent
27562c3d11
commit
59c143a9f1
|
@ -26,10 +26,13 @@ class CoursesController < ApplicationController
|
||||||
def join
|
def join
|
||||||
if User.current.logged?
|
if User.current.logged?
|
||||||
course = Course.find_by_id params[:object_id]
|
course = Course.find_by_id params[:object_id]
|
||||||
unless course
|
if course
|
||||||
@state = 4
|
if course_endTime_timeout? course
|
||||||
|
@state = 2
|
||||||
|
else
|
||||||
|
if User.current.member_of_course?(course)
|
||||||
|
@state = 3
|
||||||
else
|
else
|
||||||
unless (allow_join(course) && User.current.member_of_course?(course))
|
|
||||||
if params[:course_password] == course.password
|
if params[:course_password] == course.password
|
||||||
members = []
|
members = []
|
||||||
members << Member.new(:role_ids => [10], :user_id => User.current.id)
|
members << Member.new(:role_ids => [10], :user_id => User.current.id)
|
||||||
|
@ -39,15 +42,16 @@ class CoursesController < ApplicationController
|
||||||
else
|
else
|
||||||
@state = 1
|
@state = 1
|
||||||
end
|
end
|
||||||
else
|
|
||||||
@state = 3
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
@state = 4
|
||||||
|
end
|
||||||
else
|
else
|
||||||
@state = 5
|
@state = 5
|
||||||
end
|
end
|
||||||
respond_to do |format|
|
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
|
end
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
@state = 4
|
@state = 4
|
||||||
|
|
Loading…
Reference in New Issue