[Bps-public-commit] rt-extension-sla-utils branch, master, updated. ca65ff17f148669ed8b54dfe51aec5ff4141fbc9

Dave Goehrig dave at bestpractical.com
Thu Mar 30 13:56:57 EDT 2017


The branch, master has been updated
       via  ca65ff17f148669ed8b54dfe51aec5ff4141fbc9 (commit)
      from  a5d545cdec0e297aaf7044336894d4b5f051bf4f (commit)

Summary of changes:
 .../SLASetFromCustomField.pm}                      | 40 +++++++---------
 .../SLAOverdue.pm => Action/SLASetOverdue.pm}      | 56 +++++++++++++---------
 2 files changed, 50 insertions(+), 46 deletions(-)
 copy lib/RT/{Condition/SLAOverdue.pm => Action/SLASetFromCustomField.pm} (74%)
 copy lib/RT/{Condition/SLAOverdue.pm => Action/SLASetOverdue.pm} (72%)

- Log -----------------------------------------------------------------
commit ca65ff17f148669ed8b54dfe51aec5ff4141fbc9
Author: Dave Goehrig <dave at bestpractical.com>
Date:   Thu Mar 30 13:55:47 2017 -0400

    Adding back the actions that were missing after rename

diff --git a/lib/RT/Action/SLASetFromCustomField.pm b/lib/RT/Action/SLASetFromCustomField.pm
new file mode 100644
index 0000000..688bf45
--- /dev/null
+++ b/lib/RT/Action/SLASetFromCustomField.pm
@@ -0,0 +1,82 @@
+# BEGIN BPS TAGGED BLOCK {{{
+#
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2016 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 }}}
+
+use strict;
+use warnings;
+
+package RT::Action::SLASetFromCustomField;
+
+use base qw(RT::Action);
+
+=head2 Prepare
+
+=cut
+
+sub Prepare {
+    return 1;
+}
+
+=head2 Commit
+
+Set SLA based on CF.
+
+=cut
+
+sub Commit {
+    my $self = shift;
+
+    my $ticket = $self->TicketObj;
+    my %mapping = %{ RT->Config->Get('SLA_CF_Mapping') };
+    my $sla = $mapping{$self->TransactionObj->NewValue} || $self->TransactionObj->NewValue;
+    my ($ret, $msg) = $ticket->SetSLA($sla);
+    RT::Logger->error("Unable to update SLA: $msg") unless $ret;
+    return 1;
+
+}
+
+1;
diff --git a/lib/RT/Action/SLASetOverdue.pm b/lib/RT/Action/SLASetOverdue.pm
new file mode 100644
index 0000000..de70c19
--- /dev/null
+++ b/lib/RT/Action/SLASetOverdue.pm
@@ -0,0 +1,98 @@
+# BEGIN BPS TAGGED BLOCK {{{
+#
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2016 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 }}}
+
+use strict;
+use warnings;
+
+package RT::Action::SLASetOverdue;
+
+use base qw(RT::Action::SLA);
+
+use RT::Condition::Overdue;
+
+=head2 Prepare
+
+Checks if the ticket has service level defined.
+
+=cut
+
+sub Prepare {
+    my $self = shift;
+
+    unless ( $self->TicketObj->SLA ) {
+        $RT::Logger->error('SLA::SetOverdue scrip has been applied to ticket #'
+            . $self->TicketObj->id . ' that has no SLA defined');
+        return 0;
+    }
+
+    return 1;
+}
+
+=head2 Commit
+
+Set Overdue custom field according to SLA.
+
+=cut
+
+sub Commit {
+    my $self = shift;
+
+    my $ticket = $self->TicketObj;
+    my $txn = $self->TransactionObj;
+    my $level = $ticket->SLA;
+
+    my $overdue = RT::Condition::Overdue->new(TicketObj => $ticket);
+    return 0 unless $overdue->IsApplicable;
+
+    $ticket->AddCustomFieldValue(
+        Field => 'SLA Overdue',
+        Value => 1,
+    );
+}
+
+1;

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


More information about the Bps-public-commit mailing list