[Rt-commit] rt branch, 4.0/hardcoded-status-setters, created. rt-4.0.0-411-g3d7f7b0

Alex Vandiver alexmv at bestpractical.com
Thu May 19 17:02:54 EDT 2011


The branch, 4.0/hardcoded-status-setters has been created
        at  3d7f7b03dfabf94bc3268afbf40a031052e2054a (commit)

- Log -----------------------------------------------------------------
commit 343631a6af6c2680a186815834b72705631cf2f9
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu May 19 14:53:38 2011 -0400

    Remove ->Resolve from test code, though it is not run
    
    The test is ensuring that the code is _not_ run, which is why it still
    passes (the method no longer exists).  Regardless, update the method
    call to remove bad examples from the codebase.

diff --git a/t/api/template-simple.t b/t/api/template-simple.t
index 2848d00..bbdebb3 100644
--- a/t/api/template-simple.t
+++ b/t/api/template-simple.t
@@ -167,10 +167,10 @@ TemplateTest(
 
 is($ticket->Status, 'new', "test setup");
 SimpleTemplateTest(
-    Content => "\ntest { \$Ticket->Resolve }",
-    Output  => "test { \$Ticket->Resolve }",
+    Content => "\ntest { \$Ticket->SetStatus('resolved') }",
+    Output  => "test { \$Ticket->SetStatus('resolved') }",
 );
-is($ticket->Status, 'new', "simple templates can't call ->Resolve");
+is($ticket->Status, 'new', "simple templates can't call ->SetStatus");
 
 # Make sure changing the template's type works
 my $template = RT::Template->new(RT->SystemUser);

commit e7b2653906ed4f3d67bb124e3ad332a281649974
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu May 19 14:54:51 2011 -0400

    Remove unused code which uses nonexistant ->Resolve method
    
    This code dates from RT 1.3, which is also when the last outside
    reference to it in the codebase was removed.  It likely should have been
    removed at that time, or in 2.1.38 when the similar StallDependent was
    finally removed.

diff --git a/lib/RT/Action/ResolveMembers.pm b/lib/RT/Action/ResolveMembers.pm
deleted file mode 100644
index 6d0c879..0000000
--- a/lib/RT/Action/ResolveMembers.pm
+++ /dev/null
@@ -1,102 +0,0 @@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
-# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
-#                                          <sales at bestpractical.com>
-#
-# (Except where explicitly superseded by other copyright notices)
-#
-#
-# LICENSE:
-#
-# This work is made available to you under the terms of Version 2 of
-# the GNU General Public License. A copy of that license should have
-# been provided with this software, but in any event can be snarfed
-# from www.gnu.org.
-#
-# This work is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301 or visit their web page on the internet at
-# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
-#
-#
-# CONTRIBUTION SUBMISSION POLICY:
-#
-# (The following paragraph is not intended to limit the rights granted
-# to you to modify and distribute this software under the terms of
-# the GNU General Public License and is only of importance to you if
-# you choose to contribute your changes and enhancements to the
-# community by submitting them to Best Practical Solutions, LLC.)
-#
-# By intentionally submitting any modifications, corrections or
-# derivatives to this work, or any other work intended for use with
-# Request Tracker, to Best Practical Solutions, LLC, you confirm that
-# you are the copyright holder for those contributions and you grant
-# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
-# royalty-free, perpetual, license to use, copy, create derivative
-# works based on those contributions, and sublicense and distribute
-# those contributions and any derivatives thereof.
-#
-# END BPS TAGGED BLOCK }}}
-
-# This Action will resolve all members of a resolved group ticket
-
-package RT::Action::ResolveMembers;
-use base 'RT::Action';
-require RT::Links;
-
-use strict;
-
-#Do what we need to do and send it out.
-
-#What does this type of Action does
-
-sub Describe  {
-  my $self = shift;
-  return $self->loc("[_1] will resolve all members of a resolved group ticket.", ref $self);
-}
-
-
-sub Prepare  {
-    # nothing to prepare
-    return 1;
-}
-
-sub Commit {
-    my $self = shift;
-
-    my $Links=RT::Links->new(RT->SystemUser);
-    $Links->Limit(FIELD => 'Type', VALUE => 'MemberOf');
-    $Links->Limit(FIELD => 'Target', VALUE => $self->TicketObj->id);
-
-    while (my $Link=$Links->Next()) {
-	# Todo: Try to deal with remote URIs as well
-	next unless $Link->BaseURI->IsLocal;
-	my $base=RT::Ticket->new($self->TicketObj->CurrentUser);
-	# Todo: Only work if Base is a plain ticket num:
-	$base->Load($Link->Base);
-	# I'm afraid this might be a major bottleneck if ResolveGroupTicket is on.
-        $base->Resolve;
-    }
-}
-
-
-# Applicability checked in Commit.
-
-sub IsApplicable  {
-  my $self = shift;
-  1;  
-  return 1;
-}
-
-RT::Base->_ImportOverlays();
-
-1;
-

commit 329e9f4e2ebf0149d93e3e6c3aa988445ca59b75
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu May 19 16:59:10 2011 -0400

    Refactor "next open status" into a method on the ticket

diff --git a/lib/RT/Action/AutoOpen.pm b/lib/RT/Action/AutoOpen.pm
index f442955..525d78c 100644
--- a/lib/RT/Action/AutoOpen.pm
+++ b/lib/RT/Action/AutoOpen.pm
@@ -82,26 +82,18 @@ sub Prepare {
     my $self = shift;
 
     my $ticket = $self->TicketObj;
-    my $lifecycle = $ticket->QueueObj->Lifecycle;
-    my $status = $ticket->Status;
-
-    my @active = $lifecycle->Active;
-    # no change if no active statuses in the lifecycle
-    return 1 unless @active;
-
-    # no change if the ticket is already has first status from the list of active
-    return 1 if lc $status eq lc $active[0];
+    my $next = $ticket->FirstActiveStatus;
+    return 1 unless defined $next;
 
     # no change if the ticket is in initial status and the message is a mail
     # from a requestor
-    return 1 if $lifecycle->IsInitial($status) && $self->TransactionObj->IsInbound;
+    return 1 if $ticket->QueueObj->Lifecycle->IsInitial($ticket->Status)
+        && $self->TransactionObj->IsInbound;
 
     if ( my $msg = $self->TransactionObj->Message->First ) {
         return 1 if ($msg->GetHeader('RT-Control') || '') =~ /\bno-autoopen\b/i;
     }
 
-    my ($next) = grep $lifecycle->IsActive($_), $lifecycle->Transitions($status);
-
     $self->{'set_status_to'} = $next;
 
     return 1;
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index 3ad34cc..d673350 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -1879,6 +1879,29 @@ sub ResolvedObj {
 }
 
 
+=head2 FirstActiveStatus
+
+Returns the first active status that the ticket could transition to,
+according to its current Queue's lifecycle.  This is used in
+L<RT::Action::AutoOpen>, for instance.
+
+=cut
+
+sub FirstActiveStatus {
+    my $self = shift;
+
+    my $lifecycle = $self->QueueObj->Lifecycle;
+    my $status = $self->Status;
+    my @active = $lifecycle->Active;
+    # no change if no active statuses in the lifecycle
+    return undef unless @active;
+
+    # no change if the ticket is already has first status from the list of active
+    return undef if lc $status eq lc $active[0];
+
+    my ($next) = grep $lifecycle->IsActive($_), $lifecycle->Transitions($status);
+    return $next;
+}
 
 =head2 SetStarted
 

commit 3d7f7b03dfabf94bc3268afbf40a031052e2054a
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu May 19 17:02:01 2011 -0400

    ->Open stopped working when lifecycles landed; replace with ->FirstActiveStatus

diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index d673350..e7c6a1c 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -1929,17 +1929,15 @@ sub SetStarted {
         $time_obj->SetToNow();
     }
 
-    #Now that we're starting, open this ticket
-    #TODO do we really want to force this as policy? it should be a scrip
-
-    #We need $TicketAsSystem, in case the current user doesn't have
-    #ShowTicket
-    #
+    # We need $TicketAsSystem, in case the current user doesn't have
+    # ShowTicket
     my $TicketAsSystem = RT::Ticket->new(RT->SystemUser);
     $TicketAsSystem->Load( $self->Id );
-    if ( $TicketAsSystem->Status eq 'new' ) {
-        $TicketAsSystem->Open();
-    }
+    # Now that we're starting, open this ticket
+    # TODO: do we really want to force this as policy? it should be a scrip
+    my $next = $TicketAsSystem->FirstActiveStatus;
+
+    $self->SetStatus( $next ) if defined $next;
 
     return ( $self->_Set( Field => 'Started', Value => $time_obj->ISO ) );
 

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


More information about the Rt-commit mailing list