From 7233a81f52e1811c06d3048b3d768e1f34ba5f5a Mon Sep 17 00:00:00 2001 From: Karel Picman Date: Tue, 21 Jan 2014 13:08:52 +0100 Subject: [PATCH 1/4] New devel branch 1.4.8 --- CHANGELOG.md | 7 +++++++ README.md | 2 +- init.rb | 6 +++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad55cb8b..cbcd3c75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ Changelog for Redmine DMSF ========================== +1.4.8: ** +----------------------- + + Document links + Email links + + 1.4.7: *2014-01-02* ----------------------- diff --git a/README.md b/README.md index 58c62b41..514ddcce 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Redmine DMSF Plugin =================== -The current version of Redmine DMSF is **1.4.7** +The current version of Redmine DMSF is **1.4.8** Redmine DMSF is Document Management System Features plugin for Redmine issue tracking system; It is aimed to replace current Redmine's Documents module. diff --git a/init.rb b/init.rb index 0486da43..02ef02bf 100644 --- a/init.rb +++ b/init.rb @@ -2,7 +2,7 @@ # # Copyright (C) 2011 Vít Jonáš # Copyright (C) 2012 Daniel Munn -# Copyright (C) 2013 Karel Picman +# Copyright (C) 2014 Karel Picman # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -26,9 +26,9 @@ Redmine::Plugin.register :redmine_dmsf do name 'DMSF' author 'Vit Jonas / Daniel Munn / Karel Picman' description 'Document Management System Features' - version '1.4.7 stable' + version '1.4.8 devel' url 'http://www.redmine.org/plugins/dmsf' - author_url 'mailto:karel.picman@kontron.com' + author_url 'https://github.com/danmunn/redmine_dmsf/graphs/contributors' requires_redmine :version_or_higher => '2.0.0' From e4194a5e73684e633f6c363795e69c7625985a2f Mon Sep 17 00:00:00 2001 From: Karel Picman Date: Wed, 29 Jan 2014 15:39:34 +0100 Subject: [PATCH 2/4] #205 Ampersands in filenames --- app/views/dmsf_upload/upload_file.html.erb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/dmsf_upload/upload_file.html.erb b/app/views/dmsf_upload/upload_file.html.erb index e239ebea..a538310c 100644 --- a/app/views/dmsf_upload/upload_file.html.erb +++ b/app/views/dmsf_upload/upload_file.html.erb @@ -2,6 +2,7 @@ # # Copyright (C) 2011 Vít Jonáš # Copyright (C) 2012 Daniel Munn +# Copyright (C) 2014 Karel Pičman # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -17,5 +18,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.%> -{"original_filename":"<%= h(@tempfile.original_filename) %>", "content_type":"<%= h(@tempfile.content_type) %>", -"disk_filename":"<%= h(@disk_filename) %>"} \ No newline at end of file +{"original_filename":"<%= (@tempfile.original_filename).html_safe %>", + "content_type":"<%= (@tempfile.content_type).html_safe %>", + "disk_filename":"<%= (@disk_filename).html_safe %>"} \ No newline at end of file From efe1ae88fb5d9285d6228d43162ec9e731c804ff Mon Sep 17 00:00:00 2001 From: Karel Picman Date: Tue, 4 Feb 2014 15:32:59 +0100 Subject: [PATCH 3/4] #212 Incorrect revision information in email notification --- app/controllers/dmsf_upload_controller.rb | 13 +++++-------- app/models/dmsf_file.rb | 4 ++++ app/models/dmsf_mailer.rb | 14 +++++--------- app/views/dmsf_mailer/files_deleted.html.erb | 9 +++++---- app/views/dmsf_mailer/files_deleted.text.erb | 7 ++++--- app/views/dmsf_mailer/files_updated.html.erb | 15 ++++++++------- app/views/dmsf_mailer/files_updated.text.erb | 16 +++++++++++----- 7 files changed, 42 insertions(+), 36 deletions(-) diff --git a/app/controllers/dmsf_upload_controller.rb b/app/controllers/dmsf_upload_controller.rb index 1109e28e..fae4eb19 100644 --- a/app/controllers/dmsf_upload_controller.rb +++ b/app/controllers/dmsf_upload_controller.rb @@ -151,15 +151,12 @@ class DmsfUploadController < ApplicationController end if new_revision.save - new_revision.assign_workflow(commited_file[:dmsf_workflow_id]) - file.reload - + new_revision.assign_workflow(commited_file[:dmsf_workflow_id]) new_revision.copy_file_content(file_upload) file_upload.close - File.delete(commited_disk_filepath) - + File.delete(commited_disk_filepath) + file.set_last_revision new_revision files.push(file) - if commited_file['dmsf_file_revision'].present? commited_file['dmsf_file_revision']['custom_field_values'].each do |v| cv = CustomValue.where(:customized_id => new_revision.id, :custom_field_id => v[0]).first @@ -173,8 +170,8 @@ class DmsfUploadController < ApplicationController failed_uploads.push(commited_file) end end - unless files.empty? - files.each { |file| log_activity(file, 'uploaded') if file } + unless files.empty? + files.each { |file| log_activity(file, 'uploaded') if file } begin DmsfMailer.files_updated(User.current, files).deliver rescue ActionView::MissingTemplate => e diff --git a/app/models/dmsf_file.rb b/app/models/dmsf_file.rb index a33ca3c7..842ecaed 100644 --- a/app/models/dmsf_file.rb +++ b/app/models/dmsf_file.rb @@ -99,6 +99,10 @@ class DmsfFile < ActiveRecord::Base end @last_revision end + + def set_last_revision(new_revision) + @last_revision = new_revision + end def delete if locked_for_user? diff --git a/app/models/dmsf_mailer.rb b/app/models/dmsf_mailer.rb index cba1d8cc..6b489218 100644 --- a/app/models/dmsf_mailer.rb +++ b/app/models/dmsf_mailer.rb @@ -72,19 +72,15 @@ class DmsfMailer < Mailer private def get_notify_user_emails(user, files) - if files.empty? - return [] - end - - project = files[0].project - + return [] if files.empty? + project = files[0].project notify_members = project.members notify_members = notify_members.select do |notify_member| - notify_user = notify_member.user - if notify_user.pref[:no_self_notified] && notify_user == user + notify_user = notify_member.user + if notify_user.pref[:no_self_notified] == '1' && notify_user == user false else - if notify_member.dmsf_mail_notification.nil? + unless notify_member.dmsf_mail_notification case notify_user.mail_notification when 'all' true diff --git a/app/views/dmsf_mailer/files_deleted.html.erb b/app/views/dmsf_mailer/files_deleted.html.erb index 57043c2c..dd528923 100644 --- a/app/views/dmsf_mailer/files_deleted.html.erb +++ b/app/views/dmsf_mailer/files_deleted.html.erb @@ -1,7 +1,8 @@ <%# Redmine plugin for Document Management System "Features" # -# Copyright (C) 2011 Vít Jonáš -# Copyright (C) 2012 Daniel Munn +# Copyright (C) 2011 Vít Jonáš +# Copyright (C) 2012 Daniel Munn +# Copyright (C) 2014 Karel Pičman # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -17,8 +18,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.%> -User <%= link_to(h(@user), {:only_path => false, :controller => 'users', :action => 'show', :id => @user }) %> -deleted DMSF files in project <%= @project.name %>: +<%= link_to @user, user_path(@user, :only_path => false) %> has just deleted documents of +<%= link_to @project, project_path(@project, :only_path => false) %> as follows: <% @files.each do |file| %>

