From 30edb86ed4a6732f3ef631f80531ccd6e02b6aea Mon Sep 17 00:00:00 2001 From: "karel.picman@lbcfree.net" Date: Tue, 16 Jun 2020 14:35:47 +0200 Subject: [PATCH 1/2] No 'Link to' menu item for links --- app/views/dmsf_context_menus/_file.html.erb | 14 +++++++++----- app/views/dmsf_context_menus/_folder.html.erb | 12 +++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/app/views/dmsf_context_menus/_file.html.erb b/app/views/dmsf_context_menus/_file.html.erb index e352f54b..f94169d8 100644 --- a/app/views/dmsf_context_menus/_file.html.erb +++ b/app/views/dmsf_context_menus/_file.html.erb @@ -28,11 +28,15 @@ <%= link_to "#{l(:button_copy)}/#{l(:button_move)}", copy_file_path(id: dmsf_file), title: l(:title_copy), class: 'icon icon-copy', disabled: !dmsf_link.nil? %> -<%= link_to l(:label_link_to), - new_dmsf_link_path(project_id: project.id, - dmsf_folder_id: dmsf_file.dmsf_folder ? dmsf_file.dmsf_folder.id : nil, - dmsf_file_id: dmsf_file.id, type: 'link_to'), - title: l(:title_create_link), class: 'icon icon-link' %> +<% unless dmsf_link %> +
  • + <%= link_to l(:label_link_to), + new_dmsf_link_path(project_id: project.id, + dmsf_folder_id: dmsf_file.dmsf_folder ? dmsf_file.dmsf_folder.id : nil, + dmsf_file_id: dmsf_file.id, type: 'link_to'), + title: l(:title_create_link), class: 'icon icon-link' %> +
  • +<% end %>
  • <% if locked %> <%= context_menu_link l(:button_unlock), unlock_dmsf_files_path(id: dmsf_file), class: 'icon icon-unlock', diff --git a/app/views/dmsf_context_menus/_folder.html.erb b/app/views/dmsf_context_menus/_folder.html.erb index 1f61bd76..b8b2c477 100644 --- a/app/views/dmsf_context_menus/_folder.html.erb +++ b/app/views/dmsf_context_menus/_folder.html.erb @@ -28,11 +28,13 @@ <%= context_menu_link "#{l(:button_copy)}/#{l(:button_move)}", copy_folder_path(id: dmsf_folder), class: 'icon icon-copy', disabled: !allowed || locked %>
  • -
  • - <%= context_menu_link l(:label_link_to), - new_dmsf_link_path(project_id: project.id, dmsf_folder_id: dmsf_folder.id, type: 'link_to'), - class: 'icon icon-link', disabled: !allowed || locked %> -
  • +<% unless dmsf_link %> +
  • + <%= context_menu_link l(:label_link_to), + new_dmsf_link_path(project_id: project.id, dmsf_folder_id: dmsf_folder.id, type: 'link_to'), + class: 'icon icon-link' %> +
  • +<% end %>
  • <% if locked %> <%= context_menu_link l(:button_unlock), unlock_dmsf_path(id: project, folder_id: dmsf_folder), From d6b3c9e94d7fdd92b2ba31094469c5b35a2e2943 Mon Sep 17 00:00:00 2001 From: "karel.picman@lbcfree.net" Date: Tue, 16 Jun 2020 14:36:30 +0200 Subject: [PATCH 2/2] A workaround for missing ZIP file while emailing --- app/controllers/dmsf_controller.rb | 6 +++++- app/models/dmsf_mailer.rb | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/controllers/dmsf_controller.rb b/app/controllers/dmsf_controller.rb index 5347b144..45e70e15 100644 --- a/app/controllers/dmsf_controller.rb +++ b/app/controllers/dmsf_controller.rb @@ -185,7 +185,11 @@ class DmsfController < ApplicationController flash[:error] = l(:error_email_to_must_be_entered) else DmsfMailer.deliver_send_documents(@project, params[:email].permit!, User.current) - File.delete(params[:email][:zipped_content]) + if(File.exist?(params[:email][:zipped_content])) + File.delete(params[:email][:zipped_content]) + else + flash[:error] = l(:header_minimum_filesize) + end flash[:notice] = l(:notice_email_sent, params[:email][:to]) end redirect_to dmsf_folder_path(id: @project, folder_id: @folder) diff --git a/app/models/dmsf_mailer.rb b/app/models/dmsf_mailer.rb index 66438fb7..5e4b2657 100644 --- a/app/models/dmsf_mailer.rb +++ b/app/models/dmsf_mailer.rb @@ -84,8 +84,12 @@ class DmsfMailer < Mailer @files = email_params[:files] @author = author unless @links_only - zipped_content_data = open(email_params[:zipped_content], 'rb') { |io| io.read } - attachments['Documents.zip'] = { content_type: 'application/zip', content: zipped_content_data } + if File.exist?(email_params[:zipped_content]) + zipped_content_data = open(email_params[:zipped_content], 'rb') { |io| io.read } + attachments['Documents.zip'] = { content_type: 'application/zip', content: zipped_content_data } + else + Rails.logger.error "Cannot attach #{email_params[:zipped_content]}, it doesn't exist." + end end mail to: email_params[:to], cc: email_params[:cc], subject: email_params[:subject], 'From' => email_params[:from], 'Reply-To' => email_params[:reply_to]