[Rt-commit] rt branch, 4.0/apply-scrips-to-multiple-queues, updated. rt-4.0.4-207-g0f7fb08

Ruslan Zakirov ruz at bestpractical.com
Wed Feb 1 11:25:35 EST 2012


The branch, 4.0/apply-scrips-to-multiple-queues has been updated
       via  0f7fb0814e4f31f363bce0fa0012c355ae31ed47 (commit)
       via  6bb09e61bee306e7ea68c8c28d7a51dc9cd99697 (commit)
       via  76598b3e8666616c267458601ef1fee24a272df5 (commit)
       via  3be1c1c2337d59e094a1d32c32c6a36de30bd433 (commit)
      from  17ac6e1c933fafa0138403b92fa9d10180f46e2d (commit)

Summary of changes:
 etc/upgrade/4.1.0/content                       |   34 +++++++++++
 etc/upgrade/4.1.0/schema.mysql                  |   38 +++++++++++++
 share/html/Admin/Elements/ListGlobalScrips      |   68 -----------------------
 share/html/Admin/Scrips/Elements/SelectTemplate |    8 +--
 t/api/scrip.t                                   |    1 -
 t/api/scrip_order.t                             |    2 +-
 6 files changed, 75 insertions(+), 76 deletions(-)
 create mode 100644 etc/upgrade/4.1.0/content
 create mode 100644 etc/upgrade/4.1.0/schema.mysql
 delete mode 100755 share/html/Admin/Elements/ListGlobalScrips

- Log -----------------------------------------------------------------
commit 3be1c1c2337d59e094a1d32c32c6a36de30bd433
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Jan 25 01:10:18 2012 +0400

    account scrip and queue if both passed in templates selector
    
    Further limits choice of templates and would be handy if
    next step is to apply the scrip to the queue.

diff --git a/share/html/Admin/Scrips/Elements/SelectTemplate b/share/html/Admin/Scrips/Elements/SelectTemplate
index c72fd9b..99fe82a 100755
--- a/share/html/Admin/Scrips/Elements/SelectTemplate
+++ b/share/html/Admin/Scrips/Elements/SelectTemplate
@@ -72,12 +72,8 @@ my %global;
 $global{ lc $_ } = $_ foreach map $_->Name, @{ $global->ItemsArrayRef };
 
 my @queues;
