[Rt-commit] rtir branch, 2.9-trunk, updated. 2.6.1rc1-304-g43dce85

Ruslan Zakirov ruz at bestpractical.com
Mon Aug 22 19:02:56 EDT 2011


The branch, 2.9-trunk has been updated
       via  43dce85974c77552df0eda7268d90d9fe2783a8a (commit)
       via  79526693043b0c836edbcc6815cea71d86386994 (commit)
       via  346eba186f5f3448dc5b3da58af29777b1c9ee77 (commit)
       via  853f419e1d920b4a3e9fe1fd64894ab3004004c4 (commit)
       via  94361da64787bfd939e45bff44c77726cbfdcb4f (commit)
       via  d7e20ae4bd9788f15bfc6283bddacf0e405f2608 (commit)
       via  023079ed17f252ed1b43dd7aae93aecbaf93e5bc (commit)
       via  8f88f3383ee62e30c3b827308bc796dd71d99c4f (commit)
       via  28eb494aa8b5cba8da7a485a7a0ac8e08417249c (commit)
       via  e08c2435d6f509d262e31a73a78e63c758933671 (commit)
       via  1b4620605501777972b14d5ee58dba00c4b23b23 (commit)
       via  7d6b533c5c9e720a157a0339301be856d13b33af (commit)
       via  7d8b9cdbe4551b803f6dc8880c23f87ba9181a9e (commit)
       via  36bf1931d288bc996acaf1bf10608e16a69bb41d (commit)
       via  3d9e5fa1cbef60519979e4bc727f1ec1c5bbac4a (commit)
       via  0cc7b367db2aff31b3e658f41f5a938ba6e7e2a3 (commit)
       via  59ce4f5707935e7d4bc5589314e23a5c7b85bb2d (commit)
       via  9ef56fadb2c22be481215cf6fec29b8cf19d498f (commit)
      from  0856505bdf77a27630c5a8737de74e6da3cbe911 (commit)

Summary of changes:
 TODO.porting_over_RT4                        |    7 +-
 etc/RTIR_Config.pm                           |   65 +++++++++++
 html/Callbacks/RTIR/Elements/Tabs/Privileged |    6 +-
 html/RTIR/Incident/Reply.html                |  158 ++++++++++++--------------
 html/RTIR/Update.html                        |   11 +--
 lib/RT/IR.pm                                 |   30 +++++-
 6 files changed, 176 insertions(+), 101 deletions(-)

- Log -----------------------------------------------------------------
commit 9ef56fadb2c22be481215cf6fec29b8cf19d498f
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Aug 20 01:25:01 2011 +0400

    update TODO

diff --git a/TODO.porting_over_RT4 b/TODO.porting_over_RT4
index df38110..5d145ea 100644
--- a/TODO.porting_over_RT4
+++ b/TODO.porting_over_RT4
@@ -59,9 +59,6 @@
 
 * make Submit buttons names consistent with RT's
 
-* merge all RT::IR->*Query methods into one, they all equivalent,
-  small differences
-
 * move html/RTIR/Incident/LinkArticles.html -> html/RTIR/Link/Articles.html
 
 * html/RTIR/Forward.html still uses plain inputs for addresses

commit 59ce4f5707935e7d4bc5589314e23a5c7b85bb2d
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Aug 20 03:06:54 2011 +0400

    get rid of DefaultStatus argument

