[Bps-public-commit] RT-Extension-MandatoryOnTransition branch, master, updated. 0.19-7-g3e4f047

? sunnavy sunnavy at bestpractical.com
Mon Jul 20 14:48:17 EDT 2020


The branch, master has been updated
       via  3e4f0476eedf60ef087155899fc28420008c6833 (commit)
       via  4d517f3d7539b7163c5aca48e2e8857ceb6b7ff4 (commit)
       via  66c01eb52096275bf9dfc02cefaa394fb6d5d00d (commit)
       via  21a73297968f88b1cfa85604b2d71dfc640907c5 (commit)
       via  34b37c3ecc3519932d555476a35192d482714d74 (commit)
       via  49a43d61faf518fd4475a1e89681b5b5b592dce7 (commit)
       via  e2570c48df448524560f809ab6dda1690dfabaf7 (commit)
      from  c4b2eb6dfee3cd0b60886edb4ddd7d5812d31a2a (commit)

Summary of changes:
 Changes                                            |  3 ++
 MANIFEST                                           |  2 ++
 META.yml                                           |  4 +--
 Makefile.PL                                        |  1 +
 README                                             | 10 +++---
 .../TicketUpdate/ProcessArguments}                 | 26 ++++++++--------
 .../Display.html/BeforeProcessArguments}           | 23 +++++++-------
 inc/Module/Install/RTx.pm                          | 36 ++++++++++++++++------
 lib/RT/Extension/MandatoryOnTransition.pm          | 12 ++++----
 lib/RT/Extension/MandatoryOnTransition/Test.pm.in  |  2 +-
 xt/immutable_core_for_update.t                     | 21 ++++++++++---
 xt/mandatory_on_create.t                           |  2 ++
 12 files changed, 91 insertions(+), 51 deletions(-)
 copy html/Callbacks/RT-Extension-MandatoryOnTransition/{m/ticket/reply/BeforeUpdate => Helpers/TicketUpdate/ProcessArguments} (52%)
 copy html/Callbacks/RT-Extension-MandatoryOnTransition/{m/ticket/reply/BeforeUpdate => Ticket/Display.html/BeforeProcessArguments} (69%)

- Log -----------------------------------------------------------------
commit e2570c48df448524560f809ab6dda1690dfabaf7
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Jul 21 01:15:13 2020 +0800

    Update M:I:RTx

diff --git a/META.yml b/META.yml
index 6bc0104..2b42613 100644
--- a/META.yml
+++ b/META.yml
@@ -28,5 +28,5 @@ resources:
   license: http://opensource.org/licenses/gpl-license.php
   repository: https://github.com/bestpractical/rt-extension-mandatoryontransition
 version: '0.19'
-x_module_install_rtx_version: '0.40'
+x_module_install_rtx_version: '0.42'
 x_requires_rt: 4.0.9
diff --git a/inc/Module/Install/RTx.pm b/inc/Module/Install/RTx.pm
index 7cad529..2dd9489 100644
--- a/inc/Module/Install/RTx.pm
+++ b/inc/Module/Install/RTx.pm
@@ -6,9 +6,10 @@ use strict;
 use warnings;
 no warnings 'once';
 
+use Term::ANSIColor qw(:constants);
 use Module::Install::Base;
 use base 'Module::Install::Base';
-our $VERSION = '0.40';
+our $VERSION = '0.42';
 
 use FindBin;
 use File::Glob     ();