<%= h(file.dmsf_path_str) %> (<%= file.name %>) diff --git a/app/views/dmsf_mailer/files_deleted.text.erb b/app/views/dmsf_mailer/files_deleted.text.erb index 50ee5322..dc4cebf9 100644 --- a/app/views/dmsf_mailer/files_deleted.text.erb +++ b/app/views/dmsf_mailer/files_deleted.text.erb @@ -1,7 +1,8 @@ <%# Redmine plugin for Document Management System "Features" # -# Copyright (C) 2011 Vít Jonáš -# Copyright (C) 2012 Daniel Munn +# Copyright (C) 2011 Vít Jonáš +# Copyright (C) 2012 Daniel Munn +# Copyright (C) 2014 Karel Pičman # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -17,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 <%= @user %> deleted DMSF files in project <%= @project.name %>: +<%= @user.name %> has just deleted documents of <%= @project.name %> as follows: <% @files.each do |file| %> <%= 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 ebe11c0a..5a87bd90 100644 --- a/app/views/dmsf_mailer/files_updated.html.erb +++ b/app/views/dmsf_mailer/files_updated.html.erb @@ -1,7 +1,8 @@ <%# Redmine plugin for Document Management System "Features" # -# Copyright (C) 2011 Vít Jonáš -# Copyright (C) 2012 Daniel Munn +# Copyright (C) 2011 Vít Jonáš +# Copyright (C) 2012 Daniel Munn +# Copyright (C) 2014 Karel Pičman # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -17,8 +18,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.%> -User <%= link_to(h(@user), {:only_path => false, :controller => 'users', :action => 'show', :id => @user }) %> -actualized DMSF files in project <%= @project.name %>: +<%= link_to @user, user_path(@user, :only_path => false) %> has just actualized documents of +<%= link_to @project, project_path(@project, :only_path => false) %> as follows: <% @files.each do |file| %>

