[Rt-commit] rt branch 5.0/on-email-add-time-worked created. rt-5.0.2-59-g5b473fc9bf

BPS Git Server git at git.bestpractical.com
Thu Jan 13 15:41:03 UTC 2022


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 5.0/on-email-add-time-worked has been created
        at  5b473fc9bf75fe36f7d0e96ed41f9f5a5350a56a (commit)

- Log -----------------------------------------------------------------
commit 5b473fc9bf75fe36f7d0e96ed41f9f5a5350a56a
Author: Jason Crome <jcrome at bestpractical.com>
Date:   Thu Jan 13 09:50:54 2022 -0500

    Add upgrade path to auto-add of time to ticket
    
    Earlier commits set up a condition, action, and scrip to support
    automatically adding time worked to a ticket when a privileged user
    comments or replies at RT install time. This covers the case where an
    RT install is upgraded.
    
    Fixes: T#236291

diff --git a/etc/upgrade/5.0.3/content b/etc/upgrade/5.0.3/content
new file mode 100644
index 0000000000..7eb5762f9c
--- /dev/null
+++ b/etc/upgrade/5.0.3/content
@@ -0,0 +1,29 @@
+use strict;
+use warnings;
+
+our @ScripActions = (
+    {
+      Name        => 'Add 15 Minutes To Time Worked',              # loc
+      Description => 'Add 15 Minutes To Ticket Time Worked Value', # loc
+      ExecModule  => 'SetTimeWorked',
+      Argument    => '15'
+    },
+);
+
+our @ScripConditions = (
+    {
+      Name                 => 'On Comment Or Reply',                                # loc
+      Description          => 'When a ticket is commented on or replied to',        # loc
+      ApplicableTransTypes => 'Comment,Correspond',
+      ExecModule           => 'AnyTransaction',
+    },
+);
+
+our @Scrips = (
+    {  Description       => "On Comment or Correspond, Add 15 Mins Time Worked",
+       ScripCondition    => 'On Comment Or Reply',
+       ScripAction       => 'Add 15 Minutes To Time Worked',
+       Disabled          => 1,
+       Template          => 'Blank' },
+);
+

commit eaef3b62ac8b841c4b7be5e3e77b85f48d3b673d
Author: Jason Crome <jcrome at bestpractical.com>
Date:   Thu Jan 13 09:39:04 2022 -0500

    Add scrip to add 15 mins of time worked to ticket
    
    This is not something that everyone will want to run automatically, and
    as such, it is disabled by default. In our case, it will only get
    applied to tickets in the Sales Engineering queue. If nothing else, it
    will serve as an example for others to use in their own RT setups.
    
    See T#236291 for more information.

diff --git a/etc/initialdata b/etc/initialdata
index b6899ef75a..a60db0c3fb 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -855,6 +855,11 @@ Hour:         { $SubscriptionObj->SubValue('Hour') }
        ScripCondition    => 'Require due set according to SLA',
        ScripAction       => 'Set due date according to SLA',
        Template          => 'Blank' },
+    {  Description       => "On Comment or Correspond, Add 15 Mins Time Worked",
+       ScripCondition    => 'On Comment Or Reply',
+       ScripAction       => 'Add 15 Minutes To Time Worked',
+       Disabled          => 1,
+       Template          => 'Blank' },
 );
 
 @ACL = (

commit e11664159f8bc5bbd8927e2c11f90184be7c1eeb
Author: craig kaiser <craig at bestpractical.com>
Date:   Tue Feb 2 09:26:54 2021 -0500

    Add RT::Action::SetTimeWorked action and initialdata action

diff --git a/etc/initialdata b/etc/initialdata
index 70abff692a..b6899ef75a 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -125,6 +125,12 @@
        Description => 'Set the due date according to an agreement' , # loc
        ExecModule  => 'SLA_SetDue',
     },
+    {
+      Name        => 'Add 15 Minutes To Time Worked',              # loc
+      Description => 'Add 15 Minutes To Ticket Time Worked Value', # loc
+      ExecModule  => 'SetTimeWorked',
+      Argument    => '15'
+    },
 );
 
 @ScripConditions = (
diff --git a/lib/RT/Action/SetTimeWorked.pm b/lib/RT/Action/SetTimeWorked.pm
new file mode 100644
index 0000000000..4951294daa
--- /dev/null
+++ b/lib/RT/Action/SetTimeWorked.pm
@@ -0,0 +1,116 @@
+# BEGIN BPS TAGGED BLOCK {{{
+#
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2020 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 }}}
+
+package RT::Action::SetTimeWorked;
+
+use strict;
+use warnings;
+use base qw(RT::Action);
+
+use Scalar::Util qw(looks_like_number);
+
+=head1 DESCRIPTION
+
+Provide a time argument in minutes for how much time to add to
+the current tickets time worked value. This action will only
+run when Privileged users comment or reply.
+
+=cut
+
+sub Prepare {
+    my $self = shift;
+
+    # Only set time worked for privileged users
+    return 0 unless $self->TransactionObj->CreatorObj->Privileged;
+
+    # If we are batch stage we will check to see if any time worked values have already been set
+    if ( $self->ScripObj->Stage( TicketObj => $self->TicketObj ) eq 'TransactionBatch' ) {
+        foreach my $transaction ( @{$self->TicketObj->TransactionBatch} ) {
+            next unless $self->TransactionObj->TimeTaken;
+            return;
+        }
+    }
+    # Skip this action if TimeTaken is being updated
+    return if $self->TransactionObj->TimeTaken;
+
+    return 1;
+}
+
+sub Commit {
+    my $self = shift;
+    my $time = $self->Argument;
+    unless ( $time ) {
+        RT::Logger->error( "Time argument required for RT::Action::SetTimeWorked, none was provided" );
+        return;
+    }
+    unless ( looks_like_number( $time ) ) {
+        RT::Logger->error( "Time argument for RT::Action::SetTimeWorked must be a number: $time is invalid" );
+        return;
+    }
+
+    my $timeWorked = $self->TicketObj->TimeWorked || 0;
+
+    # Add 15 minutes to time worked
+    my $newValue = $timeWorked + $time;
+
+    # Load a ticket in the context of the user sending the message
+    my $ticketObj = RT::Ticket->new( $self->TransactionObj->CreatorObj );
+    my ($ret, $msg) = $ticketObj->Load( $self->TicketObj->Id );
+    unless ( $ret ) {
+        RT::Logger->error( "Could not load ticket #".$self->TicketObj->Id." in user context: $msg" );
+        return;
+    }
+
+    ($ret, $msg) = $ticketObj->SetTimeWorked( $newValue );
+    RT::Logger->error ( "Could not update time worked: $msg" ) unless $ret;
+    return $ret;
+}
+
+RT::Base->_ImportOverlays();
+
+1;

commit 21d7bcacb210b515753dd72d1ff2ba89d3de4cfc
Author: craig kaiser <craig at bestpractical.com>
Date:   Tue Feb 2 09:27:16 2021 -0500

    Add default scrip condition 'On Comment Or Reply'

diff --git a/etc/initialdata b/etc/initialdata
index e4e3ccc986..70abff692a 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -262,6 +262,12 @@
        ApplicableTransTypes => 'Any',
        ExecModule           => 'TimeWorkedChange',
     },
+    {
+      Name                 => 'On Comment Or Reply',                                # loc
+      Description          => 'When a ticket is commented on or replied to',        # loc
+      ApplicableTransTypes => 'Comment,Correspond',
+      ExecModule           => 'AnyTransaction',
+    },
 
 );
 

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


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list