@@ -53,7 +54,7 @@ sub RTx {
         my @look = @INC;
         unshift @look, grep {defined and -d $_} @try;
         push @look, grep {defined and -d $_}
-            map { ( "$_/rt4/lib", "$_/lib/rt4", "$_/lib" ) } @prefixes;
+            map { ( "$_/rt5/lib", "$_/lib/rt5", "$_/rt4/lib", "$_/lib/rt4", "$_/lib" ) } @prefixes;
         last if eval {local @INC = @look; require RT; $RT::LocalLibPath};
 
         warn
@@ -76,6 +77,22 @@ sub RTx {
         $self->requires_rt('4.0.0');
     }
 
+    my $package = $name;
+    $package =~ s/-/::/g;
+    if ( $RT::CORED_PLUGINS{$package} ) {
+        my ($base_version) = $RT::VERSION =~ /(\d+\.\d+\.\d+)/;
+        die RED, <<"EOT";
+
+**** Error: Your installed version of RT ($RT::VERSION) already
+            contains this extension in core, so you don't need to
+            install it.
+
+            Check https://docs.bestpractical.com/rt/$base_version/RT_Config.html
+            to configure it.
+
+EOT
+    }
+
     # Installation locations
     my %path;
     my $plugin_path;
@@ -223,7 +240,7 @@ sub requires_rt {
     my @sorted = sort RT::Handle::cmp_version $version,$RT::VERSION;
 
     if ($sorted[-1] eq $version) {
-        die <<"EOT";
+        die RED, <<"EOT";
 
 **** Error: This extension requires RT $version. Your installed version
             of RT ($RT::VERSION) is too old.
@@ -249,12 +266,12 @@ sub requires_rt_plugin {
         unshift @INC, $path;
     } else {
         my $name = $self->name;
-        warn <<"EOT";
+        my $msg = <<"EOT";
 
 **** Warning: $name requires that the $plugin plugin be installed and
               enabled; it does not appear to be installed.
-
 EOT
+        warn RED, $msg, RESET, "\n";
     }
     $self->requires(@_);
 }
@@ -264,9 +281,8 @@ sub rt_too_new {
     my $name = $self->name;
     $msg ||= <<EOT;
 
-**** Error: Your installed version of RT (%s) is too new; this extension
-            only works with versions older than %s.
-
+**** Warning: Your installed version of RT (%s) is too new; this extension
+              has not been tested on your version of RT and may not work as expected.
 EOT
     $self->add_metadata("x_rt_too_new", $version) if $self->is_admin;
 
@@ -274,7 +290,7 @@ EOT
     my @sorted = sort RT::Handle::cmp_version $version,$RT::VERSION;
 
     if ($sorted[0] eq $version) {
-        die sprintf($msg,$RT::VERSION,$version);
+        warn RED, sprintf($msg,$RT::VERSION), RESET, "\n";
     }
 }
 
@@ -297,4 +313,4 @@ sub _load_rt_handle {
 
 __END__
 
-#line 468
+#line 484

commit 49a43d61faf518fd4475a1e89681b5b5b592dce7
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Jul 21 01:15:34 2020 +0800

    Add "." to @INC for perl 5.26+

diff --git a/Makefile.PL b/Makefile.PL
index de06f53..c3b048a 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -1,3 +1,4 @@
+use lib '.';
 use inc::Module::Install;
 
 RTx 'RT-Extension-MandatoryOnTransition';

commit 34b37c3ecc3519932d555476a35192d482714d74
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Jul 21 01:15:55 2020 +0800

    Update copyright year to 2020

diff --git a/README b/README
index 7a9a1d1..b04c415 100644
--- a/README
+++ b/README
@@ -308,7 +308,7 @@ BUGS
         L<rt.cpan.org|http://rt.cpan.org/Public/Dist/Display.html?Name=RT-Extension-MandatoryOnTransition>.
 
 LICENSE AND COPYRIGHT
-    This software is Copyright (c) 2012-2018 by Best Pracical Solutions,
+    This software is Copyright (c) 2012-2020 by Best Pracical Solutions,
     LLC.
 
     This is free software, licensed under:
diff --git a/lib/RT/Extension/MandatoryOnTransition.pm b/lib/RT/Extension/MandatoryOnTransition.pm
index 32f710a..2c7edd8 100644
--- a/lib/RT/Extension/MandatoryOnTransition.pm
+++ b/lib/RT/Extension/MandatoryOnTransition.pm
@@ -965,7 +965,7 @@ or via the web at
 
 =head1 LICENSE AND COPYRIGHT
 
-This software is Copyright (c) 2012-2018 by Best Pracical Solutions, LLC.
+This software is Copyright (c) 2012-2020 by Best Pracical Solutions, LLC.
 
 This is free software, licensed under:
 

commit 21a73297968f88b1cfa85604b2d71dfc640907c5
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Jul 21 01:41:52 2020 +0800

    Add inline edit support for RT 5

diff --git a/html/Callbacks/RT-Extension-MandatoryOnTransition/Helpers/TicketUpdate/ProcessArguments b/html/Callbacks/RT-Extension-MandatoryOnTransition/Helpers/TicketUpdate/ProcessArguments
new file mode 100644
index 0000000..fdd9dd7
--- /dev/null
+++ b/html/Callbacks/RT-Extension-MandatoryOnTransition/Helpers/TicketUpdate/ProcessArguments
@@ -0,0 +1,22 @@
+<%INIT>
+my $errors_ref = RT::Extension::MandatoryOnTransition->CheckMandatoryFields(
+    ARGSRef => $ARGSRef,
+    Ticket  => $Ticket,
+    To      => $ARGSRef->{'Status'},
+);
+
+if (@$errors_ref) {
+    RT->Logger->debug("Preventing update because of missing mandatory fields");
+    push @$Actions, @$errors_ref;
+    $r->content_type('application/json; charset=utf-8');
+    $m->out( JSON( { actions => \@$Actions } ) );
+    $m->abort;
+}
+
+</%INIT>
+
+<%ARGS>
+$Ticket
+$ARGSRef
+$Actions
+</%ARGS>
diff --git a/html/Callbacks/RT-Extension-MandatoryOnTransition/Ticket/Display.html/BeforeProcessArguments b/html/Callbacks/RT-Extension-MandatoryOnTransition/Ticket/Display.html/BeforeProcessArguments
new file mode 100644
index 0000000..2c0e8e9
--- /dev/null
+++ b/html/Callbacks/RT-Extension-MandatoryOnTransition/Ticket/Display.html/BeforeProcessArguments
@@ -0,0 +1,21 @@
+<%INIT>
+my $errors_ref = RT::Extension::MandatoryOnTransition->CheckMandatoryFields(
+    ARGSRef => $ARGSRef,
+    Ticket  => $TicketObj,
+    To      => $ARGSRef->{'Status'},
+);
+
+if (@$errors_ref) {
+    RT->Logger->debug("Preventing update because of missing mandatory fields");
+    $$SkipProcessing = 1;
+    push @$ActionsRef, @$errors_ref;
+}
+
+</%INIT>
+
+<%ARGS>
+$ARGSRef
+$TicketObj
+$ActionsRef
+$SkipProcessing
+</%ARGS>

commit 66c01eb52096275bf9dfc02cefaa394fb6d5d00d
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Jul 21 01:48:56 2020 +0800

    Update docs and default path for RT 5

diff --git a/README b/README
index b04c415..9d26660 100644
--- a/README
+++ b/README
@@ -3,7 +3,7 @@ NAME
     custom fields on status transitions
 
 RT VERSION
-    Works with RT 4.0, 4.2, 4.4
+    Works with RT 4.0, 4.2, 4.4, 5.0
 
     See below for some restrictions on RT 4.0.
 
@@ -68,7 +68,7 @@ INSTALLATION
     make install
         May need root permissions
 
-    Edit your /opt/rt4/etc/RT_SiteConfig.pm
+    Edit your /opt/rt5/etc/RT_SiteConfig.pm
         If you are using RT 4.2 or greater, add this line:
 
             Plugin('RT::Extension::MandatoryOnTransition');
@@ -81,7 +81,7 @@ INSTALLATION
         @Plugins line.
 
     Clear your mason cache
-            rm -rf /opt/rt4/var/mason_data/obj
+            rm -rf /opt/rt5/var/mason_data/obj
 
     Restart your webserver
 
@@ -119,7 +119,7 @@ CONFIGURATION
         );
 
     The transition syntax is similar to that found in RT's Lifecycles. See
-    perldoc /opt/rt4/etc/RT_Config.pm.
+    perldoc /opt/rt5/etc/RT_Config.pm.
 
   Requiring role values
     You can require any core or custom role on a RT::Ticket object, below is
diff --git a/lib/RT/Extension/MandatoryOnTransition.pm b/lib/RT/Extension/MandatoryOnTransition.pm
index 2c7edd8..1349db4 100644
--- a/lib/RT/Extension/MandatoryOnTransition.pm
+++ b/lib/RT/Extension/MandatoryOnTransition.pm
@@ -10,7 +10,7 @@ RT-Extension-MandatoryOnTransition - Require core fields and ticket custom field
 
 =head1 RT VERSION
 
-Works with RT 4.0, 4.2, 4.4
+Works with RT 4.0, 4.2, 4.4, 5.0
 
 See below for some restrictions on RT 4.0.
 
@@ -94,7 +94,7 @@ value is validated against the configured whitelist or blacklist.
 
 May need root permissions
 
-=item Edit your F</opt/rt4/etc/RT_SiteConfig.pm>
+=item Edit your F</opt/rt5/etc/RT_SiteConfig.pm>
 
 If you are using RT 4.2 or greater, add this line:
 
@@ -108,7 +108,7 @@ or add C<RT::Extension::MandatoryOnTransition> to your existing C<@Plugins> line
 
 =item Clear your mason cache
 
-    rm -rf /opt/rt4/var/mason_data/obj
+    rm -rf /opt/rt5/var/mason_data/obj
 
 =item Restart your webserver
 
@@ -149,7 +149,7 @@ Category selection before resolving tickets in every other queue.
     );
 
 The transition syntax is similar to that found in RT's Lifecycles.  See
-C<perldoc /opt/rt4/etc/RT_Config.pm>.
+C<perldoc /opt/rt5/etc/RT_Config.pm>.
 
 =head2 Requiring role values
 
diff --git a/lib/RT/Extension/MandatoryOnTransition/Test.pm.in b/lib/RT/Extension/MandatoryOnTransition/Test.pm.in
index 1955480..4c79431 100644
--- a/lib/RT/Extension/MandatoryOnTransition/Test.pm.in
+++ b/lib/RT/Extension/MandatoryOnTransition/Test.pm.in
@@ -2,7 +2,7 @@ use strict;
 use warnings;
 
 ### after: use lib qw(@RT_LIB_PATH@);
-use lib qw(/opt/rt4/local/lib /opt/rt4/lib);
+use lib qw(/opt/rt5/local/lib /opt/rt5/lib);
 
 package RT::Extension::MandatoryOnTransition::Test;
 

commit 4d517f3d7539b7163c5aca48e2e8857ceb6b7ff4
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Jul 21 02:07:48 2020 +0800

    Update tests for RT 5

diff --git a/xt/immutable_core_for_update.t b/xt/immutable_core_for_update.t
index 298a1f7..d61f7f6 100644
--- a/xt/immutable_core_for_update.t
+++ b/xt/immutable_core_for_update.t
@@ -7,6 +7,9 @@ Set( %MandatoryOnTransition,
          '* -> resolved' => ['TimeWorked',]
      }
     );
