[Rt-commit] rtir branch, 2.9-trunk, updated. 2.6.1rc1-327-g70d6d6c

Ruslan Zakirov ruz at bestpractical.com
Thu Aug 25 12:54:01 EDT 2011


The branch, 2.9-trunk has been updated
       via  70d6d6c203e8d13e88d13e9dfcad61145165b09f (commit)
       via  4df5890824a1e559bd0dadcb9505fc2e48715aaa (commit)
       via  1b240c1c8169841b26b207c19c8ca31a4bab1ef6 (commit)
       via  3db519e87d3510f37a72380aa5f467f04fdcdde0 (commit)
       via  e0702e3bfa7279270768c25280a3fac81597bb94 (commit)
       via  1ffa9b49a710a0f49a0319164a906217c36128e2 (commit)
       via  cbb2cec845615efff77f6342f8fa4ae828296c1e (commit)
       via  bf0ca25e65661ee8a41db89d58bec671c0f12a5b (commit)
       via  7b6535da1e51f60530f455444decc45e227ce00f (commit)
       via  6bac4a1d9f0241b21fdc8d774a1d60f8741ddbdc (commit)
       via  0c1cd1ba4fed299906ff09aa8565e52635288bdc (commit)
       via  efb25cc7918d54a5c9a5a774e2f09b96002e116a (commit)
       via  7044f2f1071441d7be0e67ffb81cb85229cfb5c0 (commit)
       via  bad34e8efc87c7e3d4e2aba67077af5fd2db3f2b (commit)
       via  7c6dadb366bcdeb16f1e6e69c5f3dbeba6e4244c (commit)
       via  a28338ce815b229a53e2ae02de3a205a96417361 (commit)
      from  87b6d1d53f715c5482604f03b92510716051e7ac (commit)

Summary of changes:
 META.yml                                           |    1 +
 Makefile.PL                                        |    2 +
 TODO.porting_over_RT4                              |   16 +----
 etc/RTIR_Config.pm                                 |    5 +-
 etc/initialdata                                    |    1 +
 html/Callbacks/RTIR/Elements/ListActions/ModifyRow |   21 ------
 html/Callbacks/RTIR/Elements/Tabs/Privileged       |   18 ++++--
 html/Callbacks/RTIR/RTFM/Elements/Tabs/Default     |    9 ---
 .../Search/Elements/PickCFs/MassageCustomFields    |    8 ---
 html/Callbacks/RTIR/Search/Results.html/Initial    |   17 +++++
 html/Callbacks/RTIR/Ticket/Create.html/Default     |   16 ++++-
 html/Callbacks/RTIR/User/Elements/Tabs/Default     |    9 ---
 html/RTIR/Elements/QueueSummary                    |   52 ---------------
 html/RTIR/Elements/UpdateData                      |    2 +-
 html/RTIR/Incident/BulkAbandon.html                |   54 +++++++++-------
 html/RTIR/Incident/Reply.html                      |   15 +----
 html/RTIR/Prefs/Home.html                          |    5 +-
 lib/RT/IR.pm                                       |   67 ++++++++++++++++++++
 t/incident/bulk-abandon.t                          |   13 ++--
 19 files changed, 161 insertions(+), 170 deletions(-)
 delete mode 100644 html/Callbacks/RTIR/Elements/ListActions/ModifyRow
 delete mode 100644 html/Callbacks/RTIR/RTFM/Elements/Tabs/Default
 delete mode 100644 html/Callbacks/RTIR/Search/Elements/PickCFs/MassageCustomFields
 create mode 100644 html/Callbacks/RTIR/Search/Results.html/Initial
 delete mode 100644 html/Callbacks/RTIR/User/Elements/Tabs/Default
 delete mode 100644 html/RTIR/Elements/QueueSummary

- Log -----------------------------------------------------------------
commit a28338ce815b229a53e2ae02de3a205a96417361
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Aug 25 05:37:26 2011 +0400

    OurQuery method: check if a query searches in RTIR

