From 4beeedd2827d9470aff7c893a0b25b703e9e18a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Mon, 25 Mar 2019 11:27:53 +0100 Subject: [PATCH 1/6] Wrong email notifications' issuer --- app/controllers/dmsf_controller.rb | 2 +- app/models/dmsf_mailer.rb | 9 ++++++--- app/views/dmsf_mailer/files_deleted.html.erb | 2 +- app/views/dmsf_mailer/files_deleted.text.erb | 2 +- app/views/dmsf_mailer/files_updated.html.erb | 2 +- app/views/dmsf_mailer/files_updated.text.erb | 2 +- app/views/dmsf_mailer/send_documents.html.erb | 4 ++-- app/views/dmsf_mailer/send_documents.text.erb | 4 ++-- test/unit/dmsf_mailer_test.rb | 2 +- 9 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app/controllers/dmsf_controller.rb b/app/controllers/dmsf_controller.rb index 58f3b517..f544efb1 100644 --- a/app/controllers/dmsf_controller.rb +++ b/app/controllers/dmsf_controller.rb @@ -170,7 +170,7 @@ class DmsfController < ApplicationController if params[:email][:to].strip.blank? flash[:errors] = l(:error_email_to_must_be_entered) else - DmsfMailer.deliver_send_documents(@project, params[:email].permit!) + DmsfMailer.deliver_send_documents(@project, params[:email].permit!, User.current) File.delete(params[:email][:zipped_content]) flash[:notice] = l(:notice_email_sent, params[:email][:to]) end diff --git a/app/models/dmsf_mailer.rb b/app/models/dmsf_mailer.rb index def6f61d..3a774b9e 100644 --- a/app/models/dmsf_mailer.rb +++ b/app/models/dmsf_mailer.rb @@ -38,6 +38,7 @@ class DmsfMailer < Mailer redmine_headers 'Project' => project.identifier if project @files = files @project = project + @author = files.first.last_revision.user if files.first.last_revision message_id project set_language_if_valid user.language mail :to => user.mail, subject: "[#{@project.name} - #{l(:menu_dmsf)}] #{l(:text_email_doc_updated_subject)}" @@ -58,6 +59,7 @@ class DmsfMailer < Mailer redmine_headers 'Project' => project.identifier if project @files = files @project = project + @author = files.first.deleted_by_user message_id project set_language_if_valid user.language mail :to => user.mail, @@ -65,11 +67,11 @@ class DmsfMailer < Mailer end end - def self.deliver_send_documents(project, email_params) + def self.deliver_send_documents(project, email_params, author) send_documents(User.current, project, email_params).deliver_now end - def send_documents(_, project, email_params) + def send_documents(_, project, email_params, author) redmine_headers 'Project' => project.identifier if project @body = email_params[:body] @links_only = email_params[:links_only] == '1' @@ -77,7 +79,7 @@ class DmsfMailer < Mailer @expired_at = email_params[:expired_at] @folders = email_params[:folders] @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 } @@ -106,6 +108,7 @@ class DmsfMailer < Mailer @text1 = l(text1_id, :name => workflow.name, :filename => revision.dmsf_file.name, :notice => notice) @text2 = l(text2_id) @notice = notice + @author = User.find_by(id: revision.dmsf_workflow_assigned_by) mail :to => user.mail, :subject => "[#{@project.name} - #{l(:field_label_dmsf_workflow)}] #{@workflow.name} #{l(subject_id)}" end diff --git a/app/views/dmsf_mailer/files_deleted.html.erb b/app/views/dmsf_mailer/files_deleted.html.erb index dd2d3bef..e4956298 100644 --- a/app/views/dmsf_mailer/files_deleted.html.erb +++ b/app/views/dmsf_mailer/files_deleted.html.erb @@ -18,7 +18,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.%> -<%= link_to User.current, user_url(User.current) %> <%= l(:text_email_doc_deleted) %> +<%= link_to @author, user_url(@author) %> <%= l(:text_email_doc_deleted) if @author%> <%= link_to @project, project_url(@project) %> <%= l(:text_email_doc_follows) %> <% @files.each do |file| %>

