修改编辑课程接口

This commit is contained in:
z9hang 2015-01-05 17:47:04 +08:00
parent f55d8fe303
commit f252438f85
3 changed files with 7 additions and 5 deletions

View File

@ -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

View File

@ -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 {

View File

@ -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]