diff --git a/META.yml b/META.yml
index 1caf53c..5b74519 100644
--- a/META.yml
+++ b/META.yml
@@ -29,6 +29,7 @@ requires:
   DBIx::SearchBuilder: 1.51
   Hook::LexWrap: 0
   Net::Whois::RIPE: 0
+  Parse::BooleanLogic: 0
   Regexp::Common: 0
   perl: 5.8.3
 resources:
diff --git a/Makefile.PL b/Makefile.PL
index 9e29e86..60ad1cf 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -33,6 +33,8 @@ requires('Net::Whois::RIPE');
 # IP searching
 requires('Hook::LexWrap');
 requires('Regexp::Common');
+# queries parsing
+requires('Parse::BooleanLogic');
 
 # for tests
 build_requires('Test::More');
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index bd72312..c23c5a0 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -74,6 +74,9 @@ my %TYPE = (
     'blocks'           => 'Block',
 );
 
+use Parse::BooleanLogic;
+my $ticket_sql_parser = Parse::BooleanLogic->new;
+
 =head1 FUNCTIONS
 
 =head2 BusinessHours
@@ -301,6 +304,32 @@ sub Query {
     return join ' AND ', @res;
 }
 
+sub OurQuery {
+    my $self = shift;
+    my $query = shift;
+
+    my ($has_our, $has_other, @queues) = (0, 0);
+    $ticket_sql_parser->walk(
+        RT::SQL::ParseToArray( $query ),
+        { operand => sub {
+            return undef unless $_[0]->{'key'} =~ /^Queue(?:\z|\.)/;
+            my $queue = RT::Queue->new( RT->SystemUser );
+            $queue->Load( $_[0]->{'value'} );
+            my $our = $self->OurQueue( $queue );
+            my ($negative) = RT::Tickets->ClassifySQLOperation( $_[0]->{'op'} );
+            if ( $our && !$negative ) {
+                $has_our = 1;
+                push @queues, $queue->Name;
+            } else {
+                $has_other = 1;
+            }
+        } },
+    );
+    return unless $has_our && !$has_other;
+    return 1 unless wantarray;
+    return (1, @queues);
+}
+
 =head2 Incidents
 
 Takes a ticket and returns collection of all incidents this ticket

commit 7c6dadb366bcdeb16f1e6e69c5f3dbeba6e4244c
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Aug 25 05:38:43 2011 +0400

    redirect if RT's Results.html is only about RTIR

diff --git a/html/Callbacks/RTIR/Search/Results.html/Initial b/html/Callbacks/RTIR/Search/Results.html/Initial
new file mode 100644
index 0000000..9a26d41
--- /dev/null
+++ b/html/Callbacks/RTIR/Search/Results.html/Initial
@@ -0,0 +1,17 @@
+<%ARGS>
+$ARGSRef => {}
+</%ARGS>
+<%INIT>
+my ($our, @queues) = RT::IR->OurQuery( $ARGSRef->{'Query'} );
+return unless $our;
+
+RT::Interface::Web::Redirect(
+    RT->Config->Get('WebURL')
+    .'RTIR/Search/Results.html?'
+    . $m->comp(
+        '/Elements/QueryString',
+        %$ARGSRef,
+        @queues == 1? (Queue => $queues[0]) : (Queue => undef)
+    )
+);
+</%INIT>
\ No newline at end of file

commit bad34e8efc87c7e3d4e2aba67077af5fd2db3f2b
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Aug 25 05:40:14 2011 +0400

    refresh RTIR_HomepageComponents with RT's new comps

diff --git a/etc/RTIR_Config.pm b/etc/RTIR_Config.pm
index 20b595c..1855779 100644
--- a/etc/RTIR_Config.pm
+++ b/etc/RTIR_Config.pm
@@ -416,12 +416,14 @@ Set(@RTIR_HomepageComponents, qw(
     MyAdminQueues
     MySupportQueues
     MyReminders
+    RefreshHomepage
+    Dashboards
+    SavedSearches
     /RTIR/Elements/NewReports
     /RTIR/Elements/UserDueIncidents
     /RTIR/Elements/NobodyDueIncidents
     /RTIR/Elements/DueIncidents
     /RTIR/Elements/QueueSummary
-    RefreshHomepage
 ));
 
 =item C<@Active_MakeClicky>