+Set( %PriorityAsString,
+    Default => { Low => 0, Medium => 50, High => 100 },
+);
 CONFIG
     ;
 
@@ -76,10 +79,15 @@ diag "Modify ticket through Basics without permanently altering %CORE_FOR_UPDATE
     $m->goto_ticket($t0->id);
     $m->follow_link_ok( { text => 'Basics' }, 'Get Modify.html of ticket' );
     $m->submit_form_ok( { form_name => 'TicketModify',
-                          fields => { Priority => 1, },
+                          fields => { Priority => 50, },
                           button => 'SubmitTicket', },
                         'Modify any ticket 0 metadata except status, queue, or TimeWorked', );
-    $m->content_contains('Priority changed from (no value) to '1'');
+    if ( RT->Config->Get('EnablePriorityAsString') ) {
+        $m->text_contains("Priority changed from 'Low' to 'Medium'");
+    }
+    else {
+        $m->text_contains("Priority changed from (no value) to '50'");
+    }
 
     $m->goto_ticket($t1->id);
     $m->follow_link_ok( { text => 'Resolve' }, 'Try to resolve ticket');
@@ -110,10 +118,15 @@ diag "Modify ticket through Jumbo without permanently altering %CORE_FOR_UPDATE"
     $m->goto_ticket($t0->id);
     $m->follow_link_ok( { text => 'Jumbo' }, 'Get ModifyAll.html of ticket' );
     $m->submit_form_ok( { form_name => 'TicketModifyAll',
-                          fields => { Priority => 1, },
+                          fields => { Priority => 50, },
                           button => 'SubmitTicket', },
                         'Modify any ticket 0 metadata except status, queue, or TimeWorked', );
