[Rt-commit] [rtir] 15/24: Switch TicketType to use Lifecycle calls

Jesse Vincent jesse at bestpractical.com
Mon Feb 9 00:25:22 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 a5d8d9da11868c5f24f01e433240ba45ff16e483
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Sun Feb 8 19:33:28 2015 -0800

    Switch TicketType to use Lifecycle calls
---
 html/Callbacks/RTIR/Elements/MakeClicky/Default |  2 +-
 html/Callbacks/RTIR/Elements/Tabs/Privileged    | 22 +++++++++++-----------
 html/RTIR/Display.html                          |  2 +-
 html/RTIR/Elements/ShowChildren                 | 13 ++++---------
 html/RTIR/Incident/Children/index.html          |  4 ++--
 5 files changed, 19 insertions(+), 24 deletions(-)

diff --git a/html/Callbacks/RTIR/Elements/MakeClicky/Default b/html/Callbacks/RTIR/Elements/MakeClicky/Default
index b2f6bfe..c97fc05 100644
--- a/html/Callbacks/RTIR/Elements/MakeClicky/Default
+++ b/html/Callbacks/RTIR/Elements/MakeClicky/Default
@@ -222,7 +222,7 @@ ${$ARGS{handle}} = sub {
 
     if ($args{object}) {
         if ( $args{object}->isa('RT::Ticket') ) {
-            $args{type} = RT::IR::TicketType( Queue => $args{object}->QueueObj->Name );
+            $args{type} = RT::IR::TicketType( Lifecycle => $args{object}->QueueObj->Lifecycle );
 
             $args{incident} = $args{object}->id
               if $args{type} && $args{type} eq 'Incident';
diff --git a/html/Callbacks/RTIR/Elements/Tabs/Privileged b/html/Callbacks/RTIR/Elements/Tabs/Privileged
index 0a355da..6cdd458 100644
--- a/html/Callbacks/RTIR/Elements/Tabs/Privileged
+++ b/html/Callbacks/RTIR/Elements/Tabs/Privileged
@@ -139,8 +139,7 @@ if ( $request_path =~ m{^/RTIR/(?:$re_rtir_types/)?(Display|Edit|Update|Forward|
     $ticket->Load($id);
     $id = $ticket->id;
 
-    my $queue = $ticket->QueueObj;
-    my $type = RT::IR::TicketType( Queue => $queue );
+    my $type = RT::IR::TicketType( Lifecycle => $ticket->QueueObj->Lifecycle );
 
     my %can;
     my $can = sub {
@@ -236,7 +235,7 @@ if ( $request_path =~ m{^/RTIR/(?:$re_rtir_types/)?(Display|Edit|Update|Forward|
 
     my $i = 0;
     my $status = $ticket->Status;
-    my $lifecycle = $queue->LifecycleObj;
+    my $lifecycle = $ticket->QueueObj->LifecycleObj;
     foreach my $info ( $lifecycle->Actions( $status ) ) {
         my $next = $info->{'to'};
         next unless $lifecycle->IsTransition( $status => $next );
@@ -295,8 +294,9 @@ if ( $request_path =~ m{^/RTIR/(?:$re_rtir_types/)?(Display|Edit|Update|Forward|
     );
 } elsif ( $request_path =~ m{^/RTIR/Link/(ToIncident|FromIncident)/} ) {
     my $direction = $1;
-    my $queue = $args->{'Queue'};
-    my $type = RT::IR::TicketType( Queue => $queue || 'Incidents' );
+
+    my $lifecycle = $args->{'Lifecycle'};
+    my $type = RT::IR::TicketType( Lifecycle => $lifecycle || 'incidents' );
 
     my $ticket = RT::Ticket->new( $session{'CurrentUser'} );
     $ticket->Load( $args->{'id'} );
@@ -305,7 +305,7 @@ if ( $request_path =~ m{^/RTIR/(?:$re_rtir_types/)?(Display|Edit|Update|Forward|
     my %args = (
         $search_arguments->(),
         id => $id,
-        Queue => $queue,
+        Lifecycle => $lifecycle,
     );
 
     PageMenu()->child(
@@ -328,8 +328,8 @@ if ( $request_path =~ m{^/RTIR/(?:$re_rtir_types/)?(Display|Edit|Update|Forward|
         path => "/RTIR/Display.html?id=$id",
     );
 } elsif ( $request_path =~ m{^/RTIR/Incident/Children/} ) {
-    my $queue = $args->{'Queue'} || 'Incident Reports';
-    my $type = RT::IR::TicketType( Queue => $queue );
+    my $lifecycle = $args->{'Lifecycle'} || 'incident_reports';
+    my $type = RT::IR::TicketType( Lifecycle => $lifecycle );
 
     my $ticket = RT::Ticket->new( $session{'CurrentUser'} );
     $ticket->Load( $args->{'id'} );
@@ -337,12 +337,12 @@ if ( $request_path =~ m{^/RTIR/(?:$re_rtir_types/)?(Display|Edit|Update|Forward|
 
     my %args = (
         id => $id,
-        Queue => $queue,
+        Lifecycle => $lifecycle,
     );
 
     PageMenu()->child(
         new => title => loc("New $type"),
-        path => "/RTIR/Create.html?". $query_string->( Incident => $id, Queue => $queue ),
+        path => "/RTIR/Create.html?". $query_string->( Incident => $id, Lifecycle => $lifecycle ),
     );
     PageMenu()->child(
         back => title => loc('Back to ticket #[_1]', $id),
@@ -412,7 +412,7 @@ if ( $request_path =~ m{^/RTIR/(?:$re_rtir_types/)?(Display|Edit|Update|Forward|
         my (undef, @queues) = RT::IR->OurQuery( $args{'Query'} );
         $queue = $queues[0] if @queues == 1;
     }
-    my $type = RT::IR::TicketType( Queue => $queue ) || '';
+    my $type = RT::IR::TicketType( Lifecycle => $lifecycle ) || '';
 
     $args{'Queue'} = $queue if $queue;
 
diff --git a/html/RTIR/Display.html b/html/RTIR/Display.html
index c029259..c216102 100644
--- a/html/RTIR/Display.html
+++ b/html/RTIR/Display.html
@@ -169,7 +169,7 @@ unless ( $id eq 'new' ) {
     $QueueObj->Load($Queue) || Abort(loc("Queue could not be loaded."));
 }
 
-my $Type = RT::IR::TicketType( Queue => $QueueObj );
+my $Type = RT::IR::TicketType( Lifecycle => $QueueObj->Lifecycle );
 return $m->comp( '/Ticket/Display.html', %ARGS ) unless $Type;
 
 if ($Type eq 'Block' && RT->Config->Get('RTIR_DisableBlocksQueue') ) {
diff --git a/html/RTIR/Elements/ShowChildren b/html/RTIR/Elements/ShowChildren
index 006314b..d64ab58 100644
--- a/html/RTIR/Elements/ShowChildren
+++ b/html/RTIR/Elements/ShowChildren
@@ -82,22 +82,17 @@
 
 <%INIT>
 
-my $QueueObj = RT::Queue->new( $session{'CurrentUser'} );
-$QueueObj->Load( $Queue );
-unless ( $QueueObj->id ) {
-    RT->Logger->error("Couldn't load queue '$Queue'");
-    return;
-}
+my $LifecycleObj = RT::Lifecycle->Load(Name => $Lifecycle);
 
- at Statuses = $QueueObj->LifecycleObj->Valid('initial', 'active') unless @Statuses;
+ at Statuses = $LifecycleObj->Valid('initial', 'active') unless @Statuses;
 
-my $Type = RT::IR::TicketType( Queue => $Queue );
+my $Type = RT::IR::TicketType( Lifecycle => $Lifecycle );
 
 $Format ||= RT->Config->Get('RTIRSearchResultFormats')->{'Child' . $Type};
 
 my $children = RT::Tickets->new( $session{'CurrentUser'} );
 $children->FromSQL( RT::IR->Query(
-    Queue    => $Queue,
+    Lifecycle=> $Lifecycle,
     MemberOf => $Ticket,
     Status   => [@Statuses],
 ));
diff --git a/html/RTIR/Incident/Children/index.html b/html/RTIR/Incident/Children/index.html
index d989cb5..a3edf60 100644
--- a/html/RTIR/Incident/Children/index.html
+++ b/html/RTIR/Incident/Children/index.html
@@ -51,9 +51,9 @@
 <& /Elements/ListActions, actions => \@results &>
 
 % if( $children->CountAll == $all_children->CountAll ) {
-<h2><% loc('Total [_1]: [_2]', $Queue, $children->CountAll) %></h2>
+<h2><% loc('Total [_1]: [_2]', RT::IR->TicketType(Lifecycle => $Lifecycle), $children->CountAll) %></h2>
 % } else {
-<h2><% loc('Total [_1]: [_2]([_3])', $Queue, $children->CountAll, $all_children->CountAll) %></h2>
+<h2><% loc('Total [_1]: [_2]([_3])', RT::IR->TicketType(Lifecycle => $Lifecycle), $children->CountAll, $all_children->CountAll) %></h2>
 % }
 
 <form action="index.html" method="post">

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


More information about the rt-commit mailing list