[Bps-public-commit] RT-Extension-SLA branch, ignore-deadline-on-statuses, created. 0.05_02-1-ge9b63eb

Ruslan Zakirov ruz at bestpractical.com
Wed Jun 27 19:12:32 EDT 2012


The branch, ignore-deadline-on-statuses has been created
        at  e9b63eb1dfa8e32e82660179e2a04b78e52307d2 (commit)

- Log -----------------------------------------------------------------
commit e9b63eb1dfa8e32e82660179e2a04b78e52307d2
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Jun 28 02:08:33 2012 +0300

    new option - IgnoreOnStatuses
    
    Allows you to ignore deadline(s) when ticket has certain status(es)

diff --git a/Changes b/Changes
index 12d5fff..1436e21 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,7 @@
+0.06 Not released
+
+    * IgnoreOnStatuses agreement modifier
+
 0.05_02 Wed Jun 27 15:44:36 PDT 2012
 
     * Make sure timezone change is seen by system functions
diff --git a/etc/initialdata b/etc/initialdata
index 50b1bde..f9f6146 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -22,7 +22,7 @@
     },
     {  Name        => '[SLA] Require Due set', # loc
        Description => 'Detect a situation when we should set Due date' , # loc
-       ApplicableTransTypes => 'Create,CustomField,Correspond',
+       ApplicableTransTypes => 'Create,CustomField,Correspond,Set,Status',
        ExecModule => 'SLA_RequireDueSet',
     },
 );
diff --git a/etc/upgrade/0.06/content b/etc/upgrade/0.06/content
new file mode 100644
index 0000000..4c8bee3
--- /dev/null
+++ b/etc/upgrade/0.06/content
@@ -0,0 +1,16 @@
+our @Final = (
+    sub {
+        my $condition = RT::ScripCondition->new( RT->SystemUser );
+        $condition->LoadByCols( ExecModule => 'SLA_RequireDueSet' );
+        unless ( $condition->id ) {
+            $RT::Logger->error("Couldn't find condition based on SLA_RequireDueSet module. New installation?");
+            return 0;
+        }
+
+        my ($status, $msg) = $condition->SetApplicableTransTypes('Create,CustomField,Correspond,Set,Status');
+        unless ($status) {
+            $RT::Logger->error("Couldn't set ApplicableTransTypes for condition: $msg");
+        }
+        return 1;
+    },
+);
\ No newline at end of file
diff --git a/lib/RT/Condition/SLA_RequireDueSet.pm b/lib/RT/Condition/SLA_RequireDueSet.pm
index fc41f82..3ec674e 100644
--- a/lib/RT/Condition/SLA_RequireDueSet.pm
+++ b/lib/RT/Condition/SLA_RequireDueSet.pm
@@ -25,6 +25,10 @@ sub IsApplicable {
         return 1 if $self->TicketObj->FirstCustomFieldValue('SLA');
         return 0;
     }
+    elsif ( $type eq 'Status' || ($type eq 'Set' && $self->TransactionObj->Field eq 'Status') ) {
+        return 1 if $self->TicketObj->FirstCustomFieldValue('SLA');
+        return 0;
+    }
     return 1 if $self->IsCustomFieldChange('SLA');
     return 0;
 }
diff --git a/lib/RT/Extension/SLA.pm b/lib/RT/Extension/SLA.pm
index b3b8734..211e64b 100644
--- a/lib/RT/Extension/SLA.pm
+++ b/lib/RT/Extension/SLA.pm
@@ -242,7 +242,9 @@ In the above example Due is set to one hour after creation, reply
 of a non-requestor moves Due date two hours forward, requestors'
 replies move Due date to one hour and resolve deadine is 24 hours.
 
-=head2 OutOfHours (struct, no default)
+=head2 Modifying Agreements
+
+=head3 OutOfHours (struct, no default)
 
 Out of hours modifier. Adds more real or business minutes to resolve
 and/or reply options if event happens out of business hours, read also
@@ -266,6 +268,20 @@ hours, otherwise only one.
 Supporters have two additional hours in the morning to deal with bunch
 of requests that came into the system during the last night.
 
+=head3 IgnoreOnStatuses (array, no default)
+
+Allows you to ignore a deadline when ticket has certain status. Example:
+
+    'level x' => {
+        KeepInLoop => { BusinessMinutes => 60, IgnoreOnStatuses => ['stalled'] },
+    },
+
+In above example KeepInLoop deadline is ignored if ticket is stalled.
+
+B<NOTE> that if you just open ticket without a reply then Due date will be
+calculated from old action and ticket will probably be overdue. In most
+cases it shouldn't be a problem.
+
 =head2 Configuring business hours
 
 In the config you can set one or more work schedules. Use the following
@@ -377,6 +393,11 @@ sub Agreement {
         return undef;
     }
 
+    if ( $args{'Ticket'} && $res{'IgnoreOnStatuses'} ) {
+        my $status = $args{'Ticket'}->Status;
+        return undef if grep $_ eq $status, @{$res{'IgnoreOnStatuses'}};
+    }
+
     $res{'OutOfHours'} = $meta->{'OutOfHours'}{ $args{'Type'} };
 
     $args{'Queue'} ||= $args{'Ticket'}->QueueObj if $args{'Ticket'};

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



More information about the Bps-public-commit mailing list