[Rt-commit] [rtir] 01/14: Start to factor hardcoded lifecycle names out of RTIR application code

Jesse Vincent jesse at bestpractical.com
Wed Feb 18 20:55:03 EST 2015


This is an automated email from the git hooks/post-receive script.

jesse pushed a commit to branch 3.4/remove_old_constituencies
in repository rtir.

commit a8ba4ee987a04e397d9e13eddb08779c9a6dc572
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Wed Feb 18 14:27:16 2015 -0800

    Start to factor hardcoded lifecycle names out of RTIR application code
    
    Moving the lifecycle names out of the code will make it easier to
    customize lifecycles and to test the codebase to ensure that we're
    not depending on the old queue name based behavior anywhere.
    
    And it's just cleaner
---
 html/RTIR/Merge/index.html | 21 ++++++++++-----------
 lib/RT/IR.pm               |  6 ++++++
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/html/RTIR/Merge/index.html b/html/RTIR/Merge/index.html
index 17f934b..37b4527 100644
--- a/html/RTIR/Merge/index.html
+++ b/html/RTIR/Merge/index.html
@@ -69,10 +69,10 @@
 
 <& /RTIR/Elements/MergeWith, %defaults, %ARGS, Lifecycle => $Ticket->QueueObj->Lifecycle, Ticket => $Ticket &>
 
-% if ( $Type eq 'Report' ) {
-<& /RTIR/Elements/MergeWith, %defaults, %ARGS, Lifecycle => "investigations", Ticket => $Ticket &>
-% } elsif ( $Type eq 'Investigation' ) {
-<& /RTIR/Elements/MergeWith, %defaults, %ARGS, Lifecycle => "incident_reports", Ticket => $Ticket &>
+% if ( $Lifecycle eq RT::IR->lifecycle_report) {
+<& /RTIR/Elements/MergeWith, %defaults, %ARGS, Lifecycle => RT::IR->lifecycle_investigation, Ticket => $Ticket &>
+% } elsif ( $Lifecycle eq RT::IR->lifecycle_investigation) {
+<& /RTIR/Elements/MergeWith, %defaults, %ARGS, Lifecycle => RT::IR->lifecycle_report, Ticket => $Ticket &>
 % }
 <& /Elements/Submit, Caption=> loc('Merge into selected Ticket'), Label => loc("Merge") &>
 </form>
@@ -92,7 +92,7 @@ if ( $MergeTicket ) {
     my @lifecycles = sort map $_->Lifecycle, $Ticket->QueueObj, $MergeTicket->QueueObj;
     unless (
         $lifecycles[0] eq $lifecycles[1]
-        or ($lifecycles[0] eq "incident_reports" and $lifecycles[1] eq "investigations")
+        or ($lifecycles[0] eq RT::IR->lifecycle_report and $lifecycles[1] eq RT::IR->lifecycle_investigation)
     ) {
         push @results, loc("Merge failed: Ticket #[_1] is not the right type", $MergeTicket->Id );
         $checks_failure = 1;
@@ -102,7 +102,7 @@ if ( $MergeTicket ) {
 if ( $MergeTicket && !$checks_failure ) {
 
     my @lifecycles = sort map $_->Lifecycle, $Ticket->QueueObj, $MergeTicket->QueueObj;
-    if ( $lifecycles[0] ne $lifecycles[1] && $lifecycles[1] eq "incident_reports" ) {
+    if ( $lifecycles[0] ne $lifecycles[1] && $lifecycles[1] eq RT::IR->lifecycle_report ) {
         # We always want to merge into the Investigation
         ($Ticket, $MergeTicket) = ($MergeTicket, $Ticket);
     }
@@ -128,10 +128,9 @@ if ( $MergeTicket && !$checks_failure ) {
     );
 }
 
-my $Type = RT::IR::TicketType( Ticket => $Ticket );
 my $Lifecycle = $Ticket->QueueObj->Lifecycle;
 
-my $title = loc("Merge [_1] #[_2]: [_3]", $Type, $id, $Ticket->Subject);
+my $title = loc("Merge [_1] #[_2]: [_3]", RT::IR::TicketType( Ticket => $Ticket), $id, $Ticket->Subject);
 
 $Query      ||= RT::IR->ActiveQuery( Lifecycle => $Lifecycle );
 my $BaseQuery = RT::IR->Query( Lifecycle => $Lifecycle, Exclude => $id);
@@ -145,12 +144,12 @@ my %defaults = (
 );
 
 my $siblings_query = '';
-if ( $Type ne 'Incident' ) {
+if ( $Lifecycle ne RT::IR->lifecycle_incident) {
     my @parents = @{ RT::IR->Incidents( $Ticket )->ItemsArrayRef || [] };
     if ( @parents ) {
         my @lifecycles = ($Lifecycle);
-        push @lifecycles, 'investigations' if $Type eq 'Report';
-        push @lifecycles, 'incident_reports' if $Type eq 'Investigation';
+        push @lifecycles, RT::IR->lifecycle_investigation if $Lifecycle eq RT::IR->lifecycle_report;
+        push @lifecycles, RT::IR->lifecycle_report if $Lifecycle eq RT::IR->lifecycle_investigation;
         $siblings_query = RT::IR->Query(
             Lifecycle    => \@lifecycles,
             MemberOf => \@parents,
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 55f3215..86e9612 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -81,6 +81,12 @@ my %FRIENDLY_LIFECYCLE = (
 
 );
 
+sub lifecycle_report {'incident_report'}
+sub lifecycle_incident {'incident'}
+sub lifecycle_investigation {'investigation'}
+sub lifecycle_countermeasure {'blocks'}
+
+
 use Parse::BooleanLogic;
 my $ticket_sql_parser = Parse::BooleanLogic->new;
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the rt-commit mailing list