[Rt-commit] r16480 - in rt/branches/3.999-DANGEROUS/lib/RT: . Action Model Report Search

ruz at bestpractical.com ruz at bestpractical.com
Tue Oct 21 22:33:35 EDT 2008


Author: ruz
Date: Tue Oct 21 22:33:35 2008
New Revision: 16480

Modified:
   rt/branches/3.999-DANGEROUS/lib/RT/Action/UpdateTicket.pm
   rt/branches/3.999-DANGEROUS/lib/RT/Condition/CloseTicket.pm
   rt/branches/3.999-DANGEROUS/lib/RT/Condition/ReopenTicket.pm
   rt/branches/3.999-DANGEROUS/lib/RT/Model/Ticket.pm
   rt/branches/3.999-DANGEROUS/lib/RT/Record.pm
   rt/branches/3.999-DANGEROUS/lib/RT/Report/Tickets.pm
   rt/branches/3.999-DANGEROUS/lib/RT/Search/ActiveTicketsInQueue.pm
   rt/branches/3.999-DANGEROUS/lib/RT/Search/Googleish.pm

Log:
* use new calls via status_schema

Modified: rt/branches/3.999-DANGEROUS/lib/RT/Action/UpdateTicket.pm
==============================================================================
--- rt/branches/3.999-DANGEROUS/lib/RT/Action/UpdateTicket.pm	(original)
+++ rt/branches/3.999-DANGEROUS/lib/RT/Action/UpdateTicket.pm	Tue Oct 21 22:33:35 2008
@@ -118,10 +118,11 @@
 sub _compute_possible_statuses {
     my $self = shift;
 
+    my $record = $self->record;
     return [
         map { { display => $_, value => $_ } }
-          RT::Model::Queue->active_status_array,
-        RT::Model::Queue->inactive_status_array
+        $record->status,
+        $record->queue->status_schema->transitions( $record->status )
     ];
 }
 

Modified: rt/branches/3.999-DANGEROUS/lib/RT/Condition/CloseTicket.pm
==============================================================================
--- rt/branches/3.999-DANGEROUS/lib/RT/Condition/CloseTicket.pm	(original)
+++ rt/branches/3.999-DANGEROUS/lib/RT/Condition/CloseTicket.pm	Tue Oct 21 22:33:35 2008
@@ -69,8 +69,8 @@
             || ( $txn->type eq "Set" && $txn->field eq "Status" );
 
     my $queue = $self->ticket_obj->queue;
-    return 0 unless $queue->is_active_status( $txn->old_value );
-    return 0 unless $queue->is_inactive_status( $txn->new_value );
+    return 0 unless $queue->status_schema->is_active( $txn->old_value );
+    return 0 unless $queue->status_schema->is_inactive( $txn->new_value );
 
     return 1;
 }

Modified: rt/branches/3.999-DANGEROUS/lib/RT/Condition/ReopenTicket.pm
==============================================================================
--- rt/branches/3.999-DANGEROUS/lib/RT/Condition/ReopenTicket.pm	(original)
+++ rt/branches/3.999-DANGEROUS/lib/RT/Condition/ReopenTicket.pm	Tue Oct 21 22:33:35 2008
@@ -69,8 +69,8 @@
             || ( $txn->type eq "Set" && $txn->field eq "Status" );
 
     my $queue = $self->ticket_obj->queue;
-    return 0 unless $queue->is_inactive_status( $txn->old_value );
-    return 0 unless $queue->is_active_status( $txn->new_value );
+    return 0 unless $queue->status_schema->is_inactive( $txn->old_value );
+    return 0 unless $queue->status_schema->is_active( $txn->new_value );
 
     Jifty->log->debug( "Condition 'On Reopen' triggered " . "for ticket #" . $self->ticket_obj->id . " transaction #" . $txn->id );
 

Modified: rt/branches/3.999-DANGEROUS/lib/RT/Model/Ticket.pm
==============================================================================
--- rt/branches/3.999-DANGEROUS/lib/RT/Model/Ticket.pm	(original)
+++ rt/branches/3.999-DANGEROUS/lib/RT/Model/Ticket.pm	Tue Oct 21 22:33:35 2008
@@ -374,7 +374,7 @@
         return ( 0, 0, _( "No permission to create tickets in the queue '%1'", $queue_obj->name ) );
     }
 
-    unless ( $queue_obj->is_valid_status( $args{'status'} ) ) {
+    unless ( $queue_obj->status_schema->is_valid( $args{'status'} ) ) {
         return ( 0, 0, _('Invalid value for status') );
     }
 
@@ -426,7 +426,7 @@
     }
 
     #If the status is an inactive status, set the resolved date
-    elsif ( $queue_obj->is_inactive_status( $args{'status'} ) ) {
+    elsif ( $queue_obj->status_schema->is_inactive( $args{'status'} ) ) {
         Jifty->log->debug( "Got a " . $args{'status'} . "(inactive) ticket with undefined resolved date. Setting to now." );
         $Resolved->set_to_now;
     }
@@ -2393,8 +2393,6 @@
     return ( $self->set_owner( RT->nobody->user_object->id, 'Untake' ) );
 }
 
-
-
 =head2 steal
 
 A convenience method to change the owner of the current ticket to the
@@ -2414,10 +2412,6 @@
 
 }
 