diff --git a/app/views/dmsf_mailer/files_deleted.text.erb b/app/views/dmsf_mailer/files_deleted.text.erb index fe62eee3..159cb4e6 100644 --- a/app/views/dmsf_mailer/files_deleted.text.erb +++ b/app/views/dmsf_mailer/files_deleted.text.erb @@ -21,7 +21,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.%> -<%= User.current.name %> <%= l(:text_email_doc_deleted) %> <%= @project.name %> <%= l(:text_email_doc_follows) %> +<%= @author.name %> <%= l(:text_email_doc_deleted) %> <%= @project.name %> <%= l(:text_email_doc_follows) if @author %> <% @files.each do |file| %> <%= h(file.dmsf_path_str) %> (<%= file.name %>) <% if file.last_revision %> diff --git a/app/views/dmsf_mailer/files_updated.html.erb b/app/views/dmsf_mailer/files_updated.html.erb index 33f82505..d970a0d7 100644 --- a/app/views/dmsf_mailer/files_updated.html.erb +++ b/app/views/dmsf_mailer/files_updated.html.erb @@ -18,7 +18,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.%> -<%= link_to User.current, user_url(User.current) %> <%= l(:text_email_doc_updated) %> +<%= link_to @author, user_url(@author) %> <%= l(:text_email_doc_updated) if @author%> <%= link_to @project, project_url(@project) %> <%= l(:text_email_doc_follows) %> <% @files.each do |file| %>

diff --git a/app/views/dmsf_mailer/files_updated.text.erb b/app/views/dmsf_mailer/files_updated.text.erb index f5a49309..ed7d4be5 100644 --- a/app/views/dmsf_mailer/files_updated.text.erb +++ b/app/views/dmsf_mailer/files_updated.text.erb @@ -18,7 +18,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.%> -<%= User.current.name %> <%= l(:text_email_doc_updated) %> +<%= @author.name %> <%= l(:text_email_doc_updated) if @author %> <%= @project.name %> <%= l(:text_email_doc_follows) %> <% @files.each do |file| %> <%= h(file.dmsf_path_str) %> (<%= file.name %>), diff --git a/app/views/dmsf_mailer/send_documents.html.erb b/app/views/dmsf_mailer/send_documents.html.erb index 054ebb33..6db67c95 100644 --- a/app/views/dmsf_mailer/send_documents.html.erb +++ b/app/views/dmsf_mailer/send_documents.html.erb @@ -41,7 +41,7 @@ <% if @public_urls %> <% dmsf_public_url = DmsfPublicUrl.new %> <% dmsf_public_url.dmsf_file = file %> - <% dmsf_public_url.user = User.current %> + <% dmsf_public_url.user = @author %> <% dmsf_public_url.expire_at = @expired_at %> <% dmsf_public_url.save %> <%= link_to(h(file.title), dmsf_public_urls_url(:token => dmsf_public_url.token)) %> @@ -68,7 +68,7 @@ <% if @public_urls %> <% dmsf_public_url = DmsfPublicUrl.new %> <% dmsf_public_url.dmsf_file = file %> - <% dmsf_public_url.user = User.current %> + <% dmsf_public_url.user = @author %> <% dmsf_public_url.expire_at = @expired_at %> <% dmsf_public_url.save %> <%= link_to(h(file.title), dmsf_public_urls_url(:token => dmsf_public_url.token)) %> diff --git a/app/views/dmsf_mailer/send_documents.text.erb b/app/views/dmsf_mailer/send_documents.text.erb index 1cc6935a..900041e1 100644 --- a/app/views/dmsf_mailer/send_documents.text.erb +++ b/app/views/dmsf_mailer/send_documents.text.erb @@ -39,7 +39,7 @@ <% if @public_urls %> <% dmsf_public_url = DmsfPublicUrl.new %> <% dmsf_public_url.dmsf_file = file %> - <% dmsf_public_url.user = User.current %> + <% dmsf_public_url.user = @author %> <% dmsf_public_url.expire_at = @expired_at %> <% dmsf_public_url.save %> <%= dmsf_public_urls_url(:token => dmsf_public_url.token) %> @@ -61,7 +61,7 @@ <% if @public_urls %> <% dmsf_public_url = DmsfPublicUrl.new %> <% dmsf_public_url.dmsf_file = file %> - <% dmsf_public_url.user = User.current %> + <% dmsf_public_url.user = @author %> <% dmsf_public_url.expire_at = @expired_at %> <% dmsf_public_url.save %> <%= dmsf_public_urls_url(:token => dmsf_public_url.token) %> diff --git a/test/unit/dmsf_mailer_test.rb b/test/unit/dmsf_mailer_test.rb index 0c008da4..3c053c9a 100644 --- a/test/unit/dmsf_mailer_test.rb +++ b/test/unit/dmsf_mailer_test.rb @@ -73,7 +73,7 @@ class DmsfMailerTest < RedmineDmsf::Test::UnitTest email_params[:expired_at] = DateTime.current.to_s email_params[:folders] = nil email_params[:files] = "[\"#{@file1.id}\"]" - DmsfMailer.deliver_send_documents(@file1.project, email_params) + DmsfMailer.deliver_send_documents(@file1.project, email_params, User.current) email = last_email assert text_part(email).body.include? body assert html_part(email).body.include? body From fff4957f444178f393c0dc4ff703ac3b3639640b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Mon, 25 Mar 2019 13:09:39 +0100 Subject: [PATCH 2/6] Wrong email notifications' issuer --- app/models/dmsf_mailer.rb | 5 ++++- app/views/dmsf_mailer/files_deleted.html.erb | 2 +- app/views/dmsf_mailer/files_deleted.text.erb | 2 +- app/views/dmsf_mailer/files_updated.html.erb | 2 +- app/views/dmsf_mailer/files_updated.text.erb | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/models/dmsf_mailer.rb b/app/models/dmsf_mailer.rb index 3a774b9e..0883b6c5 100644 --- a/app/models/dmsf_mailer.rb +++ b/app/models/dmsf_mailer.rb @@ -39,6 +39,7 @@ class DmsfMailer < Mailer @files = files @project = project @author = files.first.last_revision.user if files.first.last_revision + @author = User.anonymous unless @author message_id project set_language_if_valid user.language mail :to => user.mail, subject: "[#{@project.name} - #{l(:menu_dmsf)}] #{l(:text_email_doc_updated_subject)}" @@ -60,6 +61,7 @@ class DmsfMailer < Mailer @files = files @project = project @author = files.first.deleted_by_user + @author = User.anonymous unless @author message_id project set_language_if_valid user.language mail :to => user.mail, @@ -68,7 +70,7 @@ class DmsfMailer < Mailer end def self.deliver_send_documents(project, email_params, author) - send_documents(User.current, project, email_params).deliver_now + send_documents(User.current, project, email_params, author).deliver_now end def send_documents(_, project, email_params, author) @@ -109,6 +111,7 @@ class DmsfMailer < Mailer @text2 = l(text2_id) @notice = notice @author = User.find_by(id: revision.dmsf_workflow_assigned_by) + @author = User.anonymous unless @author mail :to => user.mail, :subject => "[#{@project.name} - #{l(:field_label_dmsf_workflow)}] #{@workflow.name} #{l(subject_id)}" end diff --git a/app/views/dmsf_mailer/files_deleted.html.erb b/app/views/dmsf_mailer/files_deleted.html.erb index e4956298..5fabf940 100644 --- a/app/views/dmsf_mailer/files_deleted.html.erb +++ b/app/views/dmsf_mailer/files_deleted.html.erb @@ -18,7 +18,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.%> -<%= link_to @author, user_url(@author) %> <%= l(:text_email_doc_deleted) if @author%> +<%= link_to @author, user_url(@author) %> <%= l(:text_email_doc_deleted) %> <%= link_to @project, project_url(@project) %> <%= l(:text_email_doc_follows) %> <% @files.each do |file| %>