-    $m->content_contains('Priority changed from (no value) to '1'');
+    if ( RT->Config->Get('EnablePriorityAsString') ) {
+        $m->text_contains("Priority changed from 'Low' to 'Medium'");
+    }
+    else {
+        $m->text_contains("Priority changed from (no value) to '50'");
+    }
 
     $m->goto_ticket($t1->id);
     $m->follow_link_ok( { text => 'Resolve' }, 'Try to resolve ticket');
diff --git a/xt/mandatory_on_create.t b/xt/mandatory_on_create.t
index 02c9f48..b67a002 100644
--- a/xt/mandatory_on_create.t
+++ b/xt/mandatory_on_create.t
@@ -66,6 +66,7 @@ diag "Test mandatory fields on create";
                           fields => { Status => 'resolved',
                                       "Object-RT::Ticket--CustomField-$id-Values" => 'foo',
                                       'TimeWorked' => '10', },
+                          button => 'SubmitTicket',
                         }, 'Submit with resolved status');
 
     $m->content_contains("Ticket 1 created in queue 'General'");
@@ -147,6 +148,7 @@ diag "Test mandatory fields on create with content";
                           fields => { Status => 'resolved',
                                       'TimeWorked' => '10',
                                       'Content' => 'This is a message' },
+                          button => 'SubmitTicket',
                         }, 'Submit with resolved status');
 
     $m->content_contains("Ticket 3 created in queue 'Content'");

