修改编辑课程接口
This commit is contained in:
parent
f55d8fe303
commit
f252438f85
|
@ -65,12 +65,13 @@ module Mobile
|
|||
requires :is_public, type: Integer, desc: '是否公开 1公开 0私有'
|
||||
requires :open_student, type: Integer, desc: '是否公开学生列表1公开,0不公开,不公开时非课程成员无法看到学生列表'
|
||||
requires :course_type, type:Integer, desc: '暂时传1'
|
||||
requires :term, type: String, desc: '学期(秋秀学期或春秀学期)'
|
||||
requires :term, type: String, desc: '学期(秋季学期或春季学期)'
|
||||
requires :time, type: String, desc: '年份'
|
||||
requires :class_period, type: String, desc: '学时总数'
|
||||
end
|
||||
post do
|
||||
authenticate!
|
||||
cs = CoursesService.new
|
||||
cs_params = {
|
||||
course: params.reject{|k,v| [:term,:time,:class_period].include?(k)},
|
||||
term: params[:term],
|
||||
|
@ -79,7 +80,7 @@ module Mobile
|
|||
}
|
||||
course = ::Course.find(params[:course_id])
|
||||
cs.edit_course_authorize(current_user,course)
|
||||
course = cs.edit_course(cs_params, course)
|
||||
course = cs.edit_course(cs_params, course,current_user)
|
||||
present :data, course, with: Mobile::Entities::Course
|
||||
present :status, 0
|
||||
end
|
||||
|
|
|
@ -95,7 +95,7 @@ class CoursesController < ApplicationController
|
|||
#更新课程信息
|
||||
def update
|
||||
cs = CoursesService.new
|
||||
@course = cs.edit_course params,@course
|
||||
@course = cs.edit_course params,@course,User.current
|
||||
if @course.errors.full_messages.count <= 0
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
|
|
|
@ -175,8 +175,9 @@ class CoursesService
|
|||
#params[:term]:学期(秋季学期或春季学期)
|
||||
#params[:time]: 年份(例:2014)
|
||||
#params[:class_period]:学时总数
|
||||
def edit_course params,course
|
||||
course.safe_attributes = params[:course]
|
||||
def edit_course(params,course,current_user)
|
||||
course.send(:safe_attributes=, params[:course], current_user)
|
||||
#course.safe_attributes = params[:course]
|
||||
course.time = params[:time]
|
||||
course.term = params[:term]
|
||||
course.class_period = params[:class_period]
|
||||
|
|
Loading…
Reference in New Issue