[Rt-commit] rtir branch, master, updated. 4.0.1rc1-230-g4bae87f5

? sunnavy sunnavy at bestpractical.com
Fri Jun 12 18:22:08 EDT 2020


The branch, master has been updated
       via  4bae87f5fb526b94267b3c327cb93b9ab00bd3f7 (commit)
       via  89fe8823afefb52d7407bd51931c8bc71b66a54d (commit)
       via  7cb70bbd038cef22d3ebdbcc78275afa8cddfb82 (commit)
       via  c02b8e838f321d55352d589c06995d72e182b599 (commit)
       via  a323ca3c293f67e60b4c3443b9ce3c2183ad3e2f (commit)
       via  e87df94d973757a134bb6ce3e527705abea5c57f (commit)
      from  457a33389c0212272ebc3e628c3b2a24c6543633 (commit)

Summary of changes:
 MANIFEST                                           |  1 +
 docs/UPGRADING-5.0                                 | 15 +++++++++++
 etc/RTIR_Config.pm                                 | 12 ++-------
 etc/upgrade/4.9.1/content                          | 31 ++++++++++++++++++++++
 .../RTIR/Admin/Queues/DefaultValues.html/Init}     | 10 ++++---
 html/RTIR/Elements/EditCustomFields                | 11 --------
 t/custom-fields/defaults-config.t                  | 12 ++++++++-
 t/mail/skip_notification.t                         |  2 --
 8 files changed, 67 insertions(+), 27 deletions(-)
 create mode 100644 etc/upgrade/4.9.1/content
 copy html/{RTIR/Tools/index.html => Callbacks/RTIR/Admin/Queues/DefaultValues.html/Init} (91%)

- Log -----------------------------------------------------------------
commit e87df94d973757a134bb6ce3e527705abea5c57f
Author: craig kaiser <craig at bestpractical.com>
Date:   Thu May 21 08:56:22 2020 -0400

    Use core default values instead of RTIR_CustomFieldsDefaults config

diff --git a/etc/RTIR_Config.pm b/etc/RTIR_Config.pm
index e3e9b52a..e7d22b04 100644
--- a/etc/RTIR_Config.pm
+++ b/etc/RTIR_Config.pm
@@ -599,21 +599,13 @@ Set(@Active_MakeClicky, qw(httpurl_overwrite ip email domain));
 
 =item C<%RTIR_CustomFieldsDefaults>
 