diff --git a/html/Callbacks/RTIR/Elements/Tabs/Privileged b/html/Callbacks/RTIR/Elements/Tabs/Privileged
index cec4a1c..1e956b8 100644
--- a/html/Callbacks/RTIR/Elements/Tabs/Privileged
+++ b/html/Callbacks/RTIR/Elements/Tabs/Privileged
@@ -215,8 +215,8 @@ if ( $request_path =~ m{^/RTIR/(?:$re_rtir_types/)?(Display|Edit|Update)\.html$}
             $path .= "?". $m->comp(
                 '/Elements/QueryString',
                 %args,
-                Action        => $update,
-                DefaultStatus => $next,
+                Action => $update,
+                Status => $next,
             );
         } else {
             $path .= "Display.html?". $m->comp(
diff --git a/html/RTIR/Incident/Reply.html b/html/RTIR/Incident/Reply.html
index 7631645..20d9917 100644
--- a/html/RTIR/Incident/Reply.html
+++ b/html/RTIR/Incident/Reply.html
@@ -30,7 +30,6 @@
 
 <form action="Reply.html" method="get">
 <input type="hidden" name="id" value="<% $id %>" />
-<input type="hidden" name="DefaultStatus" value="<% $DefaultStatus %>" />
 <input type="hidden" name="Status" value="<% $Status %>" />
 <input type="hidden" name="All" value="<% $All %>" />
 <input type="hidden" name="Query" value="<% $Query %>" />
@@ -107,15 +106,12 @@ $id = $ARGS{'id'} = $IncidentObj->id;
 
 $m->callback( %ARGS, CallbackName => 'Initial', Ticket => $IncidentObj );
 
-# XXX: we should get rid of DefaultStatus argument at all. use Status
-$Status ||= $DefaultStatus; $DefaultStatus ||= $Status;
-
 my ($title, $SubmitCaption, $SubmitLabel);
-if ($DefaultStatus eq 'resolved') {
+if ($Status eq 'resolved') {
     $title = loc("Resolve Incident #[_1] (including children)", $id);
     $SubmitCaption = loc("Resolve Incident");
     $SubmitLabel = loc("Resolve");
-} elsif ($DefaultStatus eq 'abandoned') {
+} elsif ($Status eq 'abandoned') {
     $title = loc("Abandon Incident #[_1] (including children)", $id);
     $SubmitCaption = loc("Abandon Incident");
     $SubmitLabel = loc("Abandon");
@@ -187,14 +183,14 @@ if ( $SubmitTicket && !$checks_failure ) {
             # XXX: we push into results directly cuz ProcessTicketBasics returns results
             # with leading 'Ticket XX:' string
             push @results, ProcessTicketBasics( TicketObj => $Ticket, ARGSRef
-=> { %ARGS, $ARGS{Status} eq 'abandoned' ? ( Status => 'rejected' ) : () } );
+=> { %ARGS, $Status eq 'abandoned' ? ( Status => 'rejected' ) : () } );
         }
 
         push @results, map { loc("Ticket [_1]: [_2]", $id, $_) } @tempresults;
     }
 
     my $update_incident_state = 1;
-    if ( $DefaultStatus =~ /^(abandoned|resolved)$/) {
+    if ( $Status =~ /^(abandoned|resolved)$/ ) {
         # if we are going to resolve/reject incident then do it only when we've
         # rejected all children that are not linked to another active incident(s)
         my $children = RT::Tickets->new( $session{'CurrentUser'} );
@@ -236,10 +232,10 @@ foreach (qw(SelectedReports SelectedInvestigations SelectedBlocks)) {
 
 my $BaseURL = "RTIR/Incident/Reply.html?".
     $m->comp('/Elements/QueryString',
-        id            => $id,
-        All           => $All,
-        DefaultStatus => $DefaultStatus,
-        Action        => $Action,
+        id     => $id,
+        All    => $All,
+        Status => $Status,
+        Action => $Action,
     );
 
 </%INIT>
@@ -247,8 +243,7 @@ my $BaseURL = "RTIR/Incident/Reply.html?".
 <%ARGS>
 $id              => undef
 $All             => 0
-$DefaultStatus   => ''
-$Status          => $DefaultStatus,
+$Status          => ''
 $Action          => 'Correspond'
 
 $Query           => ''
diff --git a/html/RTIR/Update.html b/html/RTIR/Update.html
index 400a695..7060ab0 100644
--- a/html/RTIR/Update.html
+++ b/html/RTIR/Update.html
@@ -29,10 +29,7 @@
 <form action="Update.html" name="TicketUpdate" method="post" enctype="multipart/form-data">
 <input type="hidden" name="id" value="<% $id %>" />
 <input type="hidden" name="QuoteTransaction" value="<% $ARGS{'QuoteTransaction'} || '' %>" />
-% if ( $ARGS{'Status'} ) {
-<input type="hidden" name="DefaultStatus" value="<% $DefaultStatus %>" />
-<input type="hidden" name="Status" value="<% $DefaultStatus %>" />
-% }
+<input type="hidden" name="Status" value="<% $Status || '' %>" />
 <input type="hidden" name="Action" value="<% $Action || '' %>" />
 <input type="hidden" name="TakeOrStealFirst" value="<% $ARGS{TakeOrStealFirst} || '' %>" />
 
@@ -123,10 +120,6 @@ $m->callback(CallbackName => 'Initial', %ARGS, Ticket => $Ticket);
 
 my $Type = RT::IR::TicketType( Ticket => $Ticket );
 
-$DefaultStatus ||= $ARGS{'Status'} || '';
-$ARGS{'Status'} ||= $DefaultStatus; # XXX: we should get rid of the DefaultStatus
-$DefaultStatus = 'open' if $DefaultStatus eq 'new';
-
 my $title = loc("Update [_1] #[_2] ([_3])", $Type, $id, $Ticket->Subject);
 
 my $CanRespond = 0;
@@ -192,7 +185,7 @@ if ( !$checks_failure && exists $ARGS{SubmitTicket} ) {
 
 <%ARGS>
 $id => undef
-$DefaultStatus => undef
+$Status => undef
 $Action => undef
 @TxnSendMailTo => ()
 $TxnRecipients => ''

commit 0cc7b367db2aff31b3e658f41f5a938ba6e7e2a3
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Aug 20 03:29:02 2011 +0400

    drop custom logic for submit's label on update
    
    this doesn't line up well with custom lifecycles

diff --git a/html/RTIR/Incident/Reply.html b/html/RTIR/Incident/Reply.html
index 20d9917..8997ce8 100644
--- a/html/RTIR/Incident/Reply.html
+++ b/html/RTIR/Incident/Reply.html
@@ -95,7 +95,7 @@
     GnuPGWidget => $gnupg_widget,
 &>
 
-<& /Elements/Submit, Name => "SubmitTicket", Caption => $SubmitCaption, Label => $SubmitLabel &>
+<& /Elements/Submit, Name => "SubmitTicket", Label => loc("Update Incident") &>
 </form>
 
 <%INIT>
@@ -106,18 +106,12 @@ $id = $ARGS{'id'} = $IncidentObj->id;
 
 $m->callback( %ARGS, CallbackName => 'Initial', Ticket => $IncidentObj );
 
-my ($title, $SubmitCaption, $SubmitLabel);
+my $title;
 if ($Status eq 'resolved') {
     $title = loc("Resolve Incident #[_1] (including children)", $id);
-    $SubmitCaption = loc("Resolve Incident");
-    $SubmitLabel = loc("Resolve");
 } elsif ($Status eq 'abandoned') {
     $title = loc("Abandon Incident #[_1] (including children)", $id);
-    $SubmitCaption = loc("Abandon Incident");
-    $SubmitLabel = loc("Abandon");
 } else {
-    $SubmitCaption = loc("Reply to selected correspondents");
-    $SubmitLabel = loc("Reply");
     if ($All) {
         $title = loc("Incident #[_1]: Reply to All", $id);
     } else {

commit 3d9e5fa1cbef60519979e4bc727f1ec1c5bbac4a
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Aug 20 03:58:30 2011 +0400

    simplify Query call with ActiveQuery

diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index ec2cc61..05773ed 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -354,9 +354,8 @@ sub IsLinkedToActiveIncidents {
     my $parent = shift;
 
     my $tickets = RT::Tickets->new( $child->CurrentUser );
-    $tickets->FromSQL( $self->Query(
+    $tickets->FromSQL( $self->ActiveQuery(
         Queue     => 'Incidents',
-        Status    => [ RT::Lifecycle->Load('incidents')->Valid('initial', 'active') ],
         HasMember => $child,
         Exclude   => $parent->id,
     ) );

commit 36bf1931d288bc996acaf1bf10608e16a69bb41d
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Aug 20 04:15:43 2011 +0400

    replace hardcoded status check wiht lifecycles

diff --git a/html/RTIR/Incident/Reply.html b/html/RTIR/Incident/Reply.html
index 8997ce8..7e0b094 100644
--- a/html/RTIR/Incident/Reply.html
+++ b/html/RTIR/Incident/Reply.html
@@ -184,7 +184,7 @@ if ( $SubmitTicket && !$checks_failure ) {
     }
 
     my $update_incident_state = 1;
-    if ( $Status =~ /^(abandoned|resolved)$/ ) {
+    if ( $Status && $IncidentObj->QueueObj->Lifecycle->IsInactive( $Status ) ) {
         # if we are going to resolve/reject incident then do it only when we've
         # rejected all children that are not linked to another active incident(s)
         my $children = RT::Tickets->new( $session{'CurrentUser'} );

commit 7d8b9cdbe4551b803f6dc8880c23f87ba9181a9e
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Aug 20 04:16:56 2011 +0400

    extract code into IncidentHasActiveChildren method

diff --git a/html/RTIR/Incident/Reply.html b/html/RTIR/Incident/Reply.html
index 7e0b094..711413c 100644
--- a/html/RTIR/Incident/Reply.html
+++ b/html/RTIR/Incident/Reply.html
@@ -122,17 +122,7 @@ if ($Status eq 'resolved') {
 my @queues = ('Incident Reports', 'Investigations');
 push @queues, 'Blocks' unless RT->Config->Get('RTIR_DisableBlocksQueue');
 
-my $ActiveStatesQuery = RT::IR->ActiveQuery( Queue => \@queues );
-
-$Query ||= "( $ActiveStatesQuery )";
-
-# TODO: why don't we use RT::IR->ChildrenQuery ?
-my $ActiveChildrenQuery = join ' AND ', map "( $_ )", grep $_,
-    "MemberOf = $id",
-    $ActiveStatesQuery,
-    join ' OR ',
-        map "Queue = '$_'",
-        @queues;
+$Query ||= RT::IR->ActiveQuery( Queue => \@queues );
 
 $m->comp( '/RTIR/Create.html:ProcessAttachments', %ARGS );
 
@@ -187,13 +177,7 @@ if ( $SubmitTicket && !$checks_failure ) {
     if ( $Status && $IncidentObj->QueueObj->Lifecycle->IsInactive( $Status ) ) {
         # if we are going to resolve/reject incident then do it only when we've
         # rejected all children that are not linked to another active incident(s)
-        my $children = RT::Tickets->new( $session{'CurrentUser'} );
-        $children->FromSQL( $ActiveChildrenQuery );
-        while ( my $child = $children->Next ) {
-            next if RT::IR->IsLinkedToActiveIncidents( $child, $IncidentObj );
-            $update_incident_state = 0;
-            last;
-        }
+        $update_incident_state = 0 if RT::IR->IncidentHasActiveChildren( $IncidentObj );
     }
 
     if ( $update_incident_state ) {
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 05773ed..a681e62 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -337,6 +337,23 @@ sub RelevantIncidents {
     return $res;
 }
 
+=head2 IncidentHasActiveChildren
+
+=cut
+
+sub IncidentHasActiveChildren {
+    my $self = shift;
+    my $incident = shift;
+
+    my $children = RT::Tickets->new( $incident->CurrentUser );
+    $children->FromSQL( $self->ActiveQuery( Queue => \@QUEUES, MemberOf => $incident->id ) );
+    while ( my $child = $children->Next ) {
+        next if $self->IsLinkedToActiveIncidents( $child, $incident );
+        return 1;
+    }
+    return 0;
+}
+
 =head2 IsLinkedToActiveIncidents $ChildObj [$IncidentObj]
 
 Returns number of active incidents linked to child ticket

commit 7d6b533c5c9e720a157a0339301be856d13b33af
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Aug 20 05:18:49 2011 +0400

    cross cycles mappings for RTIR's lifecycles
    
    we need a few maps for workflow. define sane defaults

diff --git a/etc/RTIR_Config.pm b/etc/RTIR_Config.pm
index 6332367..20b595c 100644
--- a/etc/RTIR_Config.pm
+++ b/etc/RTIR_Config.pm
@@ -151,6 +151,71 @@ Set(
                 { label => 'Pending Removal', update => 'Comment' },
         ],
     },
+    __maps__ => {
+        'incidents -> incident_reports' => {
+            'open'      => 'open',
+            'resolved'  => 'resolved',
+            'abandoned' => 'rejected',
+        },
+        'incidents -> investigations' => {
+            'open'      => 'open',
+            'resolved'  => 'resolved',
+            'abandoned' => 'resolved',
+        },
+        'incidents -> blocks' => {
+            'open'      => 'active',
+            'resolved'  => 'removed',
+            'abandoned' => 'removed',
+        },
+        'incident_reports -> incidents' => {
+            'new'      => 'open',
+            'open'     => 'open',
+            'resolved' => 'resolved',
+            'rejected' => 'abandoned',
+        },
+        'incident_reports -> investigations' => {
+            'new'      => 'open',
+            'open'     => 'open',
+            'resolved' => 'resolved',
+            'rejected' => 'resolved',
+        },
+        'incident_reports -> blocks' => {
+            'new'      => 'pending activation',
+            'open'     => 'active',
+            'resolved' => 'removed',
+            'rejected' => 'removed',
+        },
+        'investigations -> incidents' => {
+            'open'     => 'open',
+            'resolved' => 'resolved',
+        },
+        'investigations -> incident_reports' => {
+            'open'     => 'open',
+            'resolved' => 'resolved',
+        },
+        'investigations -> blocks' => {
+            'open'     => 'active',
+            'resolved' => 'removed',
+        },
+        'blocks -> incidents' => {
+            'pending activation' => 'open',
+            'active'             => 'open',
+            'pending removal'    => 'open',
+            'removed'            => 'resolved',
+        },
+        'blocks -> incident_reports' => {
+            'pending activation' => 'new',
+            'active'             => 'open',
+            'pending removal'    => 'open',
+            'removed'            => 'resolved',
+        },
+        'blocks -> investigations' => {
+            'pending activation' => 'open',
+            'active'             => 'open',
+            'pending removal'    => 'open',
+            'removed'            => 'resolved',
+        },
+    },
 );
 
 =back

commit 1b4620605501777972b14d5ee58dba00c4b23b23
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Aug 20 05:37:04 2011 +0400

    refactor, get rid of duplicated code

diff --git a/html/RTIR/Incident/Reply.html b/html/RTIR/Incident/Reply.html
index 711413c..c9911c8 100644
--- a/html/RTIR/Incident/Reply.html
+++ b/html/RTIR/Incident/Reply.html
@@ -133,14 +133,20 @@ $m->comp( '/Elements/GnuPG/SignEncryptWidget:Process',
     self => $gnupg_widget,
     QueueObj => $IncidentObj->QueueObj,
 );
+
+my @selected_children;
+foreach my $id( @SelectedReports, @SelectedInvestigations, @SelectedBlocks ) {
+    my $ticket = RT::Ticket->new( $session{'CurrentUser'} );
+    $ticket->Load( $id );
+    unless( $ticket->id ) {
+        push @results, loc( "Ticket [_1]: Couldn't load ticket.", $id );
+        next;
+    }
+    push @children, $ticket;
+}
+
 if ( $SubmitTicket && $gnupg_widget ) {
-    foreach my $id( @SelectedReports, @SelectedInvestigations, @SelectedBlocks ) {
-        my $Ticket = RT::Ticket->new( $session{'CurrentUser'} );
-        $Ticket->Load( $id );
-        unless( $Ticket->id ) {
-            push @results, loc( "Ticket [_1]: Couldn't load ticket.", $id );
-            next;
-        }
+    foreach my $Ticket ( @selected_children ) {
         my $status = $m->comp('/Elements/GnuPG/SignEncryptWidget:Check',
             self      => $gnupg_widget,
             TicketObj => $Ticket,
@@ -150,14 +156,8 @@ if ( $SubmitTicket && $gnupg_widget ) {
 }
 
 if ( $SubmitTicket && !$checks_failure ) {
-    foreach my $id( @SelectedReports, @SelectedInvestigations, @SelectedBlocks ) {
-        my $Ticket = RT::Ticket->new( $session{'CurrentUser'} );
-        $Ticket->Load( $id );
-        unless( $Ticket->id ) {
-            push @results, loc( "Ticket [_1]: Couldn't load ticket.", $id );
-            next;
-        }
-        $id = $Ticket->id;
+    foreach my $Ticket ( @selected_children ) {
+        my $id = $Ticket->id;
 
         my @tempresults;
         $ARGS{'UpdateAttachments'} = delete $session{'Attachments'};

commit e08c2435d6f509d262e31a73a78e63c758933671
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Aug 20 05:38:06 2011 +0400

    we don't need @tempresults

diff --git a/html/RTIR/Incident/Reply.html b/html/RTIR/Incident/Reply.html
index c9911c8..bed2785 100644
--- a/html/RTIR/Incident/Reply.html
+++ b/html/RTIR/Incident/Reply.html
@@ -159,18 +159,18 @@ if ( $SubmitTicket && !$checks_failure ) {
     foreach my $Ticket ( @selected_children ) {
         my $id = $Ticket->id;
 
-        my @tempresults;
         $ARGS{'UpdateAttachments'} = delete $session{'Attachments'};
-        push @tempresults, ProcessUpdateMessage( TicketObj => $Ticket, ARGSRef => \%ARGS );
+        push @results, map { loc("Ticket [_1]: [_2]", $id, $_) },
+            ProcessUpdateMessage( TicketObj => $Ticket, ARGSRef => \%ARGS );
 
         unless ( RT::IR->IsLinkedToActiveIncidents( $Ticket, $IncidentObj ) ) {
             # XXX: we push into results directly cuz ProcessTicketBasics returns results
             # with leading 'Ticket XX:' string
-            push @results, ProcessTicketBasics( TicketObj => $Ticket, ARGSRef
-=> { %ARGS, $Status eq 'abandoned' ? ( Status => 'rejected' ) : () } );
+            push @results, ProcessTicketBasics(
+                TicketObj => $Ticket,
+                ARGSRef => { %ARGS, $Status eq 'abandoned' ? ( Status => 'rejected' ) : () },
+            );
         }
-
-        push @results, map { loc("Ticket [_1]: [_2]", $id, $_) } @tempresults;
     }
 
     my $update_incident_state = 1;

commit 28eb494aa8b5cba8da7a485a7a0ac8e08417249c
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Aug 20 09:40:54 2011 +0400

    enlist invs only if $All argument is true

diff --git a/html/RTIR/Incident/Reply.html b/html/RTIR/Incident/Reply.html
index bed2785..c910ae9 100644
--- a/html/RTIR/Incident/Reply.html
+++ b/html/RTIR/Incident/Reply.html
@@ -119,7 +119,8 @@ if ($Status eq 'resolved') {
     }
 }
 
-my @queues = ('Incident Reports', 'Investigations');
+my @queues = ('Incident Reports');
+push @queues, 'Investigations' if $All;
 push @queues, 'Blocks' unless RT->Config->Get('RTIR_DisableBlocksQueue');
 
 $Query ||= RT::IR->ActiveQuery( Queue => \@queues );

commit 8f88f3383ee62e30c3b827308bc796dd71d99c4f
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Aug 20 09:41:35 2011 +0400

    IncidentChildren method

diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index a681e62..bd72312 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -337,6 +337,16 @@ sub RelevantIncidents {
     return $res;
 }
 
+sub IncidentChildren {
+    my $self = shift;
+    my $ticket = shift;
+    my %args = (Queue => \@QUEUES, @_);
+
+    my $res = RT::Tickets->new( $ticket->CurrentUser );
+    $res->FromSQL( $self->Query( %args, MemberOf => $ticket->id ) );
+    return $res;
+}
+
 =head2 IncidentHasActiveChildren
 
 =cut

commit 023079ed17f252ed1b43dd7aae93aecbaf93e5bc
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Aug 20 09:42:40 2011 +0400

    stop abusing $session{'tickets'}
    
    we don't want to set $session{'tickets'} all the time we show
    collection of tickets. it messes current search in the tabs
    and messes ItemMap

diff --git a/html/RTIR/Incident/Reply.html b/html/RTIR/Incident/Reply.html
index c910ae9..9dc4558 100644
--- a/html/RTIR/Incident/Reply.html
+++ b/html/RTIR/Incident/Reply.html
@@ -36,8 +36,6 @@
 
 <& /Elements/GnuPG/SignEncryptWidget:ShowIssues, self => $gnupg_widget &>
 
-% my $recipients = 0;
-
 <h2><&|/l&>Reporters</&></h2>
 <& /RTIR/Search/Elements/ShowResults,
     Queue         => 'Incident Reports',
@@ -51,7 +49,6 @@
     OrderBy       => $OrderBy,
     Order         => $Order,
 &>
-% $recipients += $session{'tickets'}->CountAll;
 % if ( $All ) {
 <h2><&|/l&>Investigation Correspondents</&></h2>
 <& /RTIR/Search/Elements/ShowResults,
@@ -66,7 +63,6 @@
     OrderBy       => $OrderBy,
     Order         => $Order,
 &>
-% $recipients += $session{'tickets'}->CountAll;
 % unless( RT->Config->Get('RTIR_DisableBlocksQueue') ) {
 <h2><&|/l&>Blocks Correspondents</&></h2>
 <& /RTIR/Search/Elements/ShowResults,
@@ -81,11 +77,10 @@
     OrderBy       => $OrderBy,
     Order         => $Order,
 &>
-% $recipients += $session{'tickets'}->CountAll;
 % }
 % }
 
-% if ($recipients == 0) {
+% unless ( $candidates ) {
 <h2 class="no-recipients">Warning: no recipients!</h2>
 % }
 
@@ -217,6 +212,8 @@ my $BaseURL = "RTIR/Incident/Reply.html?".
         Action => $Action,
     );
 
+my $candidates = RT::IR->IncidentChildren( $IncidentObj, Queue => \@queues )->Count;
+
 </%INIT>
 
 <%ARGS>

commit d7e20ae4bd9788f15bfc6283bddacf0e405f2608
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Aug 20 09:49:13 2011 +0400

    don't deal with status if it's not changed

diff --git a/html/RTIR/Incident/Reply.html b/html/RTIR/Incident/Reply.html
index 9dc4558..9bd1ef2 100644
--- a/html/RTIR/Incident/Reply.html
+++ b/html/RTIR/Incident/Reply.html
@@ -101,6 +101,8 @@ $id = $ARGS{'id'} = $IncidentObj->id;
 
 $m->callback( %ARGS, CallbackName => 'Initial', Ticket => $IncidentObj );
 
+$Status = '' if $Status && $Status eq $IncidentObj->Status;
+
 my $title;
 if ($Status eq 'resolved') {
     $title = loc("Resolve Incident #[_1] (including children)", $id);

commit 94361da64787bfd939e45bff44c77726cbfdcb4f
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sun Aug 21 20:36:09 2011 +0400

    move code after update, no need to exec it always

diff --git a/html/RTIR/Incident/Reply.html b/html/RTIR/Incident/Reply.html
index 9bd1ef2..0e5a1cf 100644
--- a/html/RTIR/Incident/Reply.html
+++ b/html/RTIR/Incident/Reply.html
@@ -103,25 +103,6 @@ $m->callback( %ARGS, CallbackName => 'Initial', Ticket => $IncidentObj );
 
 $Status = '' if $Status && $Status eq $IncidentObj->Status;
 
-my $title;
-if ($Status eq 'resolved') {
-    $title = loc("Resolve Incident #[_1] (including children)", $id);
-} elsif ($Status eq 'abandoned') {
-    $title = loc("Abandon Incident #[_1] (including children)", $id);
-} else {
-    if ($All) {
-        $title = loc("Incident #[_1]: Reply to All", $id);
-    } else {
-        $title = loc("Incident #[_1]: Reply to Reporters", $id);
-    }
-}
-
-my @queues = ('Incident Reports');
-push @queues, 'Investigations' if $All;
-push @queues, 'Blocks' unless RT->Config->Get('RTIR_DisableBlocksQueue');
-
-$Query ||= RT::IR->ActiveQuery( Queue => \@queues );
-
 $m->comp( '/RTIR/Create.html:ProcessAttachments', %ARGS );
 
 my $checks_failure = 0;
@@ -206,6 +187,25 @@ foreach (qw(SelectedReports SelectedInvestigations SelectedBlocks)) {
     }
 }
 
+my $title;
+if ($Status eq 'resolved') {
+    $title = loc("Resolve Incident #[_1] (including children)", $id);
+} elsif ($Status eq 'abandoned') {
+    $title = loc("Abandon Incident #[_1] (including children)", $id);
+} else {
+    if ($All) {
+        $title = loc("Incident #[_1]: Reply to All", $id);
+    } else {
+        $title = loc("Incident #[_1]: Reply to Reporters", $id);
+    }
+}
+
+my @queues = ('Incident Reports');
+push @queues, 'Investigations' if $All;
+push @queues, 'Blocks' unless RT->Config->Get('RTIR_DisableBlocksQueue');
+
+$Query ||= RT::IR->ActiveQuery( Queue => \@queues );
+
 my $BaseURL = "RTIR/Incident/Reply.html?".
     $m->comp('/Elements/QueryString',
         id     => $id,

commit 853f419e1d920b4a3e9fe1fd64894ab3004004c4
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Aug 23 01:42:33 2011 +0400

    use cycles mapping when replying via Incident

diff --git a/html/RTIR/Incident/Reply.html b/html/RTIR/Incident/Reply.html
index 0e5a1cf..18bf117 100644
--- a/html/RTIR/Incident/Reply.html
+++ b/html/RTIR/Incident/Reply.html
@@ -121,7 +121,7 @@ foreach my $id( @SelectedReports, @SelectedInvestigations, @SelectedBlocks ) {
         push @results, loc( "Ticket [_1]: Couldn't load ticket.", $id );
         next;
     }
-    push @children, $ticket;
+    push @selected_children, $ticket;
 }
 
 if ( $SubmitTicket && $gnupg_widget ) {
@@ -135,25 +135,38 @@ if ( $SubmitTicket && $gnupg_widget ) {
 }
 
 if ( $SubmitTicket && !$checks_failure ) {
+    $ARGS{'UpdateAttachments'} = delete $session{'Attachments'};
+
+    my $incident_cycle = $IncidentObj->QueueObj->Lifecycle;
     foreach my $Ticket ( @selected_children ) {
         my $id = $Ticket->id;
 
-        $ARGS{'UpdateAttachments'} = delete $session{'Attachments'};
-        push @results, map { loc("Ticket [_1]: [_2]", $id, $_) },
+        push @results, map { loc("Ticket [_1]: [_2]", $id, $_) }
             ProcessUpdateMessage( TicketObj => $Ticket, ARGSRef => \%ARGS );
 
+        my %additional;
+        if ( $Status ) {
+            $additional{'Status'} = $incident_cycle->MoveMap(
+                $Ticket->QueueObj->Lifecycle
+            )->{ $Status };
+            unless ( $additional{'Status'} ) {
+                RT->Logger->error(
+                    "No mapping for $Status in Incidents queue"
+                    .' to status in '. $Ticket->QueueObj->Name .' queue'
+                );
+            }
+        }
+
         unless ( RT::IR->IsLinkedToActiveIncidents( $Ticket, $IncidentObj ) ) {
-            # XXX: we push into results directly cuz ProcessTicketBasics returns results
-            # with leading 'Ticket XX:' string
             push @results, ProcessTicketBasics(
                 TicketObj => $Ticket,
-                ARGSRef => { %ARGS, $Status eq 'abandoned' ? ( Status => 'rejected' ) : () },
+                ARGSRef => { %ARGS, %additional },
             );
         }
     }
 
     my $update_incident_state = 1;
-    if ( $Status && $IncidentObj->QueueObj->Lifecycle->IsInactive( $Status ) ) {
+    if ( $Status && $incident_cycle->IsInactive( $Status ) ) {
         # if we are going to resolve/reject incident then do it only when we've
         # rejected all children that are not linked to another active incident(s)
         $update_incident_state = 0 if RT::IR->IncidentHasActiveChildren( $IncidentObj );

commit 346eba186f5f3448dc5b3da58af29777b1c9ee77
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Aug 23 01:46:03 2011 +0400

    attach files to all children when replying via Inc

diff --git a/TODO.porting_over_RT4 b/TODO.porting_over_RT4
index 5d145ea..ce12c2b 100644
--- a/TODO.porting_over_RT4
+++ b/TODO.porting_over_RT4
@@ -86,6 +86,10 @@
 
 === TESTS
 
+* add tests to make sure attachments attached to all selected Children when
+  replying via Incident
+
+
 Test Summary Report
 -------------------
 t/incident/bulk-abandon.t                     (Wstat: 65280 Tests: 87 Failed: 0)

commit 79526693043b0c836edbcc6815cea71d86386994
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Aug 23 02:01:04 2011 +0400

    overwrite Status in args in case we changed it

diff --git a/html/RTIR/Incident/Reply.html b/html/RTIR/Incident/Reply.html
index 18bf117..5d42bf1 100644
--- a/html/RTIR/Incident/Reply.html
+++ b/html/RTIR/Incident/Reply.html
@@ -173,8 +173,12 @@ if ( $SubmitTicket && !$checks_failure ) {
     }
 
     if ( $update_incident_state ) {
-        push @results, ProcessObjectCustomFieldUpdates( Object => $IncidentObj, ARGSRef => \%ARGS);
-        push @results, ProcessTicketBasics( TicketObj => $IncidentObj, ARGSRef => \%ARGS );
+        push @results, ProcessObjectCustomFieldUpdates(
+            Object => $IncidentObj, ARGSRef => \%ARGS
+        );
+        push @results, ProcessTicketBasics(
+            TicketObj => $IncidentObj, ARGSRef => { %ARGS, Status => $Status },
+        );
     } else {
         push @results, loc("Status of the Incident left unchanged; not all children were updated");
     }

commit 43dce85974c77552df0eda7268d90d9fe2783a8a
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Aug 23 02:47:35 2011 +0400

    show incidents' menu on Reply page

diff --git a/html/Callbacks/RTIR/Elements/Tabs/Privileged b/html/Callbacks/RTIR/Elements/Tabs/Privileged
index 1e956b8..cc28851 100644
--- a/html/Callbacks/RTIR/Elements/Tabs/Privileged
+++ b/html/Callbacks/RTIR/Elements/Tabs/Privileged
@@ -92,7 +92,7 @@ my $search_arguments = sub {
     return %res;
 };
 
-if ( $request_path =~ m{^/RTIR/(?:$re_rtir_types/)?(Display|Edit|Update)\.html$} ) {
+if ( $request_path =~ m{^/RTIR/(?:$re_rtir_types/)?(Display|Edit|Update|Reply)\.html$} ) {
     my $id = $args->{'id'};
 
     # we'll never get here unless ticket is there and it's rtir's type

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


More information about the Rt-commit mailing list