commit 7044f2f1071441d7be0e67ffb81cb85229cfb5c0
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Aug 25 05:43:08 2011 +0400

    RTIR's custom QueueSummary goes, we can use RT's

diff --git a/TODO.porting_over_RT4 b/TODO.porting_over_RT4
index ce12c2b..2e34635 100644
--- a/TODO.porting_over_RT4
+++ b/TODO.porting_over_RT4
@@ -22,6 +22,9 @@
 * upgrade script that renames wrongly named scrips, we have
   a few scrips that named wrongly
 
+* replace /RTIR/Elements/QueueSummary with RT's QuickSearch
+  in user's settings for RTIR's home page
+
 === BRINGING UP TO DATE
 
 * Some pages with forms need new nice layouts like in RT, reply
diff --git a/etc/RTIR_Config.pm b/etc/RTIR_Config.pm
index 1855779..adb41a2 100644
--- a/etc/RTIR_Config.pm
+++ b/etc/RTIR_Config.pm
@@ -423,7 +423,6 @@ Set(@RTIR_HomepageComponents, qw(
     /RTIR/Elements/UserDueIncidents
     /RTIR/Elements/NobodyDueIncidents
     /RTIR/Elements/DueIncidents
-    /RTIR/Elements/QueueSummary
 ));
 
 =item C<@Active_MakeClicky>
diff --git a/html/RTIR/Elements/QueueSummary b/html/RTIR/Elements/QueueSummary
deleted file mode 100644
index 2b563a3..0000000
--- a/html/RTIR/Elements/QueueSummary
+++ /dev/null
@@ -1,52 +0,0 @@
-<%ATTR>
-Description => loc('RTIR queues summary')
-</%ATTR>
-<&| /Widgets/TitleBox,
-	title_class => 'inverse',
-    title => loc('RTIR queues summary'),
-    bodyclass=> '',
-&>
-
-<table border="0" cellspacing="0" cellpadding="1" width="100%">
-<tr>
-       <th class="collection-as-table"><&|/l&>Queue</&></th>
-% foreach my $s( @states ) {
-       <th class="collection-as-table"><% $s %></th>
-% }
-</tr>
-% my $i;
-% for my $queue (@queues) {
-%   $i++;
-%   my $queue_cond = "Queue = '$queue'";
-%   my $all_q = "$queue_cond AND (". join( ' OR ', map "Status = '$_'", @{ $states{ $queue } } ).')';
-<tr class="<% $i%2 ? 'oddline' : 'evenline'%>" >
-<td><a href="<% RT->Config->Get('WebPath')%>/Search/Results.html?Query=<% $all_q |un %>""><% $queue %></a></td>
-%   foreach my $s ( @states ) {
-<td align="right">
-%   if ( grep $_ eq $s, @{ $states{ $queue } } ) {
-%       my $query =  "$queue_cond AND Status = '$s'";
-%       $Tickets->FromSQL( $query );
-%       my $qs = $m->comp('/Elements/QueryString', Queue => $queue, Query => $query );
-<a href="<% RT->Config->Get('WebPath') %>/RTIR/Search/Results.html?<% $qs |n %>"><% $Tickets->Count %></a></td>
-%   } else {
--
-%   }
-</td>
-%   }
-</tr>
-% }
-</table>
-
-</&>
-<%ONCE>
-my @queues = ('Incidents', 'Incident Reports', 'Investigations');
-push @queues, 'Blocks' unless RT->Config->Get('DisableBlocksQueue');
-my %states;
-$states{$_} = [ RT::IR->Statuses( Queue => $_ ) ] foreach @queues;
-my @states = RT::IR->Statuses( Queue => \@queues );
-</%ONCE>
-<%INIT>
-my $Tickets = RT::Tickets->new($session{'CurrentUser'});
-</%INIT>
-<%ARGS>
-</%ARGS>

