From b7e6725e1fd730c54feba9e6a2e1c409ce542a18 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 15 Jul 2016 14:48:39 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E7=9A=84=E8=AF=BE=E7=A8=8B=E5=90=8D=E7=A7=B0=E5=8F=8C=E5=87=BB?= =?UTF-8?q?=E5=8F=AF=E7=82=B9=E5=87=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 13 ++- .../admin/_rename_syllabus_title.html.erb | 3 + app/views/admin/syllabuses.html.erb | 85 ++++++++++++++----- app/views/admin/update_syllabus_title.js.erb | 1 + app/views/layouts/_syllabus_info.html.erb | 4 +- app/views/layouts/_syllabus_title.html.erb | 2 +- app/views/layouts/base_syllabus.html.erb | 20 +++-- .../syllabuses/edit_syllabus_title.js.erb | 1 + config/routes.rb | 1 + public/javascripts/syllabus.js | 35 +++++--- 10 files changed, 121 insertions(+), 44 deletions(-) create mode 100644 app/views/admin/_rename_syllabus_title.html.erb create mode 100644 app/views/admin/update_syllabus_title.js.erb diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 36a5d9d4f..6c62c642a 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -96,7 +96,7 @@ class AdminController < ApplicationController def courses @name = params[:name].to_s.strip.downcase if @name && @name != "" - @courses = Course.select{ |course| (course.teacher[:lastname].to_s.downcase + course.teacher[:firstname].to_s.downcase).include?(@name) || course.name.include?(@name)} + @courses = Course.select{ |course| course.teacher && ((course.teacher.show_name).include?(@name) || course.name.include?(@name))} @courses = @courses.sort{|x, y| y.created_at <=> x.created_at} else @courses = Course.order('created_at desc') @@ -135,6 +135,17 @@ class AdminController < ApplicationController end end + #修改课程名称 + def update_syllabus_title + @syllabus = Syllabus.where("id = #{params[:syllabus_id].to_i}").first + unless @syllabus.nil? + @syllabus.update_column("title", params[:name]) + respond_to do |format| + format.js + end + end + end + #管理员界面精品课程列表 def excellent_courses @courses = Course.where("is_excellent =? or excellent_option =?", 1, 1 ) diff --git a/app/views/admin/_rename_syllabus_title.html.erb b/app/views/admin/_rename_syllabus_title.html.erb new file mode 100644 index 000000000..e3a175215 --- /dev/null +++ b/app/views/admin/_rename_syllabus_title.html.erb @@ -0,0 +1,3 @@ + + <%= syllabus.title %> + \ No newline at end of file diff --git a/app/views/admin/syllabuses.html.erb b/app/views/admin/syllabuses.html.erb index 782f6b01c..194091abc 100644 --- a/app/views/admin/syllabuses.html.erb +++ b/app/views/admin/syllabuses.html.erb @@ -46,10 +46,8 @@ <%= syllabus.id %> - - - <%= link_to(syllabus.title, syllabus_path(syllabus.id)) %> - + + <%= render :partial => 'admin/rename_syllabus_title', :locals => {:syllabus => syllabus} %> @@ -89,23 +87,24 @@