Extracts attachment change handler to module

pull/522/head
Hagen Schink 11 years ago committed by Till Breuer
parent a270705afc
commit fa45f187f6
  1. 10
      app/models/message.rb
  2. 10
      app/models/work_package.rb
  3. 41
      lib/open_project/journal/attachment_helper.rb

@ -29,6 +29,8 @@
class Message < ActiveRecord::Base
include Redmine::SafeAttributes
include OpenProject::Journal::AttachmentHelper
belongs_to :board
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
acts_as_tree :counter_cache => :replies_count, :order => "#{Message.table_name}.created_on ASC"
@ -133,12 +135,4 @@ class Message < ActiveRecord::Base
watchers(true)
watcher_users(true)
end
# ACTS AS ATTACHABLE
def attachments_changed(obj)
unless new_record?
add_journal
save!
end
end
end

@ -36,6 +36,8 @@ class WorkPackage < ActiveRecord::Base
include WorkPackage::SchedulingRules
include WorkPackage::StatusTransitions
include OpenProject::Journal::AttachmentHelper
# >>> issues.rb >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include Redmine::SafeAttributes
@ -283,14 +285,6 @@ class WorkPackage < ActiveRecord::Base
!due_date.nil? && (due_date < Date.today) && !status.is_closed?
end
# ACTS AS ATTACHABLE
def attachments_changed(obj)
unless new_record?
add_journal
save
end
end
# ACTS AS JOURNALIZED
def activity_type
"work_packages"

@ -0,0 +1,41 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2013 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# 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.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
module OpenProject
module Journal
module AttachmentHelper
def attachments_changed(obj)
unless new_record?
add_journal
save
end
end
end
end
end
Loading…
Cancel
Save