commit efb25cc7918d54a5c9a5a774e2f09b96002e116a
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Aug 25 05:52:17 2011 +0400

    no need to modify rows in ListActions
    
    * we have no _RTIR_ fields
    * status changes are ok
    * @skiplist argument wasn't used and didn't work

diff --git a/html/Callbacks/RTIR/Elements/ListActions/ModifyRow b/html/Callbacks/RTIR/Elements/ListActions/ModifyRow
deleted file mode 100644
index ea2ae0f..0000000
--- a/html/Callbacks/RTIR/Elements/ListActions/ModifyRow
+++ /dev/null
@@ -1,21 +0,0 @@
-<%INIT>
-
-# $row is passed by reference
-
-# skip things that start with skiplist items
-foreach my $item ( grep $_, @skiplist ) {
-    if ( substr( $$row, 0, length($item) ) eq $item ) {
-        return $$skip = 1;
-    }
-}
-
-# get out of here if we are not in RTIR space
-return unless $m->request_comp->path =~ m{^/RTIR/};
-
-</%INIT>
-
-<%ARGS>
-$row => undef
- at skiplist => undef
-$skip => 0
-</%ARGS>

commit 0c1cd1ba4fed299906ff09aa8565e52635288bdc
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Aug 25 05:54:30 2011 +0400

    remove tabs callback for RTFM
    
    purpose was to put RTIR into RTFM's top menu

diff --git a/html/Callbacks/RTIR/RTFM/Elements/Tabs/Default b/html/Callbacks/RTIR/RTFM/Elements/Tabs/Default
deleted file mode 100644
index d208f81..0000000
--- a/html/Callbacks/RTIR/RTFM/Elements/Tabs/Default
+++ /dev/null
@@ -1,9 +0,0 @@
-<%ARGS>
-$toptabs => {}
-</%ARGS>
-<%INIT>
-$toptabs->{'b'} = {
-    title => loc('RTIR'),
-    path  => 'RTIR/index.html',
-};
-</%INIT>

commit 6bac4a1d9f0241b21fdc8d774a1d60f8741ddbdc
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Aug 25 05:59:31 2011 +0400

    no custom fields with _RTIR prefix

diff --git a/html/Callbacks/RTIR/Search/Elements/PickCFs/MassageCustomFields b/html/Callbacks/RTIR/Search/Elements/PickCFs/MassageCustomFields
deleted file mode 100644
index 589376f..0000000
--- a/html/Callbacks/RTIR/Search/Elements/PickCFs/MassageCustomFields
+++ /dev/null
@@ -1,8 +0,0 @@
-<%args>
-$CustomFields => undef
-
-</%args>
-<%init>
-# We never want to see the RTIR custom fields in the edity ui
-$CustomFields->Limit( FIELD => 'Name', OPERATOR => 'NOT STARTSWITH', VALUE => '_RTIR');
-</%init>

commit 7b6535da1e51f60530f455444decc45e227ce00f
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Aug 25 06:01:57 2011 +0400

    use OurQueue method for queue check

diff --git a/html/Callbacks/RTIR/Ticket/Create.html/Default b/html/Callbacks/RTIR/Ticket/Create.html/Default
index 432f19f..200e1f3 100644
--- a/html/Callbacks/RTIR/Ticket/Create.html/Default
+++ b/html/Callbacks/RTIR/Ticket/Create.html/Default
@@ -1,6 +1,5 @@
 <%INIT>
-return unless $QueueObj && $QueueObj->id;
-return unless $QueueObj->Name =~ /^(Incidents|Incident Reports|Investigations|Blocks)$/i;
+return unless RT::IR->OurQueue( $QueueObj );
 $m->subexec( '/RTIR/Create.html', %$ARGSRef, Queue => $QueueObj->Name );
 $m->abort;
 </%INIT>

commit bf0ca25e65661ee8a41db89d58bec671c0f12a5b
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Aug 25 06:15:08 2011 +0400

    use redirect on create if arguments are simple
    
    subexec doesn't deal with menu really well

