parent
1f4943483e
commit
31e8ad98ae
|
@ -217,6 +217,17 @@ class AttachmentsController < ApplicationController
|
|||
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
|
||||
# modify by nwb
|
||||
if params[:project_id]
|
||||
|
|
|
@ -172,8 +172,8 @@ class SoftapplicationsController < ApplicationController
|
|||
# PUT /softapplications/1.json
|
||||
def update
|
||||
# @softapplication = Softapplication.find(params[:id])
|
||||
@softapplication.attachments.map{|attach| attach.destroy }
|
||||
@softapplication.save_attachments(params[:attachments])
|
||||
#@softapplication.attachments.map{|attach| attach.destroy }
|
||||
@softapplication.save_attachments(params[:attachments]) if params[:attachments]
|
||||
#@softapplication.deposit_project = params[:project]
|
||||
@softapplication.project = Project.find_by_id(params[:project])
|
||||
|
||||
|
|
|
@ -18,11 +18,20 @@
|
|||
:method => :delete,
|
||||
:class => '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 %>
|
||||
<%= link_to image_tag('delete.png'), attachment_path(attachment),
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
:method => :delete,
|
||||
:class => 'delete',
|
||||
:remote => true,
|
||||
#:id => "attachments_" + attachment.id.to_s,
|
||||
:title => l(:button_delete) %>
|
||||
<% 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">
|
||||
<p style="padding-left: 60px">
|
||||
<% options = {:author => true, :deletable => true} %>
|
||||
<%= render :partial => 'attachments/links',
|
||||
:locals => {:attachments => @softapplication.attachments, :options => options} %>
|
||||
<span id="soft_attachments_links">
|
||||
<%= render :partial => 'attachments/links',
|
||||
:locals => {:attachments => @softapplication.attachments, :options => options} %>
|
||||
</span>
|
||||
</p>
|
||||
<legend><%=l(:label_upload_softworkpacket_photo)%></legend>
|
||||
<%= render_flash_messages %>
|
||||
|
|
|
@ -520,6 +520,7 @@ RedmineApp::Application.routes.draw do
|
|||
match "updateType" , via: [:get, :post]
|
||||
match "updateFileDense" , via: [:get, :post]
|
||||
match "renderTag" , via: [:get, :post]
|
||||
match 'delete_softapplications', via: [:get, :post]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue