Workaround a regression in ChiliProject 2.x with setting journal attributes

https://www.chiliproject.org/issues/622
This commit is contained in:
Eric Davis
2011-09-14 13:31:43 -07:00
parent 668b1e0991
commit 38c22e2f92
3 changed files with 21 additions and 0 deletions
+5
View File
@@ -280,6 +280,11 @@ class Deliverable < ActiveRecord::Base
end
end
# Required attribute for AAJ's JournalFormatter
def name
title
end
# Accessors from the budget plugin that need to be wrapped
def subject
warn "[DEPRECATION] Deliverable#subject is deprecated. Please use Deliverable#title instead."
@@ -8,6 +8,11 @@ module RedmineContracts
# * :detail => Detail about the journal change
#
def helper_issues_show_detail_after_setting(context = { })
# This will be skipped in ChiliProject 2.x because
# acts_as_journalized overrides the prop_key with the label
# 'deliverable_id' becomes 'Deliverable' (i18n)
#
# register_on_journal_formatter is used for ChiliProject 2.x support
# TODO Later: Overwritting the caller is bad juju
if context[:detail].prop_key == 'deliverable_id'
context[:detail].reload
@@ -12,6 +12,17 @@ module RedmineContracts
delegate :title, :to => :deliverable, :prefix => true, :allow_nil => true
delegate :contract, :to => :deliverable, :allow_nil => true
# ChiliProject 2.x support for acts_as_journalized.
# Used to format the journal details on the Issue page
#
# See RedmineContracts::Hooks::HelperIssuesShowDetailAfterSettingHook
# for <2.x and Redmine version
#
# TODO: Will not support permissions or custom code in the formatter.
if Issue.respond_to?(:register_on_journal_formatter)
register_on_journal_formatter(:named_association, 'deliverable_id')
end
def contract_name
contract.try(:name)
end