[Rt-commit] rtir branch 4.0/improve-lookup-tool created. 4.0.2-6-g4d756ebf

BPS Git Server git at git.bestpractical.com
Tue Nov 23 13:31:41 UTC 2021


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 "rtir".

The branch, 4.0/improve-lookup-tool has been created
        at  4d756ebf7d81aaa0e0343211b533be69c6d7f497 (commit)

- Log -----------------------------------------------------------------
commit 4d756ebf7d81aaa0e0343211b533be69c6d7f497
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Fri Oct 26 15:52:53 2018 -0400

    Add IP lookup option when no ticketObj

diff --git a/html/RTIR/Tools/Elements/ToolFormLookup b/html/RTIR/Tools/Elements/ToolFormLookup
new file mode 100644
index 00000000..b82d8769
--- /dev/null
+++ b/html/RTIR/Tools/Elements/ToolFormLookup
@@ -0,0 +1,18 @@
+<table>
+    <tr>
+        <td valign="top" class="label"><%loc('Lookup Fields')%>:</td>
+        <td valign="top">
+            <form name="ToolLookupField" action="Lookup.html" method="get">
+                <input type="text" size="30" name="q" value="<% $q %>" /> for
+                <select name="type">
+                    <option value="ip">IP</option>
+                </select>
+            <input type="submit" value="<%loc('Go')%>" />
+            </form>
+        </td>
+    </tr>
+</table>
+
+<%args>
+$q => ''
+</%args>
diff --git a/html/RTIR/Tools/Lookup.html b/html/RTIR/Tools/Lookup.html
index 266879b6..8147d820 100644
--- a/html/RTIR/Tools/Lookup.html
+++ b/html/RTIR/Tools/Lookup.html
@@ -51,6 +51,13 @@
 
 % $m->callback(CallbackName => 'BeforeCurrent', %ARGS, ARGSRef => \%ARGS, Ticket => $TicketObj, LookupType => $type, q => $q);
 