-if ( $Scrip && $Scrip->id ) {
-    @queues = @{ $Scrip->AddedTo->ItemsArrayRef };
-}
-elsif ( $Queue && $Queue->id ) {
-    @queues = ($Queue);
-}
+push @queues, @{ $Scrip->AddedTo->ItemsArrayRef } if $Scrip && $Scrip->id;
+push @queues, $Queue if $Queue && $Queue->id;
 
 my (%names, %counters);
 foreach my $queue ( @queues ) {

commit 76598b3e8666616c267458601ef1fee24a272df5
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Jan 31 00:45:05 2012 +0400

    upgrade script for scrips on mysql

diff --git a/etc/upgrade/4.1.0/content b/etc/upgrade/4.1.0/content
new file mode 100644
index 0000000..5f55bfd
--- /dev/null
+++ b/etc/upgrade/4.1.0/content
@@ -0,0 +1,34 @@
+use strict; use warnings;
+
+our @Initial = (
+    sub {
+        foreach my $stage ('TransactionCreate', 'TransactionBatch') {
+            my $applications = RT::ObjectScrips->new( RT->SystemUser );
+            $applications->Limit( FIELD => 'Stage', VALUE => $stage );
+            my $alias = $applications->Join(
+                FIELD1 => 'Scrip',
+                TABLE2 => 'Scrips', FIELD2 => 'id'
+            );
+            $applications->OrderBy(
+                { ALIAS => $alias, FIELD => 'Description', ORDER => 'ASC' },
+            );
+            my %h; my $top_so = $h{0} = 0;
+            while ( my $record = $applications->Next ) {
+                my $oid = $record->ObjectId || 0;
+
+                my $so;
+                unless ( $oid ) {
+                    %h = (); $h{0} = $so = ++$top_so;
+                }
+                else {
+                    $so = $h{ $oid } = ($h{$oid}||$h{0}) + 1;
+                }
+                next if $record->SortOrder == $so;
+
+                my ($status, $msg) = $record->SetSortOrder($so);
+                RT->Logger->error("Couldn't set sort order: $msg")
+                    unless $status;
+            }
+        }
+    },
+);
diff --git a/etc/upgrade/4.1.0/schema.mysql b/etc/upgrade/4.1.0/schema.mysql
new file mode 100644
index 0000000..c9061a7
--- /dev/null
+++ b/etc/upgrade/4.1.0/schema.mysql
@@ -0,0 +1,38 @@
+CREATE TABLE ObjectScrips (
+  id INTEGER NOT NULL  AUTO_INCREMENT,
+  Scrip integer NOT NULL  ,
+  Stage varchar(32) CHARACTER SET ascii NOT NULL DEFAULT 'TransactionCreate',
+  ObjectId integer NOT NULL,
+  SortOrder integer NOT NULL DEFAULT 0  ,
+  Disabled int2 NOT NULL DEFAULT 0 ,
+
+  Creator integer NOT NULL DEFAULT 0  ,
+  Created DATETIME NULL  ,
+  LastUpdatedBy integer NOT NULL DEFAULT 0  ,
+  LastUpdated DATETIME NULL  ,
+  PRIMARY KEY (id)
+) ENGINE=InnoDB CHARACTER SET utf8;
+
+INSERT INTO ObjectScrips(
+    Scrip, Stage, ObjectId,
+    Creator, Created, LastUpdatedBy, LastUpdated
+)
+SELECT id, Stage, Queue, Creator, Created, LastUpdatedBy, LastUpdated
+FROM Scrips
+;
+
+UPDATE ObjectScrips SET Disabled = 1 WHERE Scrip IN (
+    SELECT id FROM Scrips WHERE Stage = 'Disabled'
+);
+UPDATE ObjectScrips SET Stage = 'TransactionCreate' WHERE Stage = 'Disabled';
+
+CREATE UNIQUE INDEX ObjectScrips1 ON ObjectScrips (ObjectId, Scrip);
+
+ALTER TABLE Scrips DROP COLUMN Stage;
+ALTER TABLE Scrips DROP COLUMN Queue;
+
+ALTER TABLE ObjectCustomFields ADD COLUMN Disabled int2 NOT NULL DEFAULT 0;
+UPDATE ObjectCustomFields SET Disabled = 1 WHERE CustomField IN (
+    SELECT id FROM CustomFields WHERE Disabled != 0
+);
+ALTER TABLE CustomFields DROP COLUMN Disabled;

commit 6bb09e61bee306e7ea68c8c28d7a51dc9cd99697
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Jan 31 02:08:21 2012 +0400

    we don't use ListGlobalScrips anymore
    
    no need in keeping it around

diff --git a/share/html/Admin/Elements/ListGlobalScrips b/share/html/Admin/Elements/ListGlobalScrips
deleted file mode 100755
index 813691c..0000000
--- a/share/html/Admin/Elements/ListGlobalScrips
+++ /dev/null
@@ -1,68 +0,0 @@
-%# BEGIN BPS TAGGED BLOCK {{{
-%#
-%# COPYRIGHT:
-%#
-%# This software is Copyright (c) 1996-2011 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 }}}
-% unless ( $Scrips->Count ) {
-<p><i><&|/l&>(No scrips)</&></i></p>
-% } else {
-
-<& /Elements/CollectionList,
-    OrderBy => 'Description',
-    Order => 'ASC',
-    Rows  => 0,
-    %ARGS,
-    Format => $Format,
-    Collection => $Scrips,
-&>
-
-% }
-
-<%init>
-my $Format = RT->Config->Get('AdminSearchResultFormat')->{'Scrips'};
-
-my $Scrips = RT::Scrips->new( $session{'CurrentUser'} );
-$Scrips->LimitToGlobal;
-</%INIT>

commit 0f7fb0814e4f31f363bce0fa0012c355ae31ed47
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Feb 1 14:39:56 2012 +0400

    don't load RT in tests before ::Test module

diff --git a/t/api/scrip.t b/t/api/scrip.t
index a8437f7..4b709f0 100644
--- a/t/api/scrip.t
+++ b/t/api/scrip.t
@@ -1,7 +1,6 @@
 
 use strict;
 use warnings;
-use RT;
 use RT::Test tests => 66;
 
 my $queue = RT::Test->load_or_create_queue( Name => 'General' );
diff --git a/t/api/scrip_order.t b/t/api/scrip_order.t
index 30c6b2e..c1ae4c1 100644
--- a/t/api/scrip_order.t
+++ b/t/api/scrip_order.t
@@ -1,8 +1,8 @@
 #!/usr/bin/perl -w
 
 use strict;
+use warnings;
 
-use RT;
 use RT::Test tests => 204;
 
 my $queue = RT::Test->load_or_create_queue( Name => 'General' );

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


More information about the Rt-commit mailing list