Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/pgfqe6ch8 into dev_aliyun

dev_aliyun
cxt 5 years ago
commit 4bb10aa183

@ -886,6 +886,8 @@ class AttachmentsController < ApplicationController
@shixun @shixun
elsif @attachment.container_type == 'Inform' elsif @attachment.container_type == 'Inform'
@inform = @attachment.container @inform = @attachment.container
elsif @attachment.container_type == 'CompetitionModuleMdContent'
@md_content = @attachment.container
elsif @attachment.container_type == 'Challenge' elsif @attachment.container_type == 'Challenge'
@challenge = @attachment.container @challenge = @attachment.container
elsif @attachment.container_type == 'Competition' elsif @attachment.container_type == 'Competition'

@ -89,7 +89,9 @@ class CompetitionsController < ApplicationController
def create_md_content def create_md_content
md_content = CompetitionModuleMdContent.find params[:md_content_id] md_content = CompetitionModuleMdContent.find params[:md_content_id]
md_content.update_attributes(params[:md_content]) 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) redirect_to md_contents_competition_url(:md_content_id => md_content.id)
end end
@ -103,7 +105,9 @@ class CompetitionsController < ApplicationController
def update_md_content def update_md_content
md_content = CompetitionModuleMdContent.find params[:md_content_id] md_content = CompetitionModuleMdContent.find params[:md_content_id]
md_content.update_attributes(params[:md_content]) 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) redirect_to md_content_competitions_path(:md_content_id => md_content.id)
end end

@ -1,6 +1,7 @@
class CompetitionModuleMdContent < ActiveRecord::Base class CompetitionModuleMdContent < ActiveRecord::Base
# attr_accessible :title, :body # attr_accessible :title, :body
belongs_to :competition_module belongs_to :competition_module
has_many :attachments, :dependent => :destroy
acts_as_attachable acts_as_attachable
end end

@ -11,6 +11,12 @@
<a href="<%= md_content_competitions_path(:md_content_id => com_module_2.try(:competition_module_md_content).try(:id)) %>" target="_blank" class="shixun-btn">使用说明</a> <a href="<%= md_content_competitions_path(:md_content_id => com_module_2.try(:competition_module_md_content).try(:id)) %>" target="_blank" class="shixun-btn">使用说明</a>
</p> </p>
</div> </div>
<div class="ccf-position-shixun" style="top: unset !important;bottom: 120px;">
<p class="inline">
<% com_module_3 = @competition.competition_modules.where(:hidden => 0, :name => '案例提交要求').first %>
<a href="<%= md_content_competitions_path(:md_content_id => com_module_3.try(:competition_module_md_content).try(:id)) %>" target="_blank" class="shixun-btn">案例提交要求</a>
</p>
</div>
</div> </div>
<img src="<%= named_attachment_path(@images[3], @images[3].try(:filename)) %>" width="100%"/> <img src="<%= named_attachment_path(@images[3], @images[3].try(:filename)) %>" width="100%"/>
<div class="pr"> <div class="pr">

Loading…
Cancel
Save