<%= link_to(h(file.dmsf_path_str), @@ -26,11 +27,11 @@ actualized DMSF files in project <%= @project.name %>: :download => ''}) %> (<%= file.name %>), <%= number_to_human_size(file.last_revision.size) %>, version: <%= file.last_revision.major_version %>.<%= file.last_revision.minor_version %>, - <%= "#{file.last_revision.workflow_str(true)}," if file.last_revision.workflow_str(true).present? %> + <%= "#{file.last_revision.workflow_str(true)}," if file.last_revision.workflow_str(true) != l(:title_none) %> <%= link_to('Details', - {:only_path => false, :controller => 'dmsf_files', :action => 'show', :id => file}) %> + {:only_path => false, :controller => 'dmsf_files', :action => 'show', :id => file}) %> <% if file.last_revision.comment.present? %> -
    <%= h(file.last_revision.comment) %> +
    <%= h(file.last_revision.comment) %> <% end %>

<% end %> diff --git a/app/views/dmsf_mailer/files_updated.text.erb b/app/views/dmsf_mailer/files_updated.text.erb index e05db87c..16e1026b 100644 --- a/app/views/dmsf_mailer/files_updated.text.erb +++ b/app/views/dmsf_mailer/files_updated.text.erb @@ -1,7 +1,8 @@ <%# Redmine plugin for Document Management System "Features" # -# Copyright (C) 2011 Vít Jonáš -# Copyright (C) 2012 Daniel Munn +# Copyright (C) 2011 Vít Jonáš +# Copyright (C) 2012 Daniel Munn +# Copyright (C) 2014 Karel Pičman # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -17,9 +18,14 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.%> -User <%= @user %> actualized DMSF files in project <%= @project.name %>: +<%= @user.name %> has just actualized documents of <%= @project.name %> as follows: <% @files.each do |file| %> - <%= file.dmsf_path_str %> (<%= file.name %>), <%= number_to_human_size(file.last_revision.size) %>, version: <%= file.last_revision.major_version %>.<%= file.last_revision.minor_version %><%= ", #{file.last_revision.workflow_str(true)}" unless file.last_revision.workflow_str(true).blank? %> + <%= file.dmsf_path_str %> (<%= file.name %>), + <%= number_to_human_size(file.last_revision.size) %>, + version: <%= file.last_revision.major_version %>.<%= file.last_revision.minor_version %>, + <%= "#{file.last_revision.workflow_str(true)}," if file.last_revision.workflow_str(true) != l(:title_none) %> <%= url_for({:only_path => false, :controller => 'dmsf_files', :action => 'show', :id => file}) %> - <% if file.last_revision.comment.present? %> comment: <%= file.last_revision.comment %><% end %> + <% if file.last_revision.comment.present? %> + comment: <%= h(file.last_revision.comment) %> + <% end %> <% end %> \ No newline at end of file From 29812ee4024ffde279cd0ca7bb2e408a08a181cd Mon Sep 17 00:00:00 2001 From: Karel Picman Date: Thu, 6 Feb 2014 10:12:28 +0100 Subject: [PATCH 4/4] #214 Required DMSF custom field prevents documents to be saved --- app/controllers/dmsf_upload_controller.rb | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/app/controllers/dmsf_upload_controller.rb b/app/controllers/dmsf_upload_controller.rb index fae4eb19..16b66fba 100644 --- a/app/controllers/dmsf_upload_controller.rb +++ b/app/controllers/dmsf_upload_controller.rb @@ -1,6 +1,7 @@ # Redmine plugin for Document Management System "Features" # -# Copyright (C) 2011 Vít Jonáš +# Copyright (C) 2011 Vít Jonáš +# Copyright (C) 2014 Karel Pičman # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -142,7 +143,13 @@ class DmsfUploadController < ApplicationController end # Need to save file first to generate id for it in case of creation. - # File id is needed to properly generate revision disk filename + # File id is needed to properly generate revision disk filename + if commited_file['dmsf_file_revision'].present? + commited_file['dmsf_file_revision']['custom_field_values'].each_with_index do |v, i| + new_revision.custom_field_values[i].value = v[1] + end + end + if new_revision.valid? && file.save new_revision.disk_filename = new_revision.new_storage_filename else @@ -157,15 +164,6 @@ class DmsfUploadController < ApplicationController File.delete(commited_disk_filepath) file.set_last_revision new_revision files.push(file) - if commited_file['dmsf_file_revision'].present? - commited_file['dmsf_file_revision']['custom_field_values'].each do |v| - cv = CustomValue.where(:customized_id => new_revision.id, :custom_field_id => v[0]).first - if cv - cv.value = v[1] - cv.save - end - end - end else failed_uploads.push(commited_file) end