diff --git a/app/views/dmsf_mailer/files_deleted.text.erb b/app/views/dmsf_mailer/files_deleted.text.erb index 159cb4e6..92cbd16f 100644 --- a/app/views/dmsf_mailer/files_deleted.text.erb +++ b/app/views/dmsf_mailer/files_deleted.text.erb @@ -21,7 +21,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.%> -<%= @author.name %> <%= l(:text_email_doc_deleted) %> <%= @project.name %> <%= l(:text_email_doc_follows) if @author %> +<%= @author.name %> <%= l(:text_email_doc_deleted) %> <%= @project.name %> <%= l(:text_email_doc_follows) %> <% @files.each do |file| %> <%= h(file.dmsf_path_str) %> (<%= file.name %>) <% if file.last_revision %> diff --git a/app/views/dmsf_mailer/files_updated.html.erb b/app/views/dmsf_mailer/files_updated.html.erb index d970a0d7..3af0256d 100644 --- a/app/views/dmsf_mailer/files_updated.html.erb +++ b/app/views/dmsf_mailer/files_updated.html.erb @@ -18,7 +18,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.%> -<%= link_to @author, user_url(@author) %> <%= l(:text_email_doc_updated) if @author%> +<%= link_to @author, user_url(@author) %> <%= l(:text_email_doc_updated) %> <%= link_to @project, project_url(@project) %> <%= l(:text_email_doc_follows) %> <% @files.each do |file| %>

