[Rt-commit] rt branch, 4.4/custom-fields-set-from-rtconfig, updated. rt-4.4.3-70-g5b10d7258
John Waller
john at bestpractical.com
Wed Nov 28 11:02:03 EST 2018
The branch, 4.4/custom-fields-set-from-rtconfig has been updated
via 5b10d7258e42b32db13c9914b9b0126eb32c472b (commit)
from 000600fdabfc3602c0e16e7d86432f907f5874d4 (commit)
Summary of changes:
etc/RT_SiteConfig.d/Lifecycle_Config.pm | 4 +-
lib/RT/Lifecycle.pm | 61 +++++++++++++---------------
lib/RT/Ticket.pm | 70 +++++++++++++++++++--------------
3 files changed, 70 insertions(+), 65 deletions(-)
- Log -----------------------------------------------------------------
commit 5b10d7258e42b32db13c9914b9b0126eb32c472b
Author: John Waller <john at bestpractical.com>
Date: Wed Nov 28 11:01:55 2018 -0500
Fixed some syntax errors, dealt with NewLifeCycle ||= changes, added proper comments
diff --git a/etc/RT_SiteConfig.d/Lifecycle_Config.pm b/etc/RT_SiteConfig.d/Lifecycle_Config.pm
index eeaf54a68..38fa970cf 100644
--- a/etc/RT_SiteConfig.d/Lifecycle_Config.pm
+++ b/etc/RT_SiteConfig.d/Lifecycle_Config.pm
@@ -52,8 +52,8 @@ Set(%Lifecycles,
'escalation1 -> open' => { label => 'Re-open' }, # loc{label}
],
dates => {
- 'open -> escalation1' => 'Stalled',
- 'escalation1 -> open' => 'Setup',
+ 'open -> escalation1' => 'Escalated',
+ 'escalation1 -> *' => 'DeEscalated',
},
},
'__maps__' => {
diff --git a/lib/RT/Lifecycle.pm b/lib/RT/Lifecycle.pm
index 314f696ce..8815fd9ce 100644
--- a/lib/RT/Lifecycle.pm
+++ b/lib/RT/Lifecycle.pm
@@ -48,29 +48,7 @@
use strict;
use warnings;
-use Data::Printer {
- color => {
- array => 'bright_white', # array index numbers
- number => 'bright_blue', # numbers
- string => 'bright_yellow', # strings
- class => 'bright_green', # class names
- method => 'bright_green', # method names
- undef => 'bright_red', # the 'undef' value
- hash => 'magenta', # hash keys
- regex => 'yellow', # regular expressions
- code => 'green', # code references
- glob => 'bright_cyan', # globs (usually file handles)
- vstring => 'bright_blue', # version strings (v5.16.0, etc)
- repeated => 'white on_red', # references to seen values
- caller_info => 'bright_cyan', # details on what's being printed
- weak => 'cyan', # weak references
- tainted => 'red', # tainted content
- escaped => 'bright_red', # escaped characters (\t, \n, etc)
-
- # potential new Perl datatypes, unknown to Data::Printer
- unknown => 'bright_yellow on_blue',
- },
-};
+
package RT::Lifecycle;
our %LIFECYCLES;
@@ -486,17 +464,34 @@ be updated on the ticket.
sub DateFields {
my $self = shift;
- my $from = shift;
- my $to = shift;
-
- my $list = $self->{'data'}{'dates'};
+ my $from = shift; # ticket from-> status
+ my $to = shift; # ticket ->to status
+ my $field = undef;
+
+ if(!$to || !$from) {
+ RT::Logger->error("Comeing from or going to status of transition is unknown - From: [$from] or To: [$to] or From");
+ return;
+ }
- foreach my $transition (keys %$list) {
- my $field = $list->{$transition};
- if ($transition eq "$from -> $to" || $transition eq "* => *" || $transition eq "* => $to" || $transition eq "$from => *") {
- return $field;
- }
- }
+ if($self->{'data'}{'dates'}){
+ my $list = $self->{'data'}{'dates'};
+ foreach my $transition (keys %$list) {
+
+ my $field = $list->{$transition};
+ if ($transition eq "$from -> $to" || $transition eq "* -> *" || $transition eq "* -> $to" || $transition eq "$from -> *") {
+ return $field;
+ }
+ }
+ }
+ else{
+ RT::Logger->debug("No custom dates section was found in Lifecycle for customer");
+ return;
+ }
+ if(!$field){
+ RT::Logger->debug("No custom date fields were found in Lifecycle.");
+ return;
+ }
+ return;
}
=head3 RightsDescription [TYPE]
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index 608576861..673274a31 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -68,7 +68,29 @@ package RT::Ticket;
use strict;
use warnings;
use base 'RT::Record';
-
+use Data::Printer {
+ color => {
+ array => 'bright_white', # array index numbers
+ number => 'bright_blue', # numbers
+ string => 'bright_yellow', # strings
+ class => 'bright_green', # class names
+ method => 'bright_green', # method names
+ undef => 'bright_red', # the 'undef' value
+ hash => 'magenta', # hash keys
+ regex => 'yellow', # regular expressions
+ code => 'green', # code references
+ glob => 'bright_cyan', # globs (usually file handles)
+ vstring => 'bright_blue', # version strings (v5.16.0, etc)
+ repeated => 'white on_red', # references to seen values
+ caller_info => 'bright_cyan', # details on what's being printed
+ weak => 'cyan', # weak references
+ tainted => 'red', # tainted content
+ escaped => 'bright_red', # escaped characters (\t, \n, etc)
+
+ # potential new Perl datatypes, unknown to Data::Printer
+ unknown => 'bright_yellow on_blue',
+ },
+};
use Role::Basic 'with';
# SetStatus and _SetStatus are reimplemented below (using other pieces of the
@@ -93,29 +115,6 @@ use RT::URI;
use RT::SLA;
use MIME::Entity;
use Devel::GlobalDestruction;
-use Data::Printer {
- color => {
- array => 'bright_white', # array index numbers
- number => 'bright_blue', # numbers
- string => 'bright_yellow', # strings
- class => 'bright_green', # class names
- method => 'bright_green', # method names
- undef => 'bright_red', # the 'undef' value
- hash => 'magenta', # hash keys
- regex => 'yellow', # regular expressions
- code => 'green', # code references
- glob => 'bright_cyan', # globs (usually file handles)
- vstring => 'bright_blue', # version strings (v5.16.0, etc)
- repeated => 'white on_red', # references to seen values
- caller_info => 'bright_cyan', # details on what's being printed
- weak => 'cyan', # weak references
- tainted => 'red', # tainted content
- escaped => 'bright_red', # escaped characters (\t, \n, etc)
-
- # potential new Perl datatypes, unknown to Data::Printer
- unknown => 'bright_yellow on_blue',
- },
-};
sub LifecycleColumn { "Queue" }
@@ -2522,6 +2521,7 @@ sub _SetStatus {
Value => $now->ISO,
RecordTransaction => 0
);
+
}
# When we close a ticket, set the 'Resolved' attribute to now.
@@ -2535,19 +2535,29 @@ sub _SetStatus {
}
# When we are in transition to an active status in THIS queue, or another queue
- if( $args{Lifecycle}->IsActive($args{Status})
- || $args{NewLifecycle}->IsActive($args{Status}) ) {
-
- my $cnow = RT::Date->new( $self->CurrentUser );
+ # - possible status case transition
+ # * => active
+ # active => inactive (and status is not resolved)
+ # NOTE: this method hands non-resolved, inactive and non->initial, new status cases
+
+ if(
+ $args{NewLifecycle}->IsActive($args{Status}) # Transing to Status is Active
+ || ( $args{NewLifecycle}->IsInactive($args{Status}) # Inactive Status, but is NOT Resolved
+ && $args{Status} ne 'Resolved' ) # IsInactve and Status is not 'Resolved'
+ )
+
+ {
+ my $cnow = RT::Date->new( $self->CurrentUser );
$cnow->SetToNow();
- my $field= $args{Lifecycle}->DateFields($old,$args{Status});
-
+ my $field = $args{Lifecycle}->DateFields($old,$args{Status});
if( $field ) {
+
my ( $ok, $e ) = $self->AddCustomFieldValue( Field => $field , Value => $cnow->ISO );
if(not $ok){
RT::Logger->error("Unable to update $field : $e");
}
+
}
else {
RT::Logger->debug("No custom data field matches")
-----------------------------------------------------------------------
More information about the rt-commit
mailing list