-Set the defaults for RTIR custom fields. Values are case-sensitive.
+Set the default value for Resolution if there is no value when an RTIR ticket
+is set to resolved or rejected.
 
 =cut
 
 Set(
     %RTIR_CustomFieldsDefaults,
-    'How Reported'  => "",
-    'Reporter Type' => "",
-    IP              => "",
-    Netmask         => "",
-    Port            => "",
-    'Where Blocked' => "",
-    Function        => "",
-    Classification  => "",
-    Description     => "",
     Resolution      => {
         resolved => "successfully resolved",
         rejected => "no resolution reached",
diff --git a/etc/upgrade/4.9.1/content b/etc/upgrade/4.9.1/content
new file mode 100644
index 00000000..4a4b5c3f
--- /dev/null
+++ b/etc/upgrade/4.9.1/content
@@ -0,0 +1,31 @@
+use strict;
+use warnings;
+
+our @Final = sub {
+    my $custom_field_defaults = RT->Config->Get('RTIR_CustomFieldsDefaults') or return;
+
+    my $custom_field = RT::CustomField->new( RT->SystemUser );
+    foreach my $cf_name ( keys %{$custom_field_defaults} ) {
+        my $value = $custom_field_defaults->{$cf_name};
+        next unless defined $value && length $value && ( !ref($value) || ref($value) eq 'ARRAY' );
+
+        my ($ret, $msg) = $custom_field->LoadByName( Name => $cf_name );
+        unless ( $ret ) {
+            RT->Logger->error( "Could not load custom field '$cf_name' : $msg" );
+            next;
+        }
+
+        if ( $custom_field->DefaultValues ) {
+            RT->Logger->debug("$cf_name already has default values, skipping");
+            next;
+        }
+
+        ($ret, $msg) = $custom_field->SetDefaultValues( Values => $value );
+        if ( $ret ) {
+            RT->Logger->debug( "Set default value for $cf_name to $value" );
+        }
+        else {
+            RT->Logger->error( "Could not set default value for $cf_name custom field: $msg" );
+        }
+    }
+};
diff --git a/html/RTIR/Elements/EditCustomFields b/html/RTIR/Elements/EditCustomFields
index f892eeda..381e9961 100644
--- a/html/RTIR/Elements/EditCustomFields
+++ b/html/RTIR/Elements/EditCustomFields
@@ -59,7 +59,6 @@
 unless ( $TicketObj && $TicketObj->Id ) {
     # no ticket, we need to find defaults of cfs
     my $CustomFields = $QueueObj->TicketCustomFields();
-    my %ConfigDefaults = RT->Config->Get('RTIR_CustomFieldsDefaults');
     while ( my $CustomField = $CustomFields->Next ) {
         my $name = $CustomField->Name;
 
@@ -77,16 +76,6 @@ unless ( $TicketObj && $TicketObj->Id ) {
         if ( $ARGS{"$name-Value"} ) {
             $CFDefaults->{"CustomField-".$CustomField->Id} = $ARGS{"$name-Value"};
         }
-        elsif ( defined $ConfigDefaults{ $name } ) {
-# if $ConfigDefaults{$name} is ref, it should be treated carefully
-            unless ( ref $ConfigDefaults{ $name } ) {
-                $CFDefaults->{"CustomField-".$CustomField->Id} = $ConfigDefaults{ $name };
-            }
-            elsif ( ref $ConfigDefaults{ $name } eq 'ARRAY' ) {
-                $CFDefaults->{"CustomField-".$CustomField->id} =
-                    join "\n", @{$ConfigDefaults{ $name }};
-            }
-        }
     }
 }
 </%INIT>

commit a323ca3c293f67e60b4c3443b9ce3c2183ad3e2f
Author: craig kaiser <craig at bestpractical.com>
Date:   Fri May 22 14:20:35 2020 -0400

    Update tests to use core default CF values feature

diff --git a/t/custom-fields/defaults-config.t b/t/custom-fields/defaults-config.t
index 4289e0ca..20eea253 100644
--- a/t/custom-fields/defaults-config.t
+++ b/t/custom-fields/defaults-config.t
@@ -5,12 +5,22 @@ use warnings;
 
 use RT::IR::Test tests => undef;
 
-my $defaults = RT->Config->Get('RTIR_CustomFieldsDefaults');
+my $defaults = {};
 $defaults->{'How Reported'}  = 'Telephone';   # IRs
 $defaults->{'Description'}   = 'Bloody mess'; # Incs
 $defaults->{'IP'}            = '127.0.0.1';   # Invs and all
 $defaults->{'Where Blocked'} = 'On the Moon'; # Countermeasures
 
+my $custom_field = RT::CustomField->new( RT->SystemUser );
+foreach my $cf_name ( keys %{$defaults} ) {
+
+    my ($ret, $msg) = $custom_field->LoadByName( Name => $cf_name );
+    ok $ret, "Load custom field '$cf_name'";
+
+    ($ret, $msg) = $custom_field->SetDefaultValues( Values => $defaults->{$cf_name} );
+    ok $ret, "Set custom field $cf_name default value to $defaults->{$cf_name}"
+}
+
 my %test_on = (
     'Incident Reports' => 'How Reported',
     'Incidents'        => 'Description',

commit c02b8e838f321d55352d589c06995d72e182b599
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Jun 4 22:30:06 2020 +0800

    Drop unnecessary Constituency CF default value set in tests
    
    The file tests SkipNotification feature, which is unrelated to
    Constituency, not mentioning the CF name is obsolete too.

diff --git a/t/mail/skip_notification.t b/t/mail/skip_notification.t
index 8ac61194..1f53ce9a 100644
--- a/t/mail/skip_notification.t
+++ b/t/mail/skip_notification.t
@@ -5,8 +5,6 @@ use warnings;
 
 use RT::IR::Test tests => undef;
 
-RT->Config->Get('RTIR_CustomFieldsDefaults')->{'Constituency'} = 'EDUNET';
-
 my ($baseurl) = RT::Test->started_ok;
 my $agent = default_agent();
 my $rtir_user = rtir_user();

commit 7cb70bbd038cef22d3ebdbcc78275afa8cddfb82
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Fri Jun 12 08:57:11 2020 -0400

    Display RTIR::Ticket CF groupings on queue admin Default Values tab
    
    By default, RT shows only RT::Ticket CF groupings.

diff --git a/MANIFEST b/MANIFEST
index 5f96ce7b..ff0bae50 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -55,6 +55,7 @@ etc/upgrade/3.3.3/content
 etc/upgrade/3.3.4/content
 etc/upgrade/remove_files
 etc/upgrade/rtir-2.4-upgrade.pl.in
+html/Callbacks/RTIR/Admin/Queues/DefaultValues.html/Init
 html/Callbacks/RTIR/autohandler/SuccessfulLogin
 html/Callbacks/RTIR/Elements/Header/Head
 html/Callbacks/RTIR/Elements/MakeClicky/Default
diff --git a/html/Callbacks/RTIR/Admin/Queues/DefaultValues.html/Init b/html/Callbacks/RTIR/Admin/Queues/DefaultValues.html/Init
new file mode 100644
index 00000000..79ce08fc
--- /dev/null
+++ b/html/Callbacks/RTIR/Admin/Queues/DefaultValues.html/Init
@@ -0,0 +1,55 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2018 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 }}}
+
+<%init>
+# To display RTIR CF groupings on queue config Default Values tab
+unshift @{$Groupings}, RT::CustomField->CustomGroupings('RTIR::Ticket');
+</%init>
+<%args>
+$Groupings
+</%args>

commit 89fe8823afefb52d7407bd51931c8bc71b66a54d
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Jun 4 22:53:25 2020 +0800

    Note config %RTIR_CustomFieldsDefaults changes in UPGRADING doc

diff --git a/docs/UPGRADING-5.0 b/docs/UPGRADING-5.0
index ce817774..2d5b6635 100644
--- a/docs/UPGRADING-5.0
+++ b/docs/UPGRADING-5.0
@@ -82,6 +82,21 @@ As with Priority above, this setting can be customized with the "DueIncidents"
 entry in C<%RTIRSearchResultFormats>. The previous option was called UpdateStatus
 and the new version is UnreadMessages.
 
+=item *
+
+Default values for RTIR custom fields previously set using the configuration
+option C<%RTIR_CustomFieldsDefaults> are now set using RT's core custom
+field default value feature. If you had defaults previously set, they will
+be migrated automatically during upgrade.
+
+RT supports setting these defaults both in the custom field configuration,
+which will set a default for all queues, and in the queue configuration
+for each individual queue.
+
+C<%RTIR_CustomFieldsDefaults> now sets default values only for "Resolution"
+because the Resolution values are set based on the status of the
+Incident when closed.
+
 =back
 
 =cut

commit 4bae87f5fb526b94267b3c327cb93b9ab00bd3f7
Merge: 457a3338 89fe8823
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sat Jun 13 06:21:46 2020 +0800

    Merge branch '5.0/use-core-custom-field-default-values'


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


More information about the rt-commit mailing list