From a6d88c6a6f0eea73c592c61a07457cc2124c93fe Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 13 Aug 2019 15:20:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E8=B7=B5=E8=AF=BE=E7=A8=8B=E7=9A=84?= =?UTF-8?q?=E9=87=91=E8=AF=BE=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/managements_controller.rb | 8 ++++++++ app/models/subject.rb | 2 +- app/views/managements/_subject_list.html.erb | 17 +++++++++++++++-- .../excellent_subject_setting.js.erb | 0 config/routes.rb | 1 + .../20190813070926_add_excellent_to_subject.rb | 5 +++++ 6 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 app/views/managements/excellent_subject_setting.js.erb create mode 100644 db/migrate/20190813070926_add_excellent_to_subject.rb diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index d946c12b..cc896ef2 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -2360,6 +2360,14 @@ end end end + # 实践课程的金课设置 + def excellent_subject_setting + if params[:subject_id] + subject = Subject.find params[:subject_id] + subject.update_attributes(:excellent => !subject.excellent) + end + end + # 已发布实训路径首页显示 def subject_homepage_show if params[:subject_id] diff --git a/app/models/subject.rb b/app/models/subject.rb index 819d446c..77db603a 100644 --- a/app/models/subject.rb +++ b/app/models/subject.rb @@ -10,7 +10,7 @@ class Subject < ActiveRecord::Base belongs_to :major # score_count 只能适合在首页使用 attr_accessible :description, :name, :status, :visits, :user_id, :course_list_id, :major_id, :learning_notes, :introduction, - :homepage_show, :score_count, :publish_time, :updated_at + :homepage_show, :score_count, :publish_time, :updated_at, :excellent has_many :stages, :dependent => :destroy, :order => "stages.position ASC" has_many :stage_shixuns, :dependent => :destroy diff --git a/app/views/managements/_subject_list.html.erb b/app/views/managements/_subject_list.html.erb index 40a3b0c4..3299af10 100644 --- a/app/views/managements/_subject_list.html.erb +++ b/app/views/managements/_subject_list.html.erb @@ -3,7 +3,7 @@ ID - 实训套件名称 + 实训套件名称 阶段 技术体系 等级体系 @@ -75,6 +75,10 @@ value="<%= c_shixun.id %>" <%= c_shixun.homepage_show ? "checked" : "" %> class="ml-3 mr5 magic-checkbox" id="homepage_show_<%= c_shixun.id %>"> + + value="<%= c_shixun.id %>" <%= c_shixun.excellent ? "checked" : "" %> class="ml-3 mr5 magic-checkbox" id="excellent_<%= c_shixun.id %>"> + + <% end %> @@ -131,7 +135,16 @@ type: 'post', dateType: "script" }); - }) + }); + $("input[name='excellent']").click(function(){ + var subject_id = $(this).val(); + $.ajax({ + url:"<%= excellent_subject_setting_managements_path %>", + data: {subject_id: subject_id}, + type: 'post', + dateType: "script" + }); + }); }); function select_repertoire(subject_id, rep_id){ $.ajax({ diff --git a/app/views/managements/excellent_subject_setting.js.erb b/app/views/managements/excellent_subject_setting.js.erb new file mode 100644 index 00000000..e69de29b diff --git a/config/routes.rb b/config/routes.rb index 2524e928..22ea0bc4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -626,6 +626,7 @@ RedmineApp::Application.routes.draw do ## oauth相关 post 'update_shixun_code_hidden' get 'update_shixun_excute_time' post 'subject_homepage_show' + post 'excellent_subject_setting' post 'support_shixun' post 'add_course' match 'add_major',:via=>[:get,:post] diff --git a/db/migrate/20190813070926_add_excellent_to_subject.rb b/db/migrate/20190813070926_add_excellent_to_subject.rb new file mode 100644 index 00000000..6da01be3 --- /dev/null +++ b/db/migrate/20190813070926_add_excellent_to_subject.rb @@ -0,0 +1,5 @@ +class AddExcellentToSubject < ActiveRecord::Migration + def change + add_column :subjects, :excellent, :boolean, :default => false + end +end