This commit is contained in:
guange 2015-01-05 17:45:14 +08:00
commit a3ed599d49
5 changed files with 1356 additions and 1350 deletions

View File

@ -31,7 +31,9 @@ module Mobile
mount Apis::Watches mount Apis::Watches
mount Apis::Upgrade mount Apis::Upgrade
add_swagger_documentation ({api_version: 'v1', base_path: 'http://u06.shellinfo.cn/trustie/api'}) #add_swagger_documentation ({api_version: 'v1', base_path: 'http://u06.shellinfo.cn/trustie/api'})
add_swagger_documentation ({api_version: 'v1', base_path: '/api'})
end end
end end

View File

@ -37,7 +37,7 @@ module Mobile
requires :is_public, type: Integer, desc: '是否公开 1公开 0私有' requires :is_public, type: Integer, desc: '是否公开 1公开 0私有'
requires :open_student, type: Integer, desc: '是否公开学生列表1公开0不公开不公开时非课程成员无法看到学生列表' requires :open_student, type: Integer, desc: '是否公开学生列表1公开0不公开不公开时非课程成员无法看到学生列表'
requires :course_type, type:Integer, desc: '暂时传1' requires :course_type, type:Integer, desc: '暂时传1'
requires :term, type: String, desc: '学期(秋秀学期或春秀学期)' requires :term, type: String, desc: '学期(秋季学期或春季学期)'
requires :time, type: String, desc: '年份' requires :time, type: String, desc: '年份'
requires :class_period, type: String, desc: '学时总数' requires :class_period, type: String, desc: '学时总数'
end end

View File

@ -207,8 +207,8 @@ class Course < ActiveRecord::Base
# 创建课程讨论区 # 创建课程讨论区
def create_board_sync def create_board_sync
@board = self.boards.build @board = self.boards.build
self.name=" #{l(:label_borad_course) }" #self.name=" #{l(:label_borad_course) }"
@board.name = self.name @board.name = " #{l(:label_borad_course) }"#self.name
@board.description = self.name.to_s @board.description = self.name.to_s
@board.project_id = -1 @board.project_id = -1
if @board.save if @board.save

View File

@ -122,16 +122,17 @@ class CoursesService
#params[:setup_time]:暂不传(貌似已经没用了) #params[:setup_time]:暂不传(貌似已经没用了)
#params[:endup_time]: 暂不传(貌似已经没用了) #params[:endup_time]: 暂不传(貌似已经没用了)
#params[:class_period]:学时总数 #params[:class_period]:学时总数
def create_course params,current_user def create_course(params,current_user)
if current_user.user_extensions.identity if current_user.user_extensions.identity
@course = Course.new @course = Course.new
@course.extra = 'course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s @course.extra = 'course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s
@course.safe_attributes = params[:course] @course.send(:safe_attributes=, params[:course], current_user)
@course.tea_id = User.current.id #@course.safe_attributes(current_user,params[:course])
@course.tea_id = current_user.id
@course.term = params[:term] @course.term = params[:term]
@course.time = params[:time] @course.time = params[:time]
#@course.school_id = params[:occupation] #@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.setup_time = params[:setup_time]
@course.endup_time = params[:endup_time] @course.endup_time = params[:endup_time]
@course.class_period = params[:class_period] @course.class_period = params[:class_period]
@ -143,9 +144,9 @@ class CoursesService
if @course.save if @course.save
#unless User.current.admin? #unless User.current.admin?
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first 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 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) #user_grades = UserGrade.create(:user_id => User.current.id, :course_id => @course.id)
if params[:course][:is_public] == '1' 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) course_status = CourseStatus.create(:course_id => @course.id, :watchers_count => 0, :changesets_count => 0, :grade => 0, :course_type => @course_tag)

File diff suppressed because it is too large Load Diff