diff --git a/app/controllers/dmsf_workflows_controller.rb b/app/controllers/dmsf_workflows_controller.rb index c50f69f0..39412d05 100644 --- a/app/controllers/dmsf_workflows_controller.rb +++ b/app/controllers/dmsf_workflows_controller.rb @@ -2,7 +2,7 @@ # # Redmine plugin for Document Management System "Features" # -# Copyright (C) 2011-15 Karel Pičman +# Copyright (C) 2011-16 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 @@ -223,6 +223,7 @@ class DmsfWorkflowsController < ApplicationController @dmsf_workflow = DmsfWorkflow.new @dmsf_workflow.name = params[:dmsf_workflow][:name] @dmsf_workflow.project_id = @project.id if @project + @dmsf_workflow.author = User.current @dmsf_workflow.save end end diff --git a/app/models/dmsf_mailer.rb b/app/models/dmsf_mailer.rb index 42d7516c..500f4362 100644 --- a/app/models/dmsf_mailer.rb +++ b/app/models/dmsf_mailer.rb @@ -29,7 +29,8 @@ class DmsfMailer < Mailer files = files.select { |file| file.notify? } redmine_headers 'Project' => project.identifier if project @files = files - @project = project + @project = project + 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)}" @@ -41,7 +42,8 @@ class DmsfMailer < Mailer files = files.select { |file| file.notify? } redmine_headers 'Project' => project.identifier if project @files = files - @project = project + @project = project + message_id project set_language_if_valid user.language mail :to => user.mail, :subject => "[#{@project.name} - #{l(:menu_dmsf)}] #{l(:text_email_doc_deleted_subject)}" @@ -70,6 +72,7 @@ class DmsfMailer < Mailer end set_language_if_valid user.language @user = user + message_id workflow @workflow = workflow @revision = revision @text1 = l(text1_id, :name => workflow.name, :filename => revision.file.name, :notice => notice) diff --git a/app/models/dmsf_workflow.rb b/app/models/dmsf_workflow.rb index d74b8a0d..6c306edf 100644 --- a/app/models/dmsf_workflow.rb +++ b/app/models/dmsf_workflow.rb @@ -2,7 +2,7 @@ # # Redmine plugin for Document Management System "Features" # -# Copyright (C) 2011-15 Karel Picman +# Copyright (C) 2011-16 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 @@ -20,7 +20,8 @@ class DmsfWorkflow < ActiveRecord::Base - has_many :dmsf_workflow_steps, -> { order 'step ASC, operator DESC' }, :dependent => :destroy + has_many :dmsf_workflow_steps, -> { order 'step ASC, operator DESC' }, :dependent => :destroy + belongs_to :author, :class_name => 'User' scope :sorted, lambda { order('name ASC') } scope :global, lambda { where('project_id IS NULL') } @@ -245,6 +246,7 @@ class DmsfWorkflow < ActiveRecord::Base new_wf = self.dup new_wf.name = name if name new_wf.project_id = project ? project.id : nil + new_wf.author = User.current if new_wf.save self.dmsf_workflow_steps.each do |step| step.copy_to(new_wf) diff --git a/db/migrate/20160222140401_approval_workflow_std_fields.rb b/db/migrate/20160222140401_approval_workflow_std_fields.rb new file mode 100644 index 00000000..edb7bbef --- /dev/null +++ b/db/migrate/20160222140401_approval_workflow_std_fields.rb @@ -0,0 +1,34 @@ +# encoding: utf-8 +# +# Redmine plugin for Document Management System "Features" +# +# Copyright (C) 2011-16 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 +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class ApprovalWorkflowStdFields < ActiveRecord::Migration + def self.up + add_column :dmsf_workflows, :updated_on, :timestamp + add_column :dmsf_workflows, :created_on, :datetime + add_column :dmsf_workflows, :author_id, :integer + DmsfWorkflow.update_all 'updated_on = now(), created_on = now(), author_id = (select id from users where admin = 1 limit 1)' + end + + def self.down + remove_column :dmsf_workflows, :updated_on + remove_column :dmsf_workflows, :created_on + remove_column :dmsf_workflows, :author_id + end +end \ No newline at end of file