-
-
-
-
 =head2 validate_status STATUS
 
 Takes a string. Returns true if that status is a valid status for this ticket.
@@ -2425,18 +2419,19 @@
 
 =cut
 
-sub validate_status {
-    my $self   = shift;
-    my $status = shift;
-
-    #Make sure the status passed in is valid
-    unless ( $self->queue->is_valid_status($status) ) {
-        return (undef);
-    }
-
-    return (1);
-
-}
+# XXX, FIXME: disable this for a while, as it conflicts with status schemas
+#sub validate_status {
+#    my $self   = shift;
+#    my $status = shift;
+#
+#    #Make sure the status passed in is valid
+#    unless ( $self->queue->status_schema->is_valid($status) ) {
+#        return (undef);
+#    }
+#
+#    return (1);
+#
+#}
 
 
 
@@ -2478,7 +2473,7 @@
         return ( 0, _('That ticket has unresolved dependencies') );
     }
 
-    unless ( $self->validate_status( $args{'status'} ) ) {
+    unless ( $self->queue->status_schema->is_valid( $args{'status'} ) ) {
         return ( 0, _( "'%1' is an invalid value for status", $args{'status'} ) );
     }
 
@@ -2498,7 +2493,7 @@
 
     #When we close a ticket, set the 'resolved' attribute to now.
     # It's misnamed, but that's just historical.
-    if ( $self->queue->is_inactive_status( $args{status} ) ) {
+    if ( $self->queue->status_schema->is_inactive( $args{status} ) ) {
         $self->_set(
             column             => 'resolved',
             value              => $now->iso,

Modified: rt/branches/3.999-DANGEROUS/lib/RT/Record.pm
==============================================================================
--- rt/branches/3.999-DANGEROUS/lib/RT/Record.pm	(original)
+++ rt/branches/3.999-DANGEROUS/lib/RT/Record.pm	Tue Oct 21 22:33:35 2008
@@ -890,7 +890,7 @@
 
 Returns an RT::Model::TicketCollection object of tickets which this ticket depends on
 and which have a status of new, open or stalled. (That list comes from
-RT::Model::Queue->active_status_array
+RT::Model::Queue->status_schema->active
 
 =cut
 
@@ -898,7 +898,7 @@
     my $self = shift;
     my $deps = RT::Model::TicketCollection->new;
 
-    my @live_statuses = RT::Model::Queue->active_status_array();
+    my @live_statuses = RT::Model::Queue->status_schema->active();
     foreach my $status (@live_statuses) {
         $deps->limit_status( value => $status );
     }

Modified: rt/branches/3.999-DANGEROUS/lib/RT/Report/Tickets.pm
==============================================================================
--- rt/branches/3.999-DANGEROUS/lib/RT/Report/Tickets.pm	(original)
+++ rt/branches/3.999-DANGEROUS/lib/RT/Report/Tickets.pm	Tue Oct 21 22:33:35 2008
@@ -242,7 +242,7 @@
     if ( $self->{'_group_by_field'} eq 'status' ) {
         my %has = map { $_->__value('status') => 1 } @{ $self->items_array_ref || [] };
 
-        foreach my $status ( grep !$has{$_}, RT::Model::Queue->new->status_array ) {
+        foreach my $status ( grep !$has{$_}, RT::Model::Queue->status_schema->valid ) {
 
             my $record = $self->new_item;
             $record->load_from_hash(

Modified: rt/branches/3.999-DANGEROUS/lib/RT/Search/ActiveTicketsInQueue.pm
==============================================================================
--- rt/branches/3.999-DANGEROUS/lib/RT/Search/ActiveTicketsInQueue.pm	(original)
+++ rt/branches/3.999-DANGEROUS/lib/RT/Search/ActiveTicketsInQueue.pm	Tue Oct 21 22:33:35 2008
@@ -79,7 +79,7 @@
 
     $self->tickets_obj->limit_queue( value => $self->argument );
 
-    foreach my $status ( RT::Model::Queue->active_status_array() ) {
+    foreach my $status ( RT::Model::Queue->status_schema->active() ) {
         $self->tickets_obj->limit_status( value => $status );
     }
 

Modified: rt/branches/3.999-DANGEROUS/lib/RT/Search/Googleish.pm
==============================================================================
--- rt/branches/3.999-DANGEROUS/lib/RT/Search/Googleish.pm	(original)
+++ rt/branches/3.999-DANGEROUS/lib/RT/Search/Googleish.pm	Tue Oct 21 22:33:35 2008
@@ -111,7 +111,7 @@
 
         # Is there a status with this name?
         elsif ( $Queue = RT::Model::Queue->new( current_user => $self->tickets_obj->current_user )
-            and $Queue->is_valid_status($key) )
+            and $Queue->status_schema->is_valid($key) )
         {
             push @status_clauses, "Status = '" . $key . "'";
         }
@@ -154,7 +154,7 @@
     push @tql_clauses, join( " OR ", sort @owner_clauses );
     if ( !@status_clauses ) {
         push @tql_clauses,
-          join( " OR ", map "Status = '$_'", RT::Model::Queue->active_status_array() );
+          join( " OR ", map "Status = '$_'", RT::Model::Queue->status_schema->active() );
     }
     else {
         push @tql_clauses, join( " OR ", sort @status_clauses );


More information about the Rt-commit mailing list