From ac1b3338c53df9a14a731cae9d52c62c15f03c11 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 1 Apr 2016 20:10:28 +0800 Subject: [PATCH] =?UTF-8?q?logo=E5=9B=BE=E6=A0=87=E6=9B=BF=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 30 +++++-------------- .../files/_upload_org_new_files.html.erb | 6 ++-- app/views/files/create.js.erb | 13 ++------ 3 files changed, 12 insertions(+), 37 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 8db287b0e..cf94da8d9 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -629,32 +629,16 @@ class FilesController < ApplicationController # redirect_to org_subfield_files_url(@org_subfield) # } end - elsif @organization + # 组织添加附件,为了修改图片 + elsif params[:organization_id] + @organization = Organization.find(params[:organization_id]) @addTag=false - attachments = Attachment.attach_filesex(@organization, params[:attachments], params[:org_attachment_type]) - - if params[:org_attachment_type] && params[:org_attachment_type].is_a?(Array) - params[:org_attachment_type].each do |type| - tag_name = get_tag_name_by_type_number type - if !attachments.empty? && attachments[:files] && tag_name != "" - attachments[:files].each do |attachment| - attachment.tag_list.add(tag_name) - attachment.save - end - end - end + # atttchment_type = 0为logo 1为banner + if params[:logo] + attachments = Attachment.attach_filesex(@organization, params[:attachments], false) else - if params[:org_attachment_type] && params[:org_attachment_type] != "5" - tag_name = get_tag_name_by_type_number params[:org_attachment_type] - if !attachments.empty? && attachments[:files] && tag_name != "" - attachments[:files].each do |attachment| - attachment.tag_list.add(tag_name) - attachment.save - end - end - end + attachments = Attachment.attach_filesex(@organization, params[:attachments], true) end - # TODO: 临时用 nyan sort_init 'created_on', 'desc' sort_update 'created_on' => "#{Attachment.table_name}.created_on", diff --git a/app/views/files/_upload_org_new_files.html.erb b/app/views/files/_upload_org_new_files.html.erb index 43b189b65..111354c1a 100644 --- a/app/views/files/_upload_org_new_files.html.erb +++ b/app/views/files/_upload_org_new_files.html.erb @@ -1,11 +1,11 @@ -
-

<%= l(:label_upload_files)%>

+

更换Logo

+

尺寸最好55*33

<%= error_messages_for 'attachment' %> - <%= form_tag(organization_files_path(org, :in_org => params[:in_org]), :multipart => true,:remote => !ie8?,:name=>"upload_form") do %> + <%= form_tag(organization_files_path(org, :in_org => params[:in_org], :logo => true), :multipart => true,:remote => !ie8?,:name=>"upload_form") do %> <%= render :partial => 'files/org_subfield_upload_attachment_list', :locals => {:container => org}%>
diff --git a/app/views/files/create.js.erb b/app/views/files/create.js.erb index 5150a1dc3..38308be12 100644 --- a/app/views/files/create.js.erb +++ b/app/views/files/create.js.erb @@ -66,18 +66,9 @@ $("#resource_list").html('<%= j(render partial: "subfield_files" ,locals: {org_ <% end %> <% end %> <% elsif @organization %> //组织单独处理 -<% if params[:in_org] %> -window.location.href = '<%= organization_files_path @organization %>'; -<%else %> hideModal(); -$("#resource_list").html('<%= j(render partial: "subfield_files" ,locals: {org_subfield: @org_subfield}) %>'); -// 添加文件上传成功提示, -<% unless params[:attachments].nil? %> -// var div = $('
文件上传成功!
'); -// $("#org_subfield_list").prepend(div); -// setTimeout( function(){div.remove();},3000); -<% end %> -<% end %> +window.location.href = '<%= organization_path @organization %>'; + <% end %> <% end %> $(document).ready(img_thumbnails);