commit 3e4f0476eedf60ef087155899fc28420008c6833
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Jul 21 02:45:44 2020 +0800

    Prep 0.20

diff --git a/Changes b/Changes
index d01ddd2..94e7cc6 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,6 @@
+0.20 2020-07-20
+ - Add RT 5 support
+
 0.19 2019-08-19
  - Only check for mandatory fields on a status or queue change.
  - Process Content the same as RT, which includes clearing whitespace
diff --git a/MANIFEST b/MANIFEST
index e37f3e8..0cdd251 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,10 +1,12 @@
 Changes
 html/Callbacks/RT-Extension-MandatoryOnTransition/Elements/EditCustomFields/BeforeCustomFields
 html/Callbacks/RT-Extension-MandatoryOnTransition/Elements/EditCustomFields/MassageCustomFields
+html/Callbacks/RT-Extension-MandatoryOnTransition/Helpers/TicketUpdate/ProcessArguments
 html/Callbacks/RT-Extension-MandatoryOnTransition/m/ticket/create/BeforeCreate
 html/Callbacks/RT-Extension-MandatoryOnTransition/m/ticket/reply/AfterWorked
 html/Callbacks/RT-Extension-MandatoryOnTransition/m/ticket/reply/BeforeUpdate
 html/Callbacks/RT-Extension-MandatoryOnTransition/Ticket/Create.html/BeforeCreate
+html/Callbacks/RT-Extension-MandatoryOnTransition/Ticket/Display.html/BeforeProcessArguments
 html/Callbacks/RT-Extension-MandatoryOnTransition/Ticket/Elements/EditBasics/MassageFields
 html/Callbacks/RT-Extension-MandatoryOnTransition/Ticket/Elements/EditCustomFields/MassageCustomFields
 html/Callbacks/RT-Extension-MandatoryOnTransition/Ticket/Modify.html/Default
diff --git a/META.yml b/META.yml
index 2b42613..87ecb59 100644
--- a/META.yml
+++ b/META.yml
@@ -27,6 +27,6 @@ requires:
 resources:
   license: http://opensource.org/licenses/gpl-license.php
   repository: https://github.com/bestpractical/rt-extension-mandatoryontransition
-version: '0.19'
+version: '0.20'
 x_module_install_rtx_version: '0.42'
 x_requires_rt: 4.0.9
diff --git a/lib/RT/Extension/MandatoryOnTransition.pm b/lib/RT/Extension/MandatoryOnTransition.pm
index 1349db4..b811583 100644
--- a/lib/RT/Extension/MandatoryOnTransition.pm
+++ b/lib/RT/Extension/MandatoryOnTransition.pm
@@ -2,7 +2,7 @@ use strict;
 use warnings;
 package RT::Extension::MandatoryOnTransition;
 
-our $VERSION = '0.19';
+our $VERSION = '0.20';
 
 =head1 NAME
 

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


More information about the Bps-public-commit mailing list