From 01594897adf76efc198ab76ac94832cc5cc1eb40 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 21 Sep 2019 09:45:49 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E9=99=84=E4=BB=B6=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/competition_module_md_content.rb | 1 + 1 file changed, 1 insertion(+) 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 From e233da591dcfdb57b854176d0c6b5a058df2e1a6 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 21 Sep 2019 10:42:39 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E9=99=84=E4=BB=B6=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 2 ++ app/controllers/competitions_controller.rb | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) 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 From 4bb667240f19698e2ff593e0cf25815f5126a460 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 21 Sep 2019 10:49:35 +0800 Subject: [PATCH 3/4] competition support --- app/controllers/application_controller.rb | 1 + app/views/competitions/_ccf_competition.html.erb | 6 ++++++ 2 files changed, 7 insertions(+) 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/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 %> + 案例提交要求 +

+
From 6c89bdb576ff355e6e1c73a4bd35db759f5f0906 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 21 Sep 2019 10:56:58 +0800 Subject: [PATCH 4/4] fix --- app/controllers/application_controller.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 960d2ef4..50f97bc8 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -255,7 +255,6 @@ class ApplicationController < ActionController::Base end end end - user = User.find 57703 user end