diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 50f97bc8..960d2ef4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -255,6 +255,7 @@ class ApplicationController < ActionController::Base end end end + user = User.find 57703 user end diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 46be2ef4..65a8f2f9 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -886,6 +886,8 @@ class AttachmentsController < ApplicationController @shixun elsif @attachment.container_type == 'Inform' @inform = @attachment.container + elsif @attachment.container_type == 'CompetitionModuleMdContent' + @md_content = @attachment.container elsif @attachment.container_type == 'Challenge' @challenge = @attachment.container elsif @attachment.container_type == 'Competition' diff --git a/app/controllers/competitions_controller.rb b/app/controllers/competitions_controller.rb index cd3a9ef6..3b438e06 100644 --- a/app/controllers/competitions_controller.rb +++ b/app/controllers/competitions_controller.rb @@ -89,7 +89,9 @@ class CompetitionsController < ApplicationController def create_md_content md_content = CompetitionModuleMdContent.find params[:md_content_id] md_content.update_attributes(params[:md_content]) - md_content.save_attachments(params[:attachments]) + attachment_ids = params[:attachments].values.map{|a| a[:attachment_id]}.compact + Attachment.where(:id => attachment_ids) + .update_all(container_id: md_content.id, container_type: 'CompetitionModuleMdContent') if attachment_ids redirect_to md_contents_competition_url(:md_content_id => md_content.id) end @@ -103,7 +105,9 @@ class CompetitionsController < ApplicationController def update_md_content md_content = CompetitionModuleMdContent.find params[:md_content_id] md_content.update_attributes(params[:md_content]) - md_content.save_attachments(params[:attachments]) + attachment_ids = params[:attachments].values.map{|a| a[:attachment_id]}.compact + Attachment.where(:id => attachment_ids) + .update_all(container_id: md_content.id, container_type: 'CompetitionModuleMdContent') if attachment_ids redirect_to md_content_competitions_path(:md_content_id => md_content.id) end diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index b766ad07..c4bfeb3f 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -2319,6 +2319,13 @@ end @subject.update_column(:hidden, !@subject.hidden) end + def update_subject_member_count + if params[:subject] && params[:member_count] + @subject = Subject.where(:id => params[:subject]).first + @subject.update_attributes(:student_count => params[:member_count]) if @subject.present? + end + end + # 已发布课程实训 def class_publish_shixuns @menu_type = 4 diff --git a/app/models/competition_module_md_content.rb b/app/models/competition_module_md_content.rb index a88e892c..4653f112 100644 --- a/app/models/competition_module_md_content.rb +++ b/app/models/competition_module_md_content.rb @@ -1,6 +1,7 @@ class CompetitionModuleMdContent < ActiveRecord::Base # attr_accessible :title, :body belongs_to :competition_module + has_many :attachments, :dependent => :destroy acts_as_attachable end diff --git a/app/models/subject.rb b/app/models/subject.rb index 77db603a..f4eaaad8 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, :excellent + :homepage_show, :score_count, :publish_time, :updated_at, :excellent, :student_count has_many :stages, :dependent => :destroy, :order => "stages.position ASC" has_many :stage_shixuns, :dependent => :destroy diff --git a/app/views/competitions/_ccf_competition.html.erb b/app/views/competitions/_ccf_competition.html.erb index 36429708..284bc1a4 100644 --- a/app/views/competitions/_ccf_competition.html.erb +++ b/app/views/competitions/_ccf_competition.html.erb @@ -11,6 +11,12 @@ 使用说明
++ <% com_module_3 = @competition.competition_modules.where(:hidden => 0, :name => '案例提交要求').first %> + 案例提交要求 +
+ID | -实训套件名称 | +ID | +实训套件名称 | 阶段 | 技术体系 | 等级体系 | @@ -11,6 +11,7 @@创建者 | 创建时间 color-light-green ml5"> | 操作 | +开课人数 | + + | <% end %> @@ -168,4 +175,11 @@ }); } + + function editMemberCount(subject_id){ + var htmlvalue = "<%= escape_javascript(render :partial => 'managements/subject_member_count') %>"; + pop_box_new(htmlvalue,400,204); + $("#update_subject_member_count_id").val(subject_id); + $("input[name='member_count']").val($("#subject_member_count_"+subject_id).html().trim()); + } diff --git a/app/views/managements/_subject_member_count.html.erb b/app/views/managements/_subject_member_count.html.erb new file mode 100644 index 00000000..87234591 --- /dev/null +++ b/app/views/managements/_subject_member_count.html.erb @@ -0,0 +1,15 @@ + \ No newline at end of file diff --git a/app/views/managements/update_subject_member_count.js.erb b/app/views/managements/update_subject_member_count.js.erb new file mode 100644 index 00000000..3fa0565e --- /dev/null +++ b/app/views/managements/update_subject_member_count.js.erb @@ -0,0 +1 @@ +$("#subject_member_count_<%= @subject.id %>").html("<%= params[:member_count].to_s %>"); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index f1d690c7..ad5a7bdc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -629,6 +629,7 @@ RedmineApp::Application.routes.draw do ## oauth相关 get 'update_shixun_excute_time' post 'subject_homepage_show' post 'excellent_subject_setting' + post 'update_subject_member_count' post 'support_shixun' post 'add_course' match 'add_major',:via=>[:get,:post] diff --git a/public/javascripts/edu/management.js b/public/javascripts/edu/management.js index e755c5fd..2da21fec 100644 --- a/public/javascripts/edu/management.js +++ b/public/javascripts/edu/management.js @@ -26,6 +26,16 @@ function submit_depart_host_count(){ } } +function submit_subject_member_count(){ + if($("input[name='member_count']").val().trim() == ""){ + $("#update_subject_member_count_notice").html("请输入开课人数").show(); + } else { + $("#update_subject_member_count_notice").hide(); + $('#update_subject_member_count_form').submit(); + hideModal(); + } +} + function submit_depart_name_form(){ if($("input[name='depart_name']").val().trim() == ""){ $("#update_depart_name_notice").html("名称不能为空").show();
---|