From f9e9404471bb9abeaee5b434a4f348fd8f95bdf6 Mon Sep 17 00:00:00 2001 From: yanxd Date: Wed, 19 Mar 2014 15:50:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=87=E6=BB=A4=E5=99=A8=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E5=8A=A0=E5=85=A5=E8=AF=BE=E7=A8=8B=E7=9A=84=E8=A1=8C=E4=B8=BA?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E5=86=8D=E8=BF=9B=E8=A1=8Cn=E5=A4=9A?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 9e8297820..215dd3a58 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -7,20 +7,16 @@ class CoursesController < ApplicationController def join if User.current.logged? course = Project.find(params[:object_id]) - if ( !course_endTime_timeout?(course) ) - course_prefs = Course.find_by_extra(course.identifier) - if params[:course_password] == course_prefs.password + course_prefs = Course.find_by_extra(course.identifier) + if params[:course_password] == course_prefs.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 else - @state = 2 + @state = 1 end end respond_to do |format| @@ -49,7 +45,18 @@ class CoursesController < ApplicationController private def allow_join - course_endTime_timeout? Project.find(params[:object_id]) + if course_endTime_timeout? Project.find(params[:object_id]) + respond_to do |format| + format.js{ + @state = 2 + render :partial => 'set_join', + :locals => {:user => User.current, + :course => Project.find(params[:object_id]), + :object_id => params[:object_id] + } + } + end + end end end \ No newline at end of file