[Rt-commit] rt branch, 3.8/overridable-approval-notes, created. rt-3.8.10-12-g5f6509d

Kevin Falcone falcone at bestpractical.com
Thu Jun 23 20:08:02 EDT 2011


The branch, 3.8/overridable-approval-notes has been created
        at  5f6509da75d9845536b9faafe1adbbfaec236fbe (commit)

- Log -----------------------------------------------------------------
commit 5f6509da75d9845536b9faafe1adbbfaec236fbe
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Jun 23 20:02:50 2011 -0400

    Refactor the note logic so you can change it
    
    Otherwise you get to copy the whole thing to make a minor change, like
    not sending all your internal comments in the Approval or Reject
    stage....

diff --git a/lib/RT/Approval/Rule/Passed.pm b/lib/RT/Approval/Rule/Passed.pm
index 1618e6e..65d90d1 100644
--- a/lib/RT/Approval/Rule/Passed.pm
+++ b/lib/RT/Approval/Rule/Passed.pm
@@ -62,13 +62,7 @@ sub Prepare {
 
 sub Commit {
     my $self = shift;
-    my $note;
-    my $t = $self->TicketObj->Transactions;
-
-    while ( my $o = $t->Next ) {
-        next unless $o->Type eq 'Correspond';
-        $note .= $o->Content . "\n" if $o->ContentObj;
-    }
+    my $note = $self->GetNotes;
 
     my ($top) = $self->TicketObj->AllDependedOnBy( Type => 'ticket' );
     my $links  = $self->TicketObj->DependedOnBy;
@@ -108,4 +102,17 @@ sub Commit {
     return;
 }
 
+sub GetNotes {
+    my $self = shift;
+    my $t = $self->TicketObj->Transactions;
+    my $note = '';
+
+    while ( my $o = $t->Next ) {
+        next unless $o->Type eq 'Correspond';
+        $note .= $o->Content . "\n" if $o->ContentObj;
+    }
+    return $note;
+
+}
+
 1;
diff --git a/lib/RT/Approval/Rule/Rejected.pm b/lib/RT/Approval/Rule/Rejected.pm
index b10f5f0..73cb0bc 100644
--- a/lib/RT/Approval/Rule/Rejected.pm
+++ b/lib/RT/Approval/Rule/Rejected.pm
@@ -65,14 +65,7 @@ sub Commit {    # XXX: from custom prepare code
     my $self = shift;
     if ( my ($rejected) =
         $self->TicketObj->AllDependedOnBy( Type => 'ticket' ) ) {
-        my $note = '';
-        if ( RT->Config->Get('ApprovalRejectionNotes') ) {
-            my $t = $self->TicketObj->Transactions;
-            while ( my $o = $t->Next ) {
-                next unless $o->Type eq 'Correspond';
-                $note .= $o->Content . "\n" if $o->ContentObj;
-            }
-        }
+        my $note = $self->GetNotes;
 
         my $template = $self->GetTemplate('Approval Rejected',
                                           TicketObj => $rejected,
@@ -112,4 +105,18 @@ sub Commit {    # XXX: from custom prepare code
 
 }
 
+sub GetNotes {
+    my $self = shift;
+    my $note = '';
+
+    if ( RT->Config->Get('ApprovalRejectionNotes') ) {
+        my $t = $self->TicketObj->Transactions;
+        while ( my $o = $t->Next ) {
+            next unless $o->Type eq 'Correspond';
+            $note .= $o->Content . "\n" if $o->ContentObj;
+        }
+    }
+    return $note;
+}
+
 1;

-----------------------------------------------------------------------


More information about the Rt-commit mailing list