[Rt-commit] r17183 - in rt/3.8/branches/ruleset/lib/RT/Approval: .
clkao at bestpractical.com
clkao at bestpractical.com
Fri Dec 12 06:32:20 EST 2008
Author: clkao
Date: Fri Dec 12 06:32:19 2008
New Revision: 17183
Modified:
rt/3.8/branches/ruleset/lib/RT/Approval/Rule.pm
rt/3.8/branches/ruleset/lib/RT/Approval/Rule/NewPending.pm
rt/3.8/branches/ruleset/lib/RT/Approval/Rule/Passed.pm
rt/3.8/branches/ruleset/lib/RT/Approval/Rule/Rejected.pm
Log:
refactor common approval templating code.
Modified: rt/3.8/branches/ruleset/lib/RT/Approval/Rule.pm
==============================================================================
--- rt/3.8/branches/ruleset/lib/RT/Approval/Rule.pm (original)
+++ rt/3.8/branches/ruleset/lib/RT/Approval/Rule.pm Fri Dec 12 06:32:19 2008
@@ -12,5 +12,16 @@
$self->TicketObj->Type eq 'approval';
}
+sub GetTemplate {
+ my ($self, $template_name, %args) = @_;
+ my $template = RT::Template->new($self->CurrentUser);
+ $template->Load($template_name) or return;
+ my ($result, $msg) = $template->Parse(%args);
+
+ # XXX: error handling
+
+ return $template;
+}
+
1;
Modified: rt/3.8/branches/ruleset/lib/RT/Approval/Rule/NewPending.pm
==============================================================================
--- rt/3.8/branches/ruleset/lib/RT/Approval/Rule/NewPending.pm (original)
+++ rt/3.8/branches/ruleset/lib/RT/Approval/Rule/NewPending.pm Fri Dec 12 06:32:19 2008
@@ -33,13 +33,13 @@
# this generates more correct content of the message, but not sure
# if ccmessageto is the right way to do this.
- my $template = RT::Template->new($self->CurrentUser);
- $template->Load('New Pending Approval')
- or die;
+ my $template = $self->GetTemplate('New Pending Approval',
+ TicketObj => $top,
+ TransactionObj => $to)
+ or return;
my ( $result, $msg ) = $template->Parse(
TicketObj => $top,
- TransactionObj => $to,
);
$self->TicketObj->Comment( CcMessageTo => $self->TicketObj->OwnerObj->EmailAddress,
MIMEObj => $template->MIMEObj );
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 Fri Dec 12 06:32:19 2008
@@ -33,15 +33,12 @@
}
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(
+ my $template = $self->GetTemplate(
+ $passed ? 'All Approvals Passed' : 'Approval Passed',
TicketObj => $top,
Approval => $self->TicketObj,
Notes => $note,
- );
+ ) or die;
$top->Correspond( MIMEObj => $template->MIMEObj );
return;
Modified: rt/3.8/branches/ruleset/lib/RT/Approval/Rule/Rejected.pm
==============================================================================
--- rt/3.8/branches/ruleset/lib/RT/Approval/Rule/Rejected.pm (original)
+++ rt/3.8/branches/ruleset/lib/RT/Approval/Rule/Rejected.pm Fri Dec 12 06:32:19 2008
@@ -17,15 +17,11 @@
my $self = shift;
if ( my ($rejected) =
$self->TicketObj->AllDependedOnBy( Type => 'ticket' ) ) {
- my $template = RT::Template->new( $self->CurrentUser );
- $template->Load('Approval Rejected')
- or die;
-
- my ( $result, $msg ) = $template->Parse(
- TicketObj => $rejected,
- Approval => $self->TicketObj,
- Notes => '',
- );
+ my $template = $self->GetTemplate('Approval Rejected',
+ TicketObj => $rejected,
+ Approval => $self->TicketObj,
+ Notes => '')
+ or return;
$rejected->Correspond( MIMEObj => $template->MIMEObj );
$rejected->SetStatus(
More information about the Rt-commit
mailing list