1.修复竞赛作品每次修改之后,都会吧图片清空的BUG

2.修改删除竞赛作品图片功能
competition
sw 11 years ago
parent 1f4943483e
commit 31e8ad98ae

@ -217,6 +217,17 @@ class AttachmentsController < ApplicationController
end end
end end
#删除竞赛作品的附件
def delete_softapplications
@attachment = Attachment.find params[:id]
@softapplication = @attachment.container if @attachment!=nil
@attachment.container.attachments.delete(@attachment) if @attachment!=nil
respond_to do |format|
format.html { redirect_to_referer_or edit_softapplication_path(@softapplication) }
#format.js
end
end
def autocomplete def autocomplete
# modify by nwb # modify by nwb
if params[:project_id] if params[:project_id]

@ -172,8 +172,8 @@ class SoftapplicationsController < ApplicationController
# PUT /softapplications/1.json # PUT /softapplications/1.json
def update def update
# @softapplication = Softapplication.find(params[:id]) # @softapplication = Softapplication.find(params[:id])
@softapplication.attachments.map{|attach| attach.destroy } #@softapplication.attachments.map{|attach| attach.destroy }
@softapplication.save_attachments(params[:attachments]) @softapplication.save_attachments(params[:attachments]) if params[:attachments]
#@softapplication.deposit_project = params[:project] #@softapplication.deposit_project = params[:project]
@softapplication.project = Project.find_by_id(params[:project]) @softapplication.project = Project.find_by_id(params[:project])

@ -18,11 +18,20 @@
:method => :delete, :method => :delete,
:class => 'delete', :class => 'delete',
:title => l(:button_delete) %> :title => l(:button_delete) %>
<%# elsif attachment.container_type == 'Softapplication'%>
<%#= link_to image_tag('delete.png'), delete_softapplications_attachments_path(:id => attachment.id),
:data => {:confirm => l(:text_are_you_sure)},
:method => :delete,
:class => 'delete',
:remote => true,
:title => l(:button_delete) %>
<% else %> <% else %>
<%= link_to image_tag('delete.png'), attachment_path(attachment), <%= link_to image_tag('delete.png'), attachment_path(attachment),
:data => {:confirm => l(:text_are_you_sure)}, :data => {:confirm => l(:text_are_you_sure)},
:method => :delete, :method => :delete,
:class => 'delete', :class => 'delete',
:remote => true,
#:id => "attachments_" + attachment.id.to_s,
:title => l(:button_delete) %> :title => l(:button_delete) %>
<% end %> <% end %>
<% end %> <% end %>

@ -0,0 +1,2 @@
<% options = {:author => true, :deletable => true} %>
$("#soft_attachments_links").html('<%= escape_javascript(render(:partial => 'links', :locals => {:attachments => @softapplication.attachments, :options => options} )) %>');

@ -102,8 +102,10 @@
<fieldset style="width: 500px"> <fieldset style="width: 500px">
<p style="padding-left: 60px"> <p style="padding-left: 60px">
<% options = {:author => true, :deletable => true} %> <% options = {:author => true, :deletable => true} %>
<%= render :partial => 'attachments/links', <span id="soft_attachments_links">
:locals => {:attachments => @softapplication.attachments, :options => options} %> <%= render :partial => 'attachments/links',
:locals => {:attachments => @softapplication.attachments, :options => options} %>
</span>
</p> </p>
<legend><%=l(:label_upload_softworkpacket_photo)%></legend> <legend><%=l(:label_upload_softworkpacket_photo)%></legend>
<%= render_flash_messages %> <%= render_flash_messages %>

@ -520,6 +520,7 @@ RedmineApp::Application.routes.draw do
match "updateType" , via: [:get, :post] match "updateType" , via: [:get, :post]
match "updateFileDense" , via: [:get, :post] match "updateFileDense" , via: [:get, :post]
match "renderTag" , via: [:get, :post] match "renderTag" , via: [:get, :post]
match 'delete_softapplications', via: [:get, :post]
end end
end end

Loading…
Cancel
Save