Redmine 4.1.1

This commit is contained in:
Manuel Cillero 2020-11-22 21:20:06 +01:00
parent 33e7b881a5
commit 3d976f1b3b
1593 changed files with 36180 additions and 19489 deletions

View file

@ -1,5 +1,7 @@
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2006-2019 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -26,7 +28,6 @@ class Journal < ActiveRecord::Base
belongs_to :user
has_many :details, :class_name => "JournalDetail", :dependent => :delete_all, :inverse_of => :journal
attr_accessor :indice
attr_protected :id
acts_as_event :title => Proc.new {|o| status = ((s = o.new_status) ? " (#{s})" : nil); "#{o.issue.tracker} ##{o.issue.id}#{status}: #{o.issue.subject}" },
:description => :notes,
@ -43,7 +44,7 @@ class Journal < ActiveRecord::Base
" (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')").distinct
before_create :split_private_notes
after_commit :send_notification, :on => :create
after_create_commit :send_notification
scope :visible, lambda {|*args|
user = args.shift || User.current
@ -54,10 +55,12 @@ class Journal < ActiveRecord::Base
where(Journal.visible_notes_condition(user, :skip_pre_condition => true))
}
safe_attributes 'notes',
:if => lambda {|journal, user| journal.new_record? || journal.editable_by?(user)}
safe_attributes 'private_notes',
:if => lambda {|journal, user| user.allowed_to?(:set_notes_private, journal.project)}
safe_attributes(
'notes',
:if => lambda {|journal, user| journal.new_record? || journal.editable_by?(user)})
safe_attributes(
'private_notes',
:if => lambda {|journal, user| user.allowed_to?(:set_notes_private, journal.project)})
# Returns a SQL condition to filter out journals with notes that are not visible to user
def self.visible_notes_condition(user=User.current, options={})
@ -95,19 +98,6 @@ class Journal < ActiveRecord::Base
end
end
def each_notification(users, &block)
if users.any?
users_by_details_visibility = users.group_by do |user|
visible_details(user)
end
users_by_details_visibility.each do |visible_details, users|
if notes? || visible_details.any?
yield(users)
end
end
end
end
# Returns the JournalDetail for the given attribute, or nil if the attribute
# was not updated
def detail_for_attribute(attribute)
@ -138,7 +128,7 @@ class Journal < ActiveRecord::Base
# Returns a string of css classes
def css_classes
s = 'journal'
s = +'journal'
s << ' has-notes' unless notes.blank?
s << ' has-details' unless details.blank?
s << ' private-notes' if private_notes?
@ -320,7 +310,8 @@ class Journal < ActiveRecord::Base
(Setting.notified_events.include?('issue_note_added') && notes.present?) ||
(Setting.notified_events.include?('issue_status_updated') && new_status.present?) ||
(Setting.notified_events.include?('issue_assigned_to_updated') && detail_for_attribute('assigned_to_id').present?) ||
(Setting.notified_events.include?('issue_priority_updated') && new_value_for('priority_id').present?)
(Setting.notified_events.include?('issue_priority_updated') && new_value_for('priority_id').present?) ||
(Setting.notified_events.include?('issue_fixed_version_updated') && detail_for_attribute('fixed_version_id').present?)
)
Mailer.deliver_issue_edit(self)
end