[Rt-commit] rt branch, 3.999-trunk, updated. e4697bd879eccb9e26b651f893502e39fba408d8

sartak at bestpractical.com sartak at bestpractical.com
Wed Dec 2 07:06:09 EST 2009


The branch, 3.999-trunk has been updated
       via  e4697bd879eccb9e26b651f893502e39fba408d8 (commit)
       via  aa8436b10436c54fc7ce1859a911b4566d764c10 (commit)
      from  853464cbadbc698a7d0676079fe6692e76599e59 (commit)

Summary of changes:
 lib/RT/Model/Ticket.pm |   45 ++++++++++++++++++++++++++++++---------------
 1 files changed, 30 insertions(+), 15 deletions(-)

- Log -----------------------------------------------------------------
commit aa8436b10436c54fc7ce1859a911b4566d764c10
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Wed Dec 2 06:57:02 2009 -0500

    canonicalize_resolved

diff --git a/lib/RT/Model/Ticket.pm b/lib/RT/Model/Ticket.pm
index 0a43aa2..4149864 100755
--- a/lib/RT/Model/Ticket.pm
+++ b/lib/RT/Model/Ticket.pm
@@ -474,19 +474,6 @@ sub create {
 # }}}
 
     # {{{ Dates
-    my $resolved;
-    if ( defined $args{'resolved'} ) {
-        $resolved = RT::DateTime->new_from_string($args{'resolved'});
-    }
-    #If the status is an inactive status, set the resolved date
-    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 = RT::DateTime->now;
-    }
-    else {
-        $resolved = RT::DateTime->new_unset;
-    }
-
     my $told;
     if ( defined $args{'told'} ) {
         $told = RT::DateTime->new_from_string($args{'told'});
@@ -589,7 +576,7 @@ sub create {
         type             => $args{'type'},
         starts           => $args{'starts'},
         started          => $args{'started'},
-        resolved         => $resolved,
+        resolved         => $args{'resolved'},
         told             => $told,
         due              => $args{'due'},
     );
@@ -902,6 +889,32 @@ sub canonicalize_started {
     return RT::DateTime->new_unset;
 }
 
+=head2 canonicalize_resolved
+
+Try to parse the resolved date as a string.
+
+=cut
+
+sub canonicalize_resolved {
+    my $self     = shift;
+    my $resolved = shift;
+    my $other    = shift;
+
+    if (defined $resolved) {
+        return RT::DateTime->new_from_string($resolved);
+    }
+
+    my $queue = $self->queue_id || $other->{queue};
+    my $queue_obj = RT::Model::Queue->new;
+    $queue_obj->load($queue);
+
+    if ( !$queue_obj->status_schema->is_inactive($other->{status}) ) {
+        return RT::DateTime->now;
+    }
+
+    return RT::DateTime->new_unset;
+}
+
 sub roles { return ( "cc", "admin_cc", "requestor" ); }
 
 =head2 squelch_mail_to [EMAIL]

commit e4697bd879eccb9e26b651f893502e39fba408d8
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Wed Dec 2 07:04:45 2009 -0500

    Doc the started/resolved interaction with status

diff --git a/lib/RT/Model/Ticket.pm b/lib/RT/Model/Ticket.pm
index 4149864..b8d2dcc 100755
--- a/lib/RT/Model/Ticket.pm
+++ b/lib/RT/Model/Ticket.pm
@@ -865,7 +865,8 @@ sub canonicalize_starts {
 
 =head2 canonicalize_started
 
-Try to parse the started date as a string.
+Try to parse the started date as a string. If the status is not one of the
+queue's initial statuses, then a default of "now" will be used.
 
 =cut
 
@@ -891,7 +892,8 @@ sub canonicalize_started {
 
 =head2 canonicalize_resolved
 
-Try to parse the resolved date as a string.
+Try to parse the resolved date as a string. If the status is inactive, then a
+default of "now" will be used.
 
 =cut
 

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


More information about the Rt-commit mailing list