[Rt-commit] r17137 - in rt/3.8/branches/ruleset: etc lib/RT lib/RT/Approval/Rule
clkao at bestpractical.com
clkao at bestpractical.com
Sun Dec 7 09:38:56 EST 2008
Author: clkao
Date: Sun Dec 7 09:38:56 2008
New Revision: 17137
Modified:
rt/3.8/branches/ruleset/etc/initialdata
rt/3.8/branches/ruleset/lib/RT/Approval/Rule/Passed.pm
rt/3.8/branches/ruleset/lib/RT/Template_Overlay.pm
rt/3.8/branches/ruleset/t/approval/basic.t
Log:
- only correspond txn content should be approver's note.
- when approval passed, use the associated template for sending
correspond rather than calling notify action and comment.
- no longer needs the T:: hack in template.
- put $Notes into the approval templates.
Modified: rt/3.8/branches/ruleset/etc/initialdata
==============================================================================
--- rt/3.8/branches/ruleset/etc/initialdata (original)
+++ rt/3.8/branches/ruleset/etc/initialdata Sun Dec 7 09:38:56 2008
@@ -326,6 +326,8 @@
Your ticket has been approved by { eval { $Approval->OwnerObj->Name } }.
Other approvals may be pending.
+
+Approver\'s notes: { $Notes }
'
},
{ Queue => '___Approvals',
@@ -336,7 +338,10 @@
Greetings,
-Your ticket has been approved. Its Owner may now start to act on it.
+Your ticket has been approved by { eval { $Approval->OwnerObj->Name } }.
+Its Owner may now start to act on it.
+
+Approver\'s notes: { $Notes }
'
},
{ Queue => '___Approvals',
@@ -348,6 +353,8 @@
Greetings,
Your ticket has been rejected by { eval { $Approval->OwnerObj->Name } }.
+
+Approver\'s notes: { $Notes }
'
},
{ Queue => 0,
Modified: rt/3.8/branches/ruleset/lib/RT/Approval/Rule/Passed.pm
==============================================================================
--- rt/3.8/branches/ruleset/lib/RT/Approval/Rule/Passed.pm (original)
+++ rt/3.8/branches/ruleset/lib/RT/Approval/Rule/Passed.pm Sun Dec 7 09:38:56 2008
@@ -18,43 +18,33 @@
my $t = $self->TicketObj->Transactions;
while ( my $o = $t->Next ) {
- $note .= $o->Content . "\n" if $o->ContentObj
- and $o->Content !~ /Default Approval/;
+ next unless $o->Type eq 'Correspond';
+ $note .= $o->Content . "\n" if $o->ContentObj;
}
- my ($Approval) = $self->TicketObj->AllDependedOnBy( Type => 'ticket' );
+ my ($top) = $self->TicketObj->AllDependedOnBy( Type => 'ticket' );
my $links = $self->TicketObj->DependedOnBy;
- my $passed = 0;
while ( my $link = $links->Next ) {
my $obj = $link->BaseObj;
- next if ( $obj->HasUnresolvedDependencies( Type => 'approval' ) );
+ next unless $obj->Type eq 'approval';
+ next if $obj->HasUnresolvedDependencies( Type => 'approval' );
- if ( $obj->Type eq 'ticket' ) {
- $obj->Comment(
- Content => $self->loc("Your request has been approved."),
- );
- $passed = 1;
- }
- elsif ( $obj->Type eq 'approval' ) {
- $obj->SetStatus( Status => 'open', Force => 1 );
- }
+ $obj->SetStatus( Status => 'open', Force => 1 );
}
- unless ($passed) {
- $Approval->Comment(
- Content => $self->loc( "Your request has been approved by [_1]. Other approvals may still be pending.", # loc
- $self->TransactionObj->CreatorObj->Name,
- ) . "\n" . $self->loc( "Approver's notes: [_1]", # loc
- $note
- ),
- );
- }
+ my $passed = !$top->HasUnresolvedDependencies( Type => 'approval' );
+ my $template = RT::Template->new($self->CurrentUser);
+ $template->Load($passed ? 'All Approvals Passed' : 'Approval Passed')
+ or die;
+
+ my ($result, $msg) = $template->Parse(
+ TicketObj => $top,
+ Approval => $self->TicketObj,
+ Notes => $note,
+ );
- $T::Approval = $self->TicketObj; # so we can access it inside templates
- $self->RunScripAction('Notify Requestors',
- $passed ? 'All Approvals Passed' : 'Approval Passed',
- TicketObj => $Approval,
- );
+ $top->Correspond( MIMEObj => $template->MIMEObj );
+ return;
}
1;
Modified: rt/3.8/branches/ruleset/lib/RT/Template_Overlay.pm
==============================================================================
--- rt/3.8/branches/ruleset/lib/RT/Template_Overlay.pm (original)
+++ rt/3.8/branches/ruleset/lib/RT/Template_Overlay.pm Sun Dec 7 09:38:56 2008
@@ -414,7 +414,6 @@
my $is_broken = 0;
my $retval = $template->fill_in(
- PACKAGE => 'T',
HASH => \%args,
BROKEN => sub {
my (%args) = @_;
Modified: rt/3.8/branches/ruleset/t/approval/basic.t
==============================================================================
--- rt/3.8/branches/ruleset/t/approval/basic.t (original)
+++ rt/3.8/branches/ruleset/t/approval/basic.t Sun Dec 7 09:38:56 2008
@@ -8,7 +8,7 @@
or plan skip_all => 'require Email::Abstract and Test::Email';
}
-plan tests => 28;
+plan tests => 29;
use RT;
use RT::Test;
@@ -138,6 +138,14 @@
$cfo->Load( $user_a );
$dependson_cfo->CurrentUser($cfo);
+ my $notes = MIME::Entity->build(
+ Data => [ 'Resources exist to be consumed.' ]
+ );
+ RT::I18N::SetMIMEEntityToUTF8($notes); # convert text parts into utf-8
+
+ my ( $notesval, $notesmsg ) = $dependson_cfo->Correspond( MIMEObj => $notes );
+ ok($notesval, $notesmsg);
+
my ($ok, $msg) = $dependson_cfo->SetStatus( Status => 'resolved' );
ok($ok, "cfo can approve - $msg");
@@ -145,10 +153,10 @@
to => 'ceo at company.com',
subject => qr/New Pending Approval: PO approval request for PO/,
body => qr/pending your approval/
-},{ from => qr/CFO via RT/,
+},{ from => qr/RT System/,
to => 'minion at company.com',
subject => qr/Ticket Approved:/,
- body => qr/approved by CFO/
+ body => qr/approved by CFO.*notes: Resources exist to be consumed/s
};
is ($t->DependsOn->Count, 1, "still depends only on the CEO approval");
More information about the Rt-commit
mailing list