[Rt-commit] rtir branch, 5.0/use-core-custom-field-default-values, repushed
? sunnavy
sunnavy at bestpractical.com
Thu Jun 4 13:18:07 EDT 2020
The branch 5.0/use-core-custom-field-default-values was deleted and repushed:
was 3d13b147a7ebfe53e4c44875db410633b1648e9d
now cba2a5b93f848ea2cf6254797dc5350fa082edd3
1: fb3a29c1 ! 1: fb731e9f Use core default values instead of RTIR_CustomFieldsDefaults config
@@ -39,21 +39,27 @@
+use warnings;
+
+our @Final = sub {
++ my $custom_field_defaults = RT->Config->Get('RTIR_CustomFieldsDefaults') or return;
++
+ my $custom_field = RT::CustomField->new( RT->SystemUser );
-+
-+ my $custom_field_defaults = RT->Config->Get('RTIR_CustomFieldsDefaults') || ();
-+
+ foreach my $cf_name ( keys %{$custom_field_defaults} ) {
-+ next if ref $cf_name eq 'HASH';
++ 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;
+ }
-+ ($ret, $msg) = $custom_field->SetDefaultValues( Values => $custom_field_defaults->{$cf_name} );
++
++ 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 $custom_field_defaults->{$cf_name}" );
++ 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" );
2: 3d13b147 ! 2: e9fd1892 Update tests to use core default CF values feature
@@ -10,7 +10,7 @@
use RT::IR::Test tests => undef;
-my $defaults = RT->Config->Get('RTIR_CustomFieldsDefaults');
-+my $defaults = ();
++my $defaults = {};
$defaults->{'How Reported'} = 'Telephone'; # IRs
$defaults->{'Description'} = 'Bloody mess'; # Incs
$defaults->{'IP'} = '127.0.0.1'; # Invs and all
@@ -30,15 +30,3 @@
'Incident Reports' => 'How Reported',
'Incidents' => 'Description',
-diff --git a/t/mail/skip_notification.t b/t/mail/skip_notification.t
---- a/t/mail/skip_notification.t
-+++ b/t/mail/skip_notification.t
-@@
-
- 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();
-: ------- > 3: 99a2f472 Drop unnecessary Constituency CF default value set in tests
-: ------- > 4: cba2a5b9 Note config %RTIR_CustomFieldsDefaults changes in UPGRADING doc
More information about the rt-commit
mailing list