diff --git a/app/views/dmsf_mailer/files_updated.text.erb b/app/views/dmsf_mailer/files_updated.text.erb index ed7d4be5..b2829104 100644 --- a/app/views/dmsf_mailer/files_updated.text.erb +++ b/app/views/dmsf_mailer/files_updated.text.erb @@ -18,7 +18,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.%> -<%= @author.name %> <%= l(:text_email_doc_updated) if @author %> +<%= @author.name %> <%= l(:text_email_doc_updated) %> <%= @project.name %> <%= l(:text_email_doc_follows) %> <% @files.each do |file| %> <%= h(file.dmsf_path_str) %> (<%= file.name %>), From d0497c7cc7abcfe6ea4b26bfb57e0eb01032506d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Mon, 25 Mar 2019 15:40:14 +0100 Subject: [PATCH 3/6] Displaying notifications' recipients even if they aren't notified --- app/models/dmsf_mailer.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/dmsf_mailer.rb b/app/models/dmsf_mailer.rb index 0883b6c5..7a2b0639 100644 --- a/app/models/dmsf_mailer.rb +++ b/app/models/dmsf_mailer.rb @@ -25,8 +25,8 @@ class DmsfMailer < Mailer layout 'mailer' def self.deliver_files_updated(project, files) - files = files.select { |file| file.notify? } users = get_notify_users(project, files) + files = files.select { |file| file.notify? } users.each do |user| files_updated(user, project, files).deliver_later end @@ -47,8 +47,8 @@ class DmsfMailer < Mailer end def self.deliver_files_deleted(project, files) - files = files.select { |file| file.notify? } users = get_notify_users(project, files) + files = files.select { |file| file.notify? } users.each do |user| files_deleted(user, project, files).deliver_later end From 5160348696a4455e21d0325cc1be85941d1213a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Tue, 26 Mar 2019 14:24:56 +0100 Subject: [PATCH 4/6] Comptibility with Easy SW: sorting icons are not visible --- assets/stylesheets/redmine_dmsf.css | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/assets/stylesheets/redmine_dmsf.css b/assets/stylesheets/redmine_dmsf.css index 3eb9b36d..ca11080f 100644 --- a/assets/stylesheets/redmine_dmsf.css +++ b/assets/stylesheets/redmine_dmsf.css @@ -88,6 +88,20 @@ table.display thead th div.DataTables_sort_wrapper span { display: block; } +/* Comptibility with Easy SW: sorting icons are not visible do */ +.ui-state-default .ui-icon { + background-image: url("../../../stylesheets/jquery/images/ui-icons_759fcf_256x240.png"); +} + +.ui-icon-triangle-1-n { + background-position: 0 -16px; +} + +.ui-icon-triangle-1-s { + background-position: -64px -16px; +} +/* end */ + .dmsf_controls, .dmsf_controls input, .dmsf_controls select, From dda3ae437b8a6cb1a07036d1cf431b84c6e7a57b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Wed, 27 Mar 2019 10:20:18 +0100 Subject: [PATCH 5/6] Failure to Update DMSF from 1.5.9 to 2.0.0 during migrate #988 --- db/migrate/20170421101901_dmsf_file_container_rollback.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/20170421101901_dmsf_file_container_rollback.rb b/db/migrate/20170421101901_dmsf_file_container_rollback.rb index 78dee662..ea904047 100644 --- a/db/migrate/20170421101901_dmsf_file_container_rollback.rb +++ b/db/migrate/20170421101901_dmsf_file_container_rollback.rb @@ -47,7 +47,7 @@ class DmsfFileContainerRollback < ActiveRecord::Migration[4.2] folder = DmsfFolder.new folder.project_id = issue.project.id folder.dmsf_folder_id = parent.id - folder.title = "#{issue.id} - #{issue.subject}" + folder.title = "#{issue.id} - #{DmsfFolder.get_valid_title(issue.subject)}" folder.user_id = User.anonymous.id folder.save! new_folder_ids << folder.id From 75c253453efe0b04ef7eb01776a10e0243ee5880 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Wed, 27 Mar 2019 12:03:44 +0100 Subject: [PATCH 6/6] Failure to Update DMSF from 1.5.9 to 2.0.0 during migrate --- ...0170421101901_dmsf_file_container_rollback.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/db/migrate/20170421101901_dmsf_file_container_rollback.rb b/db/migrate/20170421101901_dmsf_file_container_rollback.rb index ea904047..92dd3738 100644 --- a/db/migrate/20170421101901_dmsf_file_container_rollback.rb +++ b/db/migrate/20170421101901_dmsf_file_container_rollback.rb @@ -44,12 +44,16 @@ class DmsfFileContainerRollback < ActiveRecord::Migration[4.2] new_folder_ids << parent.id end # Issue folder - folder = DmsfFolder.new - folder.project_id = issue.project.id - folder.dmsf_folder_id = parent.id - folder.title = "#{issue.id} - #{DmsfFolder.get_valid_title(issue.subject)}" - folder.user_id = User.anonymous.id - folder.save! + title = "#{issue.id} - #{DmsfFolder.get_valid_title(issue.subject)}" + folder = DmsfFolder.find_by(project_id: issue.project.id, dmsf_folder_id: parent.id, title: title) + unless folder + folder = DmsfFolder.new + folder.project_id = issue.project.id + folder.dmsf_folder_id = parent.id + folder.title = "#{issue.id} - #{DmsfFolder.get_valid_title(issue.subject)}" + folder.user_id = User.anonymous.id + folder.save! + end new_folder_ids << folder.id # Move the file into the new folder file.dmsf_folder_id = folder.id