diff --git a/html/Callbacks/RTIR/Ticket/Create.html/Default b/html/Callbacks/RTIR/Ticket/Create.html/Default
index 200e1f3..ecf4134 100644
--- a/html/Callbacks/RTIR/Ticket/Create.html/Default
+++ b/html/Callbacks/RTIR/Ticket/Create.html/Default
@@ -1,7 +1,16 @@
 <%INIT>
 return unless RT::IR->OurQueue( $QueueObj );
-$m->subexec( '/RTIR/Create.html', %$ARGSRef, Queue => $QueueObj->Name );
-$m->abort;
+
+if ( grep !/^(id|results|Queue)$/, keys %$ARGSRef ) {
+    # for something complex use subexec
+    $m->subexec( '/RTIR/Create.html', %$ARGSRef, Queue => $QueueObj->Name );
+    $m->abort;
+}
+
+my $url = RT->Config->Get('WebURL') .'RTIR/Create.html?'
+    . $m->comp('/Elements/QueryString', %$ARGSRef, Queue => $QueueObj->Name )
+;
+RT::Interface::Web::Redirect( $url );
 </%INIT>
 <%ARGS>
 $QueueObj => undef

commit cbb2cec845615efff77f6342f8fa4ae828296c1e
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Aug 25 06:41:36 2011 +0400

    return 'RTIR at a glance' settings page back

diff --git a/html/Callbacks/RTIR/Elements/Tabs/Privileged b/html/Callbacks/RTIR/Elements/Tabs/Privileged
index cc28851..b0bf64a 100644
--- a/html/Callbacks/RTIR/Elements/Tabs/Privileged
+++ b/html/Callbacks/RTIR/Elements/Tabs/Privileged
@@ -398,10 +398,14 @@ if ( $request_path =~ m{^/RTIR/(?:$re_rtir_types/)?(Display|Edit|Update|Reply)\.
     );
 }
 
-
-if ( $request_path =~ m{^/RTIR/(?:index\.html|)$} ) {
-    PageMenu()->child( edit => title => loc('Edit'), path => '/RTIR/Prefs/MyRT.html' )
-        if $session{'CurrentUser'}->HasRight(Right => 'ModifySelf', Object => $RT::System);
+if ( $session{'CurrentUser'}->HasRight(Right => 'ModifySelf', Object => $RT::System) ) {
+    if ( $request_path =~ m{^/RTIR/(?:index\.html|)$} ) {
+        PageMenu()->child( edit => title => loc('Edit'), path => '/RTIR/Prefs/Home.html' )
+    }
+    Menu->child('preferences')->child('settings')->child(
+        rtir_home_page => title => loc('RTIR at a glance'),
+        path => '/RTIR/Prefs/Home.html',
+    );
 }
 
 PageWidgets()->child('simple_search')->title( $m->scomp(
diff --git a/html/Callbacks/RTIR/User/Elements/Tabs/Default b/html/Callbacks/RTIR/User/Elements/Tabs/Default
deleted file mode 100644
index ffe1a0a..0000000
--- a/html/Callbacks/RTIR/User/Elements/Tabs/Default
+++ /dev/null
@@ -1,9 +0,0 @@
-<%ARGS>
-$tabs => {}
-</%ARGS>
-<%INIT>
-$tabs->{ra} = {
-    title => loc('RTIR Home'),
-    path  => 'RTIR/Prefs/Home.html',
-};
-</%INIT>
diff --git a/html/RTIR/Prefs/Home.html b/html/RTIR/Prefs/Home.html
index 61f1393..bf13a2e 100644
--- a/html/RTIR/Prefs/Home.html
+++ b/html/RTIR/Prefs/Home.html
@@ -1,5 +1,5 @@
-<& /Elements/Header, Title => $title &>
-<& /User/Elements/Tabs, current_tab => 'RTIR/Prefs/Home.html', Title => $title &>
+<& /Elements/Header, Title => loc("Customize '[_1]'", loc("RTIR home page") ) &>
+<& /Elements/Tabs &>
 <& /Elements/ListActions, actions => \@results &>
 
 <& /Widgets/SelectionBox:header, nojs => 1 &>
@@ -16,7 +16,6 @@
 # XXX: copy&past of the similar RT's page
 
 my @results;
-my $title = loc("Customize '[_1]'", loc("RTIR home page") );
 my $user = $session{'CurrentUser'}->UserObj;
 
 unless (exists $session{'my_rtir_portlets'}) {

commit 1ffa9b49a710a0f49a0319164a906217c36128e2
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Aug 25 06:43:32 2011 +0400

    show Quicksearch portlet by default on RTIR's page

diff --git a/etc/initialdata b/etc/initialdata
index 84a0df4..5cf8f12 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -707,6 +707,7 @@ for my $cf (@CustomFields) {
         ],
         summary => [
             { type => 'component', name => 'RefreshHomepage' },
+            { type => 'component', name => 'Quicksearch' },
         ]
     },
 } );

commit e0702e3bfa7279270768c25280a3fac81597bb94
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Aug 25 06:56:38 2011 +0400

    there is no need in Queue argument in AddAttachments
    
    $Ticket can also be undef in UpdateData

diff --git a/html/RTIR/Elements/UpdateData b/html/RTIR/Elements/UpdateData
index 500989d..b70bf43 100644
--- a/html/RTIR/Elements/UpdateData
+++ b/html/RTIR/Elements/UpdateData
@@ -27,7 +27,7 @@
 <& /Ticket/Elements/UpdateCc, %ARGS, TicketObj => $Ticket &>
 % }
 
