From f55d8fe3033bad20c4ed11804e4b4ae3b89f450f Mon Sep 17 00:00:00 2001 From: z9hang Date: Mon, 5 Jan 2015 16:58:11 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E6=AD=A3=E6=96=B0=E5=BB=BA?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=8E=A5=E5=8F=A3=E6=97=A0=E6=95=88=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E3=80=822=E3=80=81=E4=BF=AE=E6=AD=A3=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=E8=AF=BE=E7=A8=8B=E6=8E=A5=E5=8F=A3=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE=E4=B8=AD=E8=AF=BE=E7=A8=8B=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course.rb | 4 ++-- app/services/courses_service.rb | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/models/course.rb b/app/models/course.rb index ef42d91e8..30bbaeba3 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -207,8 +207,8 @@ class Course < ActiveRecord::Base # 创建课程讨论区 def create_board_sync @board = self.boards.build - self.name=" #{l(:label_borad_course) }" - @board.name = self.name + #self.name=" #{l(:label_borad_course) }" + @board.name = " #{l(:label_borad_course) }"#self.name @board.description = self.name.to_s @board.project_id = -1 if @board.save diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index d1b5e8be5..3f025c892 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -122,16 +122,17 @@ class CoursesService #params[:setup_time]:暂不传(貌似已经没用了) #params[:endup_time]: 暂不传(貌似已经没用了) #params[:class_period]:学时总数 - def create_course params,current_user + def create_course(params,current_user) if current_user.user_extensions.identity @course = Course.new @course.extra = 'course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s - @course.safe_attributes = params[:course],current_user - @course.tea_id = User.current.id + @course.send(:safe_attributes=, params[:course], current_user) + #@course.safe_attributes(current_user,params[:course]) + @course.tea_id = current_user.id @course.term = params[:term] @course.time = params[:time] #@course.school_id = params[:occupation] - @course.school_id = User.current.user_extensions.school_id + @course.school_id = current_user.user_extensions.school_id @course.setup_time = params[:setup_time] @course.endup_time = params[:endup_time] @course.class_period = params[:class_period] @@ -143,9 +144,9 @@ class CoursesService if @course.save #unless User.current.admin? r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first - m = Member.new(:user => User.current, :roles => [r]) + m = Member.new(:user => current_user, :roles => [r]) m.project_id = -1 - course = CourseInfos.new(:user_id => User.current.id, :course_id => @course.id) + course = CourseInfos.new(:user_id => current_user.id, :course_id => @course.id) #user_grades = UserGrade.create(:user_id => User.current.id, :course_id => @course.id) if params[:course][:is_public] == '1' course_status = CourseStatus.create(:course_id => @course.id, :watchers_count => 0, :changesets_count => 0, :grade => 0, :course_type => @course_tag)