+% if ( ! $TicketObj ) {
+    <& Elements/ToolFormLookup,
+        %ARGS,
+        q => $q,
+    &>
+% }
+
 % if ( $TicketObj ) {
 <&| /Widgets/TitleBox, title => loc("Current [_1]: #[_2]", $TicketType, $ticket), class => 'ticket-info-basics' &>
 <& /Elements/CollectionList, Query => "id = $ticket", Format => RT->Config->Get('RTIRSearchResultFormats')->{$TicketType . 'Default'}, ShowNavigation => 0,

commit 296f090391cfd978eb68f868c729583b44388d5d
Author: craig kaiser <craig at bestpractical.com>
Date:   Thu May 21 09:32:06 2020 -0400

    Update tests to reflect using core default CF values feature

diff --git a/t/custom-fields/defaults-config.t b/t/custom-fields/defaults-config.t
deleted file mode 100644
index 4289e0ca..00000000
--- a/t/custom-fields/defaults-config.t
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use warnings;
-
-use RT::IR::Test tests => undef;
-
-my $defaults = RT->Config->Get('RTIR_CustomFieldsDefaults');
-$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 %test_on = (
-    'Incident Reports' => 'How Reported',
-    'Incidents'        => 'Description',
-    'Investigations'   => 'IP',
-    'Countermeasures'  => 'Where Blocked',
-);
-
-my %replace_with = (
-    'How Reported'  => 'Email',
-    'Description'   => 'Lucky Incident',
-    'IP'            => '172.16.0.1',
-    'Where Blocked' => 'On the Sun',
-);
-
-RT::Test->started_ok;
-my $agent = default_agent();
-
-{
-    my $incident_id; # countermeasure couldn't be created without incident id
-    foreach my $queue( 'Incidents', 'Incident Reports', 'Investigations', 'Countermeasures' ) {
-        my $cf_name = $test_on{ $queue };
-        my $cf_default = $defaults->{ $cf_name };
-        my $cf_replace = $replace_with{ $cf_name };
-
-        diag "goto ${queue}' create page and check fields' defaults" if $ENV{'TEST_VERBOSE'};
-        {
-            $agent->goto_create_rtir_ticket( $queue );
-            my $input = $agent->custom_field_input( $queue, $cf_name );
-            ok $input, 'found input for the field';
-            is $agent->value($input), $cf_default, "correct value";
-        }
-
-        diag "create a ticket in ${queue} queue and check fields' values" if $ENV{'TEST_VERBOSE'};
-        {
-            my $id = $agent->create_rtir_ticket_ok(
-                $queue,
-                {
-                    Subject => "test",
-                    ( $queue eq 'Countermeasures' ? ( Incident => $incident_id ) : () ),
-                },
-            );
-            $incident_id = $id if $queue eq 'Incidents';
-
-            my $ticket = RT::Ticket->new( $RT::SystemUser );
-            $ticket->Load( $id );
-            ok( $ticket->id, 'loaded ticket' );
-            is( $ticket->FirstCustomFieldValue($cf_name), $cf_default, 'correct value' );
-        }
-
-        diag "create a ticket in ${queue} queue and check fields' values" if $ENV{'TEST_VERBOSE'};
-        {
-            my $id = $agent->create_rtir_ticket_ok(
-                $queue,
-                {
-                    Subject => "test",
-                    ( $queue eq 'Countermeasures' ? ( Incident => $incident_id ) : () ),
-                },
-                { $cf_name => $cf_replace }
-            );
-            $incident_id = $id if $queue eq 'Incidents';
-
-            my $ticket = RT::Ticket->new( $RT::SystemUser );
-            $ticket->Load( $id );
-            ok( $ticket->id, 'loaded ticket' );
-            is( $ticket->FirstCustomFieldValue($cf_name), $cf_replace, 'correct value' );
-        }
-    }
-}
-
-
-undef $agent;
-done_testing;
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 e6995a744bae0468b6b04657c60ab2327b7d1aa0
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 461b901c..37f76e49 100644
--- a/etc/RTIR_Config.pm
+++ b/etc/RTIR_Config.pm
@@ -553,21 +553,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 defaults value for Resolution if there is no value when 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/temp/content b/etc/upgrade/temp/content
new file mode 100644
index 00000000..d1916ad7
--- /dev/null
+++ b/etc/upgrade/temp/content
@@ -0,0 +1,27 @@
+our @Final = sub {
+    my $custom_field = RT::CustomField->new( RT->SystemUser );
+
+    my $custom_field_defaults = RT->Config->Get('RTIR_CustomFieldsDefaults') || ();
+    unless ( scalar keys %{$custom_field} ) {
+        RT->Logger->error( "To set custom field defaults the %RTIR_CustomFieldsDefaults must be present, if there is a configuration for this value that was removed re-enable it and re-run this script." );
+        return;
+    }
+
+    foreach my $cf_name ( keys %{$custom_field_defaults} ) {
+        next if $cf_name eq 'Resolution';
+
+        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 ( $ret ) {
+            RT->Logger->debug( "Set default value for $cf_name to $custom_field_defaults->{$cf_name}" );
+        }
+        else {
+            RT->Logger->error( "Could not set default value for $cf_name custom field $msg" );
+        }
+    }
+    RT->Logger->info( "Custom field defaults are now handled in the web UI on the custom field admin page, only Resolution needs to be set in \%RTIR_CustomFieldsDefaults." );
+};
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>
diff --git a/html/RTIR/Incident/Elements/ReplyForm b/html/RTIR/Incident/Elements/ReplyForm
index f13e3952..0c8fc46f 100644
--- a/html/RTIR/Incident/Elements/ReplyForm
+++ b/html/RTIR/Incident/Elements/ReplyForm
@@ -71,8 +71,7 @@
     QueueObj  => $TicketObj->QueueObj,
     Name      => 'Resolution',
     Default   => (
-        $TicketObj->FirstCustomFieldValue('Resolution') ||
-        RT->Config->Get('RTIR_CustomFieldsDefaults')->{'Resolution'}{$Status}
+        $TicketObj->FirstCustomFieldValue('Resolution')
     ),
     Rows      => 1,
 &></td></tr>

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


hooks/post-receive
-- 
rtir


More information about the rt-commit mailing list