From 59c143a9f18e58af3d500addba65fa1e1fd8226b Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 22 Oct 2014 13:56:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8A=A0=E5=85=A5=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E9=80=BB=E8=BE=91=E5=88=A4=E6=96=AD=E6=9C=89=E8=AF=AF?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 34 +++++++++++++++------------ 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 089960e76..8402c05f0 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -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