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 898e4977..ccfd432e 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