-<& /Ticket/Elements/AddAttachments, %ARGS, QueueObj => $Ticket->QueueObj &>
+<& /Ticket/Elements/AddAttachments, %ARGS &>
 
 % if ( $Ticket ) {
 <tr><td colspan="2"><& /RTIR/Elements/AttachReports, Ticket => $Ticket &></td></tr>

commit 3db519e87d3510f37a72380aa5f467f04fdcdde0
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Aug 25 08:39:19 2011 +0400

    RT::IR->MapStatus( $status, $from => $to ) method

diff --git a/html/RTIR/Incident/Reply.html b/html/RTIR/Incident/Reply.html
index 5d42bf1..e162ae3 100644
--- a/html/RTIR/Incident/Reply.html
+++ b/html/RTIR/Incident/Reply.html
@@ -144,18 +144,9 @@ if ( $SubmitTicket && !$checks_failure ) {
         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'
-                );
-            }
-        }
+        my %additional = (
+            Status => RT::IR->MapStatus( $Status, $incident_cycle => $Ticket ),
+        );
 
         unless ( RT::IR->IsLinkedToActiveIncidents( $Ticket, $IncidentObj ) ) {
             push @results, ProcessTicketBasics(
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index c23c5a0..d3cabe9 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -418,6 +418,40 @@ sub IsLinkedToActiveIncidents {
     return $tickets->Count;
 }
 
+sub MapStatus {
+    my $self = shift;
+    my ($status, $from, $to) = @_;
+    return unless $status;
+
+    foreach my $e ($from, $to) {
+        if ( blessed $e ) {
+            if ( $e->isa('RT::Queue') ) {
+                $e = $e->Lifecycle;
+            }
+            elsif ( $e->isa('RT::Ticket') ) {
+                $e = $e->QueueObj->Lifecycle;
+            }
+            elsif ( !$e->isa('RT::Lifecycle') ) {
+                $e = undef;
+            }
+        }
+        else {
+            my $queue = RT::Queue->new( RT->SystemUser );
+            $queue->Load( $e );
+            $e = $queue->Lifecycle;
+        }
+        return unless $e;
+    }
+    my $res = $from->MoveMap( $to )->{ $status };
+    unless ( $res ) {
+        RT->Logger->warning(
+            "No mapping for $status in ". $from->Name .' lifecycle'
+            .' to status in '. $to->Name .' lifecycle'
+        );
+    }
+    return $res;
+}
+
 sub GetCustomField {
     my $field = shift or return;
     return (__PACKAGE__->CustomFields( $field ))[0];

commit 1b240c1c8169841b26b207c19c8ca31a4bab1ef6
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Aug 25 08:40:13 2011 +0400

    filter out duplicated queue names in RT::IR->OurQuery

diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index d3cabe9..3b1507c 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -327,6 +327,10 @@ sub OurQuery {
     );
     return unless $has_our && !$has_other;
     return 1 unless wantarray;
+
+    my %seen;
+    @queues = grep !$seen{ lc $_ }++, @queues;
+
     return (1, @queues);
 }
 

commit 4df5890824a1e559bd0dadcb9505fc2e48715aaa
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Aug 25 08:42:10 2011 +0400

    figure out queue for Tabs from Query
    
    if it's not in ARGS

diff --git a/html/Callbacks/RTIR/Elements/Tabs/Privileged b/html/Callbacks/RTIR/Elements/Tabs/Privileged
index b0bf64a..55bdead 100644
--- a/html/Callbacks/RTIR/Elements/Tabs/Privileged
+++ b/html/Callbacks/RTIR/Elements/Tabs/Privileged
@@ -349,7 +349,11 @@ if ( $request_path =~ m{^/RTIR/(?:$re_rtir_types/)?(Display|Edit|Update|Reply)\.
     );
 } elsif ( $request_path =~ m{^/RTIR/(Search/|Incident/BulkAbandon\.html$)} ) {
     my $queue = $args->{'Queue'} || '';
-    my $type = RT::IR::TicketType( Queue => $queue );
+    unless ( $queue ) {
+        my (undef, @queues) = RT::IR->OurQuery( $args->{'Query'} );
+        $queue = $queues[0] if @queues == 1;
+    }
+    my $type = RT::IR::TicketType( Queue => $queue ) || '';
 
     my %args = (
         $search_arguments->(),

commit 70d6d6c203e8d13e88d13e9dfcad61145165b09f
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Aug 25 08:48:26 2011 +0400

    return back bulk abandon

diff --git a/TODO.porting_over_RT4 b/TODO.porting_over_RT4
index 2e34635..5b3b29e 100644
--- a/TODO.porting_over_RT4
+++ b/TODO.porting_over_RT4
@@ -44,8 +44,6 @@
 
 * Don't see Articles on IR's Update.html
 
-* BulkAbandon needs a lot of love. see TODO comments
-
 * BulkAbandon misses Query arguments when updated
 
 * /Incident/Reply.html needs refine query page
@@ -92,14 +90,3 @@
 * 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)
-  Non-zero exit status: 255
-  Parse errors: Bad plan.  You planned 105 tests but ran 87.
-Files=37, Tests=2440, 1512 wallclock secs ( 0.80 usr  0.36 sys + 411.18 cusr 33.56 csys = 445.90 CPU)
-Result: FAIL
-Failed 3/37 test programs. 3/2440 subtests failed.
-make: *** [test_dynamic] Ошибка 255
-
diff --git a/html/RTIR/Incident/BulkAbandon.html b/html/RTIR/Incident/BulkAbandon.html
index 5f6aa0f..322dbfe 100644
--- a/html/RTIR/Incident/BulkAbandon.html
+++ b/html/RTIR/Incident/BulkAbandon.html
@@ -87,6 +87,8 @@ my ( @results );
 $m->comp( '/RTIR/Create.html:ProcessAttachments', %ARGS );
 
 if ( $ARGS{'BulkAbandon'} ) {
+    $ARGS{'UpdateAttachments'} = delete $session{'Attachments'};
+
     my @tempresults;
     foreach my $id ( @SelectedTickets ) {
         $m->out('<!--  Processing <% $t->id %> -->'); $m->flush_buffer;
@@ -105,38 +107,41 @@ if ( $ARGS{'BulkAbandon'} ) {
         }
 
         # process replies
-        if( scalar @ReplyToAll ) {
-            # XXX: why do we limit to open?
-            # RT4 TODO
-            my $query = "Status = 'open' AND MemberOf = $id";
-            $query .= " AND (". join(' OR ', map "Queue = '$_'", @ReplyToAll) .")";
-            my $members = RT::Tickets->new( $t->CurrentUser );
-            $members->FromSQL( $query );
-            while( my $member = $members->Next ) {
-                $ARGS{'UpdateAttachments'} = delete $session{'Attachments'} if $session{'Attachments'};
-                push @tempresults, ProcessUpdateMessage(TicketObj => $member, ARGSRef => \%ARGS );
+        if ( @ReplyToAll ) {
+            my $children = RT::IR->IncidentChildren(
+                $t, Queue => \@ReplyToAll, Initial => 1, Active => 1,
+            );
+            while ( my $child = $children->Next ) {
+                push @tempresults, ProcessUpdateMessage(
+                    TicketObj => $child, ARGSRef => \%ARGS,
+                );
             }
         }
 
         # process status updates
-        my @tmp;
         {
-            # RT4 TODO
-            my $query = "MemberOf = $id"
-                ." AND ( ". join(" OR ", map "Status = '$_'", RT->Config->Get('ActiveStatus') ) ." )"
-                ." AND ( Queue = 'Incident Reports' OR Queue = 'Blocks' OR Queue = 'Investigations' )";
-
-            my $members = new RT::Tickets( $t->CurrentUser );
-            $members->FromSQL( $query );
-            while( my $member = $members->Next ) {
-                next if RT::IR->IsLinkedToActiveIncidents( $member, $t );
-                push @tmp, $member;
+            my $children = RT::IR->IncidentChildren(
+                $t, Initial => 1, Active => 1,
+            );
+            while ( my $child = $children->Next ) {
+                next if RT::IR->IsLinkedToActiveIncidents( $child, $t );
+
+                push @tempresults, ProcessTicketBasics(
+                    TicketObj => $child,
+                    ARGSRef => {
+                        %ARGS,
+                        Status => RT::IR->MapStatus( $Status, $t => $child ),
+                    },
+                );
             }
         }
 
-        push @tmp, $t;
-        foreach my $t( @tmp ) {
-            push @tempresults, ProcessTicketBasics( ARGSRef => \%ARGS, TicketObj => $t );
+        unless ( RT::IR->IncidentHasActiveChildren( $t ) ) {
+            push @tempresults, ProcessTicketBasics(
+                TicketObj => $t, ARGSRef => { %ARGS, Status => $Status },
+            );
+        } else {
+            push @tempresults, [$t->id, loc("Status of the Incident left unchanged; not all children were updated")];
         }
     }
 
@@ -152,7 +157,6 @@ my $BaseURL = "RTIR/Incident/BulkAbandon.html?"
 
 </%INIT>
 <%ARGS>
-# RT4 TODO
 $Status          => 'abandoned'
 $Queue           => 'Incidents'
 
diff --git a/t/incident/bulk-abandon.t b/t/incident/bulk-abandon.t
index f05e93a..3b078f6 100644
--- a/t/incident/bulk-abandon.t
+++ b/t/incident/bulk-abandon.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use RT::IR::Test tests => 105;
+use RT::IR::Test tests => 112;
 
 RT::Test->started_ok;
 my $agent = default_agent();
@@ -63,12 +63,13 @@ foreach my $id (@incident_ids) {
 	$agent->ticket_status_is( $id, 'abandoned', "Incident $id is abandoned");
 }
 
-foreach my $id (@ir_ids ) {
-	diag("IR #$id state is " . $agent->ticket_status( $id)) if($ENV{'TEST_VERBOSE'});
+foreach my $id ($ir_ids[0]) {
+    $agent->ticket_status_is( $id, 'resolved', 'correct status' );
+}
+foreach my $id (@ir_ids[ 1 .. $#invests ] ) {
+    $agent->ticket_status_is( $id, 'rejected', 'correct status' );
 }
 foreach my $id (@invests) {
-	diag("IR #$id state is " . $agent->ticket_status( $id)) if($ENV{'TEST_VERBOSE'});
+    $agent->ticket_status_is( $id, 'resolved', 'correct status' );
 }
 
-
-

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


More information about the Rt-commit mailing list