[Rt-commit] r19319 - in rt/3.999/branches/config-in-db: . lib/RT/Action lib/RT/View lib/RT/View/Admin sbin share/html/Admin/Tools/Shredder/Elements/Error share/html/Prefs share/html/Widgets share/web/static/css

sunnavy at bestpractical.com sunnavy at bestpractical.com
Tue Apr 21 21:16:57 EDT 2009


Author: sunnavy
Date: Tue Apr 21 21:16:56 2009
New Revision: 19319

Added:
   rt/3.999/branches/config-in-db/lib/RT/Action/CreateGroup.pm
   rt/3.999/branches/config-in-db/lib/RT/View/Admin.pm
   rt/3.999/branches/config-in-db/lib/RT/View/Admin/CustomFields.pm
   rt/3.999/branches/config-in-db/lib/RT/View/Admin/Queues.pm
   rt/3.999/branches/config-in-db/share/web/static/css/app-base.css
      - copied unchanged from r18766, /rt/3.999/branches/config-in-db/share/web/static/css/base.css
   rt/3.999/branches/config-in-db/share/web/static/css/app.css
      - copied, changed from r18766, /rt/3.999/branches/config-in-db/share/web/static/css/main.css
   rt/3.999/branches/config-in-db/share/web/static/css/rt-forms.css
      - copied, changed from r18766, /rt/3.999/branches/config-in-db/share/web/static/css/forms.css
Removed:
   rt/3.999/branches/config-in-db/share/web/static/css/base.css
   rt/3.999/branches/config-in-db/share/web/static/css/forms.css
   rt/3.999/branches/config-in-db/share/web/static/css/main.css
Modified:
   rt/3.999/branches/config-in-db/   (props changed)
   rt/3.999/branches/config-in-db/.gitignore
   rt/3.999/branches/config-in-db/lib/RT/Config.pm
   rt/3.999/branches/config-in-db/lib/RT/DateTime.pm
   rt/3.999/branches/config-in-db/lib/RT/View.pm
   rt/3.999/branches/config-in-db/lib/RT/View/Admin/Groups.pm
   rt/3.999/branches/config-in-db/lib/RT/View/Admin/Users.pm
   rt/3.999/branches/config-in-db/lib/RT/View/CRUD.pm
   rt/3.999/branches/config-in-db/sbin/rt-migrate-db-from-3.8
   rt/3.999/branches/config-in-db/share/html/Admin/Tools/Shredder/Elements/Error/NoStorage
   rt/3.999/branches/config-in-db/share/html/Prefs/Other.html
   rt/3.999/branches/config-in-db/share/html/Widgets/FinalizeWidgetArguments

Log:
 r20759 at sunnavys-mb (orig r19206):  ruz | 2009-04-16 06:25:57 +0800
 * update upgrade script, it doesn't work yet however
 r20766 at sunnavys-mb (orig r19213):  sartak | 2009-04-16 10:50:47 +0800
 Change the DateTime format from strftime specifier to method name
 r20767 at sunnavys-mb (orig r19214):  sartak | 2009-04-16 10:50:53 +0800
 Change DateTimeFormat picker to be a dropdown instead of a textbox
 r20768 at sunnavys-mb (orig r19215):  sartak | 2009-04-16 10:50:56 +0800
 More gitignore files
 r20769 at sunnavys-mb (orig r19216):  sartak | 2009-04-16 11:16:41 +0800
 Fix case of RT::Config's %META
 r20770 at sunnavys-mb (orig r19217):  sartak | 2009-04-16 11:21:24 +0800
 RT::Model::Queues -> RT::Model::QueueCollection
 r20771 at sunnavys-mb (orig r19218):  sartak | 2009-04-16 11:22:05 +0800
 Unlimit -> unlimit
 r20772 at sunnavys-mb (orig r19219):  sartak | 2009-04-16 11:22:46 +0800
 Handle RT4 style foo_bar style arguments in FinalizeWidgetArguments
 r20773 at sunnavys-mb (orig r19220):  sartak | 2009-04-16 11:27:11 +0800
 Fix argument case so that Prefs/Others actually works
 r20774 at sunnavys-mb (orig r19221):  sartak | 2009-04-16 11:30:46 +0800
 Remove these RT3 crutches :)
 r20782 at sunnavys-mb (orig r19229):  ruz | 2009-04-17 02:35:22 +0800
 * update upgrading script
 r20785 at sunnavys-mb (orig r19232):  sartak | 2009-04-17 04:03:54 +0800
 RT::View::Admin for collecting all the admin-specific views
 r20786 at sunnavys-mb (orig r19233):  sartak | 2009-04-17 04:11:39 +0800
 For now, forbid group creation through CRUD
 r20787 at sunnavys-mb (orig r19234):  sartak | 2009-04-17 04:25:07 +0800
 Define an explicit CreateGroup action for creating user-defined groups
 r20788 at sunnavys-mb (orig r19235):  sartak | 2009-04-17 05:55:30 +0800
 Begin de-conflicting css files
 r20789 at sunnavys-mb (orig r19236):  sartak | 2009-04-17 05:58:01 +0800
 Disambiguate rt-forms.css from forms.css
 r20790 at sunnavys-mb (orig r19237):  sartak | 2009-04-17 07:03:47 +0800
 Make the name of each group a link to its full modify page
 r20791 at sunnavys-mb (orig r19238):  sartak | 2009-04-17 07:06:49 +0800
 Make links in forms bold
 r20792 at sunnavys-mb (orig r19239):  sartak | 2009-04-17 07:36:00 +0800
 Titles for our admin CRUD
 r20793 at sunnavys-mb (orig r19240):  sartak | 2009-04-17 07:36:04 +0800
 Set title in RT::View::CRUD's overridden index.html
 r20818 at sunnavys-mb (orig r19265):  ruz | 2009-04-17 09:53:08 +0800
 * upgrade script should be much better
 r20826 at sunnavys-mb (orig r19273):  sartak | 2009-04-18 08:02:05 +0800
 Use page_title for the in-page title too
 r20827 at sunnavys-mb (orig r19274):  sartak | 2009-04-18 08:09:26 +0800
 Factor the ugly form field overriding out into the superclass
 r20861 at sunnavys-mb (orig r19308):  sartak | 2009-04-21 15:05:11 +0800
 Limit user CRUD to privileged users
 r20863 at sunnavys-mb (orig r19310):  sartak | 2009-04-21 17:05:30 +0800
 Basic queue config crud
 r20866 at sunnavys-mb (orig r19313):  sartak | 2009-04-21 17:10:41 +0800
 Basic CF CRUD
 r20867 at sunnavys-mb (orig r19314):  sartak | 2009-04-21 17:20:36 +0800
 Can't really have tags inside _(), so rewrite the message


Modified: rt/3.999/branches/config-in-db/.gitignore
==============================================================================
--- rt/3.999/branches/config-in-db/.gitignore	(original)
+++ rt/3.999/branches/config-in-db/.gitignore	Tue Apr 21 21:16:56 2009
@@ -10,4 +10,5 @@
 pm_to_blib
 t/data/gnupg/keyrings/random_seed
 t/mailbox_*
-
+rt4
+var/

Added: rt/3.999/branches/config-in-db/lib/RT/Action/CreateGroup.pm
==============================================================================
--- (empty file)
+++ rt/3.999/branches/config-in-db/lib/RT/Action/CreateGroup.pm	Tue Apr 21 21:16:56 2009
@@ -0,0 +1,28 @@
+use strict;
+use warnings;
+
+=head1 NAME
+
+RT::Action::CreateGroup
+
+=cut
+
+package RT::Action::CreateGroup;
+use base qw/RT::Action RT::Action::Record::Create/;
+
+=head2 create_record
+
+This uses L<RT::Model::Group/create_user_defined> for creating user-defined
+groups.
+
+=cut
+
+sub create_record {
+    my $self  = shift;
+    my $group = $self->record;
+
+    return $group->create_user_defined(@_);
+}
+
+1;
+

Modified: rt/3.999/branches/config-in-db/lib/RT/Config.pm
==============================================================================

Modified: rt/3.999/branches/config-in-db/lib/RT/DateTime.pm
==============================================================================
--- rt/3.999/branches/config-in-db/lib/RT/DateTime.pm	(original)
+++ rt/3.999/branches/config-in-db/lib/RT/DateTime.pm	Tue Apr 21 21:16:56 2009
@@ -135,7 +135,8 @@
 sub config_format {
     my $self = _canonicalize_self(@_);
 
-    return $self->strftime(RT->config->get('date_time_format'));
+    my $format = RT->config->get('DateTimeFormat');
+    return $self->$format;
 }
 
 sub date {

Modified: rt/3.999/branches/config-in-db/lib/RT/View.pm
==============================================================================
--- rt/3.999/branches/config-in-db/lib/RT/View.pm	(original)
+++ rt/3.999/branches/config-in-db/lib/RT/View.pm	Tue Apr 21 21:16:56 2009
@@ -51,11 +51,8 @@
 package RT::View;
 use Jifty::View::Declare -base;
 
-require RT::View::Admin::Groups;
-alias RT::View::Admin::Groups under 'admin/groups/';
-
-require RT::View::Admin::Users;
-alias RT::View::Admin::Users under 'admin/users/';
+require RT::View::Admin;
+alias RT::View::Admin under 'admin/';
 
 require RT::View::Ticket;
 alias RT::View::Ticket under 'ticket/';

Added: rt/3.999/branches/config-in-db/lib/RT/View/Admin.pm
==============================================================================
--- (empty file)
+++ rt/3.999/branches/config-in-db/lib/RT/View/Admin.pm	Tue Apr 21 21:16:56 2009
@@ -0,0 +1,67 @@
+# BEGIN BPS TAGGED BLOCK {{{
+#
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
+#                                          <jesse 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/copyleft/gpl.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 }}}
+use warnings;
+use strict;
+
+package RT::View::Admin;
+use Jifty::View::Declare -base;
+
+require RT::View::Admin::Groups;
+alias RT::View::Admin::Groups under 'groups/';
+
+require RT::View::Admin::Users;
+alias RT::View::Admin::Users under 'users/';
+
+require RT::View::Admin::Queues;
+alias RT::View::Admin::Queues under 'queues/';
+
+require RT::View::Admin::CustomFields;
+alias RT::View::Admin::CustomFields under 'custom_fields/';
+
+1;
+

Added: rt/3.999/branches/config-in-db/lib/RT/View/Admin/CustomFields.pm
==============================================================================
--- (empty file)
+++ rt/3.999/branches/config-in-db/lib/RT/View/Admin/CustomFields.pm	Tue Apr 21 21:16:56 2009
@@ -0,0 +1,63 @@
+# BEGIN BPS TAGGED BLOCK {{{
+#
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
+#                                          <jesse 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/copyleft/gpl.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 }}}
+use warnings;
+use strict;
+
+package RT::View::Admin::CustomFields;
+use Jifty::View::Declare -base;
+use base 'RT::View::CRUD';
+
+use constant page_title      => 'Custom Field Management';
+use constant object_type     => 'CustomField';
+use constant display_columns => qw(name type);
+
+use constant tab_url         => '/Admin/Elements/CustomFieldTabs';
+use constant current_tab     => 'Admin/Queues/';
+
+1;
+

Modified: rt/3.999/branches/config-in-db/lib/RT/View/Admin/Groups.pm
==============================================================================
--- rt/3.999/branches/config-in-db/lib/RT/View/Admin/Groups.pm	(original)
+++ rt/3.999/branches/config-in-db/lib/RT/View/Admin/Groups.pm	Tue Apr 21 21:16:56 2009
@@ -52,6 +52,7 @@
 use Jifty::View::Declare -base;
 use base 'RT::View::CRUD';
 
+use constant page_title     => 'Group Management';
 use constant object_type    => 'Group';
 use constant tab_url        => '/Admin/Elements/GroupTabs';
 use constant current_tab    => 'Admin/Groups/';
@@ -65,5 +66,24 @@
     return $c;
 }
 
+=head2 view_field_name
+
+Display each group's name as a hyperlink to the modify page
+
+=cut
+
+sub view_field_name {
+    my $self = shift;
+    my %args = @_;
+
+    $self->view_via_callback(%args, callback => sub {
+        my %args = @_;
+        hyperlink(
+            label => $args{current_value},
+            url   => "/Admin/Groups/Modify.html?id=$args{id}",
+        );
+    });
+}
+
 1;
 

Added: rt/3.999/branches/config-in-db/lib/RT/View/Admin/Queues.pm
==============================================================================
--- (empty file)
+++ rt/3.999/branches/config-in-db/lib/RT/View/Admin/Queues.pm	Tue Apr 21 21:16:56 2009
@@ -0,0 +1,63 @@
+# BEGIN BPS TAGGED BLOCK {{{
+#
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
+#                                          <jesse 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/copyleft/gpl.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 }}}
+use warnings;
+use strict;
+
+package RT::View::Admin::Queues;
+use Jifty::View::Declare -base;
+use base 'RT::View::CRUD';
+
+use constant page_title      => 'Queue Management';
+use constant object_type     => 'Queue';
+use constant display_columns => qw(id name description correspond_address initial_priority default_due_in);
+
+use constant tab_url         => '/Admin/Elements/QueueTabs';
+use constant current_tab     => 'Admin/Queues/';
+
+1;
+

Modified: rt/3.999/branches/config-in-db/lib/RT/View/Admin/Users.pm
==============================================================================
--- rt/3.999/branches/config-in-db/lib/RT/View/Admin/Users.pm	(original)
+++ rt/3.999/branches/config-in-db/lib/RT/View/Admin/Users.pm	Tue Apr 21 21:16:56 2009
@@ -52,11 +52,20 @@
 use Jifty::View::Declare -base;
 use base 'RT::View::CRUD';
 
+use constant page_title      => 'User Management';
 use constant object_type     => 'User';
 use constant display_columns => qw(id name email);
 
 use constant tab_url         => '/Admin/Elements/UserTabs';
 use constant current_tab     => 'Admin/Users/';
 
+# limit to privileged users
+sub _current_collection {
+    my $self = shift;
+    my $collection = $self->SUPER::_current_collection(@_);
+    $collection->limit_to_privileged;
+    return $collection;
+}
+
 1;
 

Modified: rt/3.999/branches/config-in-db/lib/RT/View/CRUD.pm
==============================================================================
--- rt/3.999/branches/config-in-db/lib/RT/View/CRUD.pm	(original)
+++ rt/3.999/branches/config-in-db/lib/RT/View/CRUD.pm	Tue Apr 21 21:16:56 2009
@@ -61,12 +61,14 @@
 sub current_subtab { shift->current_tab(@_) }
 
 template 'index.html' => page {
+    title => shift->page_title,
+} content {
     my $self = shift;
 
     render_mason($self->tab_url, {
         current_tab    => $self->current_tab,
         current_subtab => $self->current_subtab,
-        title          => $self->object_type,
+        title          => $self->page_title,
     });
 
     form {
@@ -77,4 +79,30 @@
     }
 };
 
+sub view_via_callback {
+    my $self = shift;
+    my %args = @_;
+
+    my $field = $args{action}->form_field($args{field}, render_mode => 'read');
+
+    $args{id} = $args{action}->argument_value('id');
+    $args{current_value} = "@{[$field->current_value]}";
+
+    # I don't see a clean way to do this :(
+    $field->render_wrapper_start();
+    $field->render_preamble();
+
+    $field->render_label();
+
+    # render the value with a hyperlink
+    span {
+        attr { class is "@{[ $field->classes ]} value" };
+        $args{callback}->(%args);
+    };
+
+    $field->render_wrapper_end();
+
+    return;
+}
+
 1;

Modified: rt/3.999/branches/config-in-db/sbin/rt-migrate-db-from-3.8
==============================================================================
--- rt/3.999/branches/config-in-db/sbin/rt-migrate-db-from-3.8	(original)
+++ rt/3.999/branches/config-in-db/sbin/rt-migrate-db-from-3.8	Tue Apr 21 21:16:56 2009
@@ -1,6 +1,8 @@
 #!/usr/bin/perl 
+
 use strict;
 use warnings;
+
 use Getopt::Long;
 use Carp;
 use Text::Naming::Convention qw/renaming/;
@@ -8,215 +10,288 @@
 use FindBin;
 use lib "$FindBin::Bin/../lib";
 
-my %args;
-
-BEGIN {
-    confess "unknown option"
-      unless GetOptions( \%args, 'db-name-rt3=s', 'help' );
-
-    my $USAGE = <<'END';
-before run, please backup your dbs
-and we need to set up a basic rt4 db with the cmd:
-$ jifty schema --setup --no-bootstrap
-
-then run: ./sbin/migrate-db-from-rt3
-
-options: 
+my %opts;
+GetOptions( \%opts,
+    "help", "upgrade", "debug",
+);
+if ( $opts{'help'} || !$opts{'upgrade'} ) {
+    require Pod::Usage;
+    import Pod::Usage;
+    pod2usage(-verbose => 1);
+    exit 1;
+}
 
-help: print this usage
-db-name-rt3: db name of rt3, default is 'rt3'
-END
+{
+    require Jifty::Script::Schema;
+    my $schema = Jifty::Script::Schema->new(
+        no_bootstrap      => 1,
+        no_model_tables   => 1,
+        create_database   => 0,
+        drop_database     => 0,
+    );
+    $schema->setup_environment;
+    Jifty->setup_database_connection( no_version_check => 1 );
+    $schema->create_all_tables;
+}
 
-    if ( $args{'help'} ) {
-        print $USAGE;
-        exit 0;
-    }
 
-    use Jifty::Everything;
-    Jifty->new();
+{
+    require Jifty::Everything;
+    import Jifty::Everything;
+    new Jifty;
 }
 
-
-my $db_name_rt3 = $args{'db-name-rt3'} || 'rt3';
 my $db_type = Jifty->config->framework('Database')->{'Driver'};
-my $db_name_rt4 = Jifty->config->framework('Database')->{'Database'};
+my $db_name = Jifty->config->framework('Database')->{'Database'};
 my $db_user = Jifty->config->framework('Database')->{'User'};
+my $dbh     = Jifty->handle->dbh;
+
+my %columns = (
+    ACL => [qw(id PrincipalType PrincipalId RightName ObjectType ObjectId DelegatedBy DelegatedFrom)],
+    Attachments => [qw(id TransactionId Parent MessageId Subject Filename ContentType ContentEncoding Content Headers Creator Created)],
+    Attributes => [qw(id Name Description Content ContentType ObjectType ObjectId Creator Created LastUpdatedBy LastUpdated)],
+    CachedGroupMembers => [qw(id GroupId MemberId Via ImmediateParentId Disabled)],
+    CustomFields => [qw(id Name Type MaxValues Pattern Repeated Description SortOrder LookupType Creator Created LastUpdatedBy LastUpdated Disabled)],
+    CustomFieldValues => [qw(id CustomField Name Description SortOrder Creator Created LastUpdatedBy LastUpdated)],
+    GroupMembers => [qw(id GroupId MemberId)],
+    Groups => [qw(id Name Description Domain Type Instance)],
+    Links => [qw(id Base Target Type LocalTarget LocalBase LastUpdatedBy LastUpdated Creator Created)],
+    ObjectCustomFields => [qw(id CustomField ObjectId SortOrder Creator Created LastUpdatedBy LastUpdated)],
+    ObjectCustomFieldValues => [qw(id CustomField ObjectType ObjectId SortOrder Content LargeContent ContentType ContentEncoding Creator Created LastUpdatedBy LastUpdated Disabled)],
+    Principals => [qw(id Type ObjectId Disabled)],
+    Queues => [qw(id Name Description CorrespondAddress CommentAddress InitialPriority FinalPriority DefaultDueIn Creator Created LastUpdatedBy LastUpdated Disabled)],
+    ScripActions => [qw(id Name Description ExecModule Argument Creator Created LastUpdatedBy LastUpdated)],
+    ScripConditions => [qw(id Name Description ExecModule Argument ApplicableTransTypes Creator Created LastUpdatedBy LastUpdated)],
+    Scrips => [qw(id Description ScripCondition ScripAction ConditionRules ActionRules CustomIsApplicableCode CustomPrepareCode CustomCommitCode Stage Queue Template Creator Created LastUpdatedBy LastUpdated)],
+    Templates => [qw(id Queue Name Description Type Language TranslationOf Content LastUpdated LastUpdatedBy Creator Created)],
+    Tickets => [qw(id EffectiveId Queue Type IssueStatement Resolution Owner Subject InitialPriority FinalPriority Priority TimeEstimated TimeWorked Status TimeLeft Told Starts Started Due Resolved LastUpdatedBy LastUpdated Creator Created Disabled)],
+    Transactions => [qw(id ObjectType ObjectId TimeTaken Type Field OldValue NewValue ReferenceType OldReference NewReference Data Creator Created)],
+    Users => [qw(id Name Password Comments Signature EmailAddress FreeformContactInfo Organization RealName NickName Lang EmailEncoding WebEncoding ExternalContactInfoId ContactInfoSystem ExternalAuthId AuthSystem Gecos HomePhone WorkPhone MobilePhone PagerPhone Address1 Address2 City State Zip Country Timezone PGPKey Creator Created LastUpdatedBy LastUpdated)],
+);
+
+my @tables = keys %columns;
 
-my %name_changes = (
+my %special_renaming = (
     nick_name           => 'nickname',
     email_address       => 'email',
     principal_type      => 'type',
     immediate_parent_id => 'immediate_parent',
 );
 
-my @tables = qw/ACL Attachments  Attributes CachedGroupMembers CustomFieldValues
-CustomFields GroupMembers Groups Links ObjectCustomFieldValues ObjectCustomFields    Principals  Queues ScripActions ScripConditions Scrips Templates Tickets
-Transactions Users sessions/;
-
-my $tables_need_change = 'ACL Principals Templates Scrips';
-my $tables_no_change = 'Attachments  Attributes CachedGroupMembers CustomFieldValues CustomFields GroupMembers Groups Links ObjectCustomFieldValues ObjectCustomFields    Queues ScripActions ScripConditions Tickets Transactions Users sessions';
-
-if ( $db_type eq 'mysql' ) {
-    $db_user ||= 'root';
-
-    my $run_sql = sub {
-        my $db  = shift;
-        my @sql = @_;
-        open my $fh, '|-', "mysql -u $db_user $db" or die $!;
-        print $fh $_ for @sql;
-        close $fh;
-    };
-
-    # make a tmp rt3 db, with to-be-dropped columns dropped
-    my $tmp_rt3_db = "tmp_${db_name_rt3}_for_migration";
-    print "creating database $tmp_rt3_db\n";
-    $run_sql->( '',          "create database $tmp_rt3_db;\n" );
-    print "created database $tmp_rt3_db with success\n";
-
-    print "copying tables need to alter( $tables_need_change ) to $tmp_rt3_db\n";
-    system(
-        "mysqldump -u $db_user $db_name_rt3 $tables_need_change |
-      mysql -u $db_user $tmp_rt3_db"
-    ) && die $!;
-    print "copied tables need to alter with success!\n";
-
-    # now we alert tables
-    my @alter_sql = (
-        'alter table ACL drop column DelegatedBy;',
-        'alter table ACL drop column DelegatedFrom;',
-        'alter table Principals drop column ObjectId;',
-        'alter table Templates drop column Language;',
-        'alter table Templates drop column TranslationOf;',
-        'alter table Scrips drop column ConditionRules;',
-        'alter table Scrips drop column ActionRules;'
-    );
-    print "altering the copied tables\n";
-    $run_sql->( $tmp_rt3_db, @alter_sql );
-    print "altered the copied tables with success\n";
-
-    my $insert = sub {
-        my $input_cmd = shift;
-
-        open my $fh, '-|', $input_cmd or die $!;
-
-        while (<$fh>) {
-            next unless /^INSERT INTO/;
-            my $insert = $_;
-
-            # e.g. RT::Group -> RT::Model::Group
-            $insert =~ s/'RT::(?!System|ScripAction)(\w+)\b/'RT::Model::$1/g;
-            $insert =~ s/'Owner'/'owner'/g;
-            $insert =~ s/'Requestor'/'requestor'/g;
-            $insert =~ s/'Cc'/'cc'/g;
-            $insert =~ s/'AdminCc'/'admin_cc'/g;
-            $insert =~
-s/(?<!INSERT INTO )`(\w+)`/'`' . ($name_changes{renaming( $1)} || renaming($1)) . '`'/ge;
-            $run_sql->( $db_name_rt4, $insert );
+my %drop_columns = (
+# drop columns related to delegations
+    ACL        => [qw(DelegatedBy DelegatedFrom)],
+# always was equal to id
+    Principals => [qw(ObjectId)],
+# XXX: do we really want to drop this?
+    Templates  => [qw(Language TranslationOf)],
+# never used this fields
+    Scrips     => [qw(ConditionRules ActionRules)],
+);
+
+
+update_all_tables();
+rename_columns_in_all_tables();
+drop_columns_in_all_tables();
+post_update_all_tables();
+
+sub post_update_attributes_table {
+
+# need to add a row for the default status schema in Attributes and update
+# part columns of that table
+    require RT::Model::AttributeCollection;
+    my $collection = RT::Model::AttributeCollection->new( current_user => RT->system_user );
+    $collection->unlimit;
+    while ( my $attr = $collection->next ) {
+        my $desc = $attr->description;
+        $desc =~ s/\[_(\d)\]/%$1/g; # [_1] => %1
+        $attr->set_description($desc);
+
+        my $content = $attr->content;
+
+        next unless ref $content && ref $content eq 'HASH';
+        for my $k ( keys %$content ) {
+            my $v = $content->{$k};
+            delete $content->{$k};
+            $content->{ renaming $k} = $v;
         }
-    };
+        my $format = $content->{'format'};
+        if ( $format ) {
+            # update for the name convention changes
+            $format =~ s/__(?!WebPath)(\w+)__/'__' . renaming($1) . '__'/eg;
+            $format =~ s/TITLE:Subject/TITLE:subject/g;
+            $format =~ s/(,\s*|^\s*)(\w+)(?=\s*,|\s*$)/$1 . renaming($2)/eg;
+            $content->{'format'} = $format;
+        }
+        $attr->set_content($content);
+    }
 
-    print "inserting data to $db_name_rt4\n";
-# insert unchanged(actually, no so changed) tables from origion db
-    $insert->(
-"mysqldump -u $db_user $db_name_rt3 --complete-insert --no-create-info $tables_no_change"
-    );
+    add_default_status_schema();
+}
 
-# import changed tables form tmp db
-    $insert->(
-"mysqldump -u $db_user $tmp_rt3_db --complete-insert --no-create-info"
+sub add_default_status_schema {
+    require RT::Model::Attribute;
+    my $attribute = RT::Model::Attribute->new( current_user => RT->system_user );
+    my @results = $attribute->create(
+        name        => 'StatusSchemas',
+        object      => RT->system,
+        description => 'all system status schemas',
+        content     => {
+            default => {
+                initial     => ['new'],
+                active      => [ 'open', 'stalled' ],
+                inactive    => [ 'resolved', 'rejected', 'deleted' ],
+                transitions => {
+                    new      => [qw(open resolved rejected deleted)],
+                    open     => [qw(stalled resolved rejected deleted)],
+                    stalled  => [qw(open)],
+                    resolved => [qw(open)],
+                    rejected => [qw(open)],
+                    deleted  => [qw(open)],
+                },
+                actions => {
+                    'new -> open'     => [ 'Open It', 'respond' ],
+                    'new -> resolved' => [ 'Resolve', 'comment' ],
+                    'new -> rejected' => [ 'Reject',  'respond' ],
+                    'new -> deleted'  => [ 'Delete',  '' ],
+
+                    'open -> stalled'  => [ 'Stall',   'comment' ],
+                    'open -> resolved' => [ 'Resolve', 'comment' ],
+                    'open -> rejected' => [ 'Reject',  'respond' ],
+                    'open -> deleted'  => [ 'Delete',  'hide' ],
+
+                    'stalled -> open'  => [ 'Open It',  '' ],
+                    'resolved -> open' => [ 'Re-open',  'comment' ],
+                    'rejected -> open' => [ 'Re-open',  'comment' ],
+                    'deleted -> open'  => [ 'Undelete', '' ],
+                },
+            }
+        }
     );
-    print "inserted data to $db_name_rt4 with success\n";
+}
+
+print "updated attributes with success\n";
 
-    $run_sql->( '',                   "drop database $tmp_rt3_db\n" );
 
-    # set up proper values for new added columns
-    # Queue.status_schema: 'default' # this is done automatically by rt4
+sub post_update_users_table {
+    # add email confirmed
+    require RT::Model::User;
+    RT::Model::User->add_column_in_db('email_confirmed');
+    execute_query("UPDATE Users SET email_confirmed = 1 WHERE name != 'RT_System'");
 }
 
-print "updating table Attributes\n";
-# need to add a row for the default status schema in Attributes and update
-# part columns of that table
-use RT::Model::AttributeCollection;
-my $collection =
-  RT::Model::AttributeCollection->new( current_user => RT->system_user );
-$collection->unlimit;
-while ( my $attr = $collection->next ) {
-    my $desc = $attr->description;
-    $desc =~ s/\[_(\d)\]/%$1/g; # [_1] => %1
-    $attr->set_description($desc);
-
-    my $content = $attr->content;
-
-    next unless ref $content && ref $content eq 'HASH';
-    for my $k ( keys %$content ) {
-        my $v = $content->{$k};
-        delete $content->{$k};
-        $content->{ renaming $k} = $v;
-    }
-    my $format = $content->{'format'};
-    if ( $format ) {
-        # update for the name convention changes
-        $format =~ s/__(?!WebPath)(\w+)__/'__' . renaming($1) . '__'/eg;
-        $format =~ s/TITLE:Subject/TITLE:subject/g;
-        $format =~ s/(,\s*|^\s*)(\w+)(?=\s*,|\s*$)/$1 . renaming($2)/eg;
-        $content->{'format'} = $format;
-    }
-    $attr->set_content($content);
-}
-
-# add default status schema
-use RT::Model::Attribute;
-my $attribute = RT::Model::Attribute->new( current_user => RT->system_user );
-my @results = $attribute->create(
-    name        => 'StatusSchemas',
-    object      => RT->system,
-    description => 'all system status schemas',
-    content     => {
-        default => {
-            initial     => ['new'],
-            active      => [ 'open', 'stalled' ],
-            inactive    => [ 'resolved', 'rejected', 'deleted' ],
-            transitions => {
-                new      => [qw(open resolved rejected deleted)],
-                open     => [qw(stalled resolved rejected deleted)],
-                stalled  => [qw(open)],
-                resolved => [qw(open)],
-                rejected => [qw(open)],
-                deleted  => [qw(open)],
-            },
-            actions => {
-                'new -> open'     => [ 'Open It', 'respond' ],
-                'new -> resolved' => [ 'Resolve', 'comment' ],
-                'new -> rejected' => [ 'Reject',  'respond' ],
-                'new -> deleted'  => [ 'Delete',  '' ],
-
-                'open -> stalled'  => [ 'Stall',   'comment' ],
-                'open -> resolved' => [ 'Resolve', 'comment' ],
-                'open -> rejected' => [ 'Reject',  'respond' ],
-                'open -> deleted'  => [ 'Delete',  'hide' ],
-
-                'stalled -> open'  => [ 'Open It',  '' ],
-                'resolved -> open' => [ 'Re-open',  'comment' ],
-                'rejected -> open' => [ 'Re-open',  'comment' ],
-                'deleted -> open'  => [ 'Undelete', '' ],
-            },
+sub update_all_tables {
+    foreach my $table ( @tables ) {
+        my $function = join '_', 'update', $table, 'table';
+        next unless defined &$function;
+
+        print "updating table $table\n";
+        no strict 'refs';
+        (&$function)->();
+        print "updated table $table\n";
+    }
+}
+
+sub post_update_all_tables {
+    foreach my $table ( @tables ) {
+        my $function = join '_', 'post', 'update', $table, 'table';
+        next unless defined &$function;
+
+        print "updating table $table\n";
+        no strict 'refs';
+        (&$function)->();
+        print "updated table $table\n";
+    }
+}
+
+sub drop_columns_in_all_tables {
+    while ( my ($table, $columns) = each %drop_columns ) {
+        print "dropping columns in table $table\n";
+        drop_columns( $table, @$columns );
+        print "dropped columns in table $table\n";
+    }
+}
+
+sub rename_columns_in_all_tables {
+    foreach my $table ( @tables ) {
+        my %map;
+        foreach my $column ( @{ $columns{ $table } } ) {
+            next if $drop_columns{$table} && grep $_ eq $column, @{$drop_columns{$table}};
+
+            my $new = renaming( $column );
+            $new = $special_renaming{ $new } || $new;
+            next if lc $new eq lc $column;
+
+            $map{ $column } = $new;
         }
+        next unless keys %map;
+        print "renaming columns in table $table\n";
+        rename_columns( $table, %map );
+        print "renamed columns in table $table\n";
     }
-);
+}
 
-print "updated attributes with success\n";
+sub update_acl_table {
+# delete delegated rights
+    execute_query("DELETE FROM ACL WHERE DelegatedBy != 0 AND DelegatedBy IS NOT NULL");
+# replace PrincipalType with NULLs where it's not a role
+    execute_query("UPDATE TABLE ACL SET PrincipalType = NULL WHERE PrincipalType IN ('User', 'Group')");
+}
+
+sub update_groups_table {
+# delete personal groups, everything else can be covered by validator
+    execute("DELETE FROM Groups WHERE Domain = 'Personal'");
+}
 
+sub rename_columns {
+    my ($table, %map) = (@_);
 
-print "updating table Users\n";
-use RT::Model::UserCollection;
-my $user_collection =
-  RT::Model::UserCollection->new( current_user => RT->system_user );
-
-while ( my $user = $user_collection->next ) {
-    my $name = $user->name;
-    $user->__set( column => 'email_confirmed', value => 1 )
-      unless $name eq 'RT_System';
+    my $handle = Jifty->handle;
+    while ( my ($from, $to) = each %map ) {
+        $handle->rename_column(
+            table  => $table,
+            column => $from,
+            to     => $to,
+        );
+    }
 }
-print "updated table Users with success\n";
-print "migrated with success!\n"
 
+sub drop_columns {
+    my ($table, @columns) = @_;
+    my $query = "ALTER TABLE $table ". join ', ', map "DROP COLUMN $_", @columns;
+    return execute_query( $query );
+}
+
+sub execute_query {
+    my ($query, @binds) = @_;
+
+    print "Executing query: $query\n\n";
+
+    my $sth = $dbh->prepare( $query ) or die "couldn't prepare $query\n\tError: ". $dbh->errstr;
+    $sth->execute( @binds ) or die "couldn't execute $query\n\tError: ". $sth->errstr;
+    return $sth;
+}
+
+=head1 NAME
+
+rt-migrate-db-from-3.8
+
+=head1 SYNOPSIS
+
+    rt-migrate-db-from-3.8 --help
+    rt-migrate-db-from-3.8 --upgrade
+
+=head1 DESCRIPTION
+
+before run, please backup your dbs
+and we need to set up a basic rt4 db with the cmd:
+$ jifty schema --setup --no-bootstrap
+
+then run: ./sbin/migrate-db-from-rt3
+
+options: 
+
+help: print this usage
+db-name-rt3: db name of rt3, default is 'rt3'
+
+=cut

Modified: rt/3.999/branches/config-in-db/share/html/Admin/Tools/Shredder/Elements/Error/NoStorage
==============================================================================
--- rt/3.999/branches/config-in-db/share/html/Admin/Tools/Shredder/Elements/Error/NoStorage	(original)
+++ rt/3.999/branches/config-in-db/share/html/Admin/Tools/Shredder/Elements/Error/NoStorage	Tue Apr 21 21:16:56 2009
@@ -55,5 +55,6 @@
 	title => 'Error',
 &>
 <div class="error">
-<% _('Shredder needs a directory to write dumps to. Please check that you have <span class="file-path">%1</span> and it is writable by your web server.', $path ) %>
+<% _('Shredder needs a directory to write dumps to. Please check that the following directory exists and is writable by your web server.') %>
+<span class="file-path"><% $path %></span>
 </div>

Modified: rt/3.999/branches/config-in-db/share/html/Prefs/Other.html
==============================================================================

Modified: rt/3.999/branches/config-in-db/share/html/Widgets/FinalizeWidgetArguments
==============================================================================
--- rt/3.999/branches/config-in-db/share/html/Widgets/FinalizeWidgetArguments	(original)
+++ rt/3.999/branches/config-in-db/share/html/Widgets/FinalizeWidgetArguments	Tue Apr 21 21:16:56 2009
@@ -48,12 +48,14 @@
 <%init>
     my %args = %$widget_arguments;
 
-    %args = (%args, %{ $args{Callback}->() }) if $args{Callback};
+    %args = (%args, %{ $args{callback}->() }) if $args{callback};
+
     $args{'description'} = _( $args{'description'} ) if $args{'description'};
     $args{'hints'} = _( $args{'hints'} ) if $args{'hints'};
-    if ( $args{'ValuesLabel'} ) {
-        while (my ($k, $v) = each %{ $args{'ValuesLabel'} } ) {
-            $args{'ValuesLabel'}->{$k} = _( $args{'ValuesLabel'}->{$k} );
+
+    if ( $args{'values_label'} ) {
+        while (my ($k, $v) = each %{ $args{'values_label'} } ) {
+            $args{'values_label'}->{$k} = _( $args{'values_label'}->{$k} );
         }
     }
     return \%args;

Copied: rt/3.999/branches/config-in-db/share/web/static/css/app.css (from r18766, /rt/3.999/branches/config-in-db/share/web/static/css/main.css)
==============================================================================
--- /rt/3.999/branches/config-in-db/share/web/static/css/main.css	(original)
+++ rt/3.999/branches/config-in-db/share/web/static/css/app.css	Tue Apr 21 21:16:56 2009
@@ -1,10 +1,8 @@
 @import "yui-fonts.css";
- at import "base.css";
 
 @import "layout.css";
- at import "nav.css";
- at import "forms.css";
 @import "boxes.css";
+ at import "rt-forms.css";
 
 @import "login.css";
 @import "ticket-lists.css";

Copied: rt/3.999/branches/config-in-db/share/web/static/css/rt-forms.css (from r18766, /rt/3.999/branches/config-in-db/share/web/static/css/forms.css)
==============================================================================
--- /rt/3.999/branches/config-in-db/share/web/static/css/forms.css	(original)
+++ rt/3.999/branches/config-in-db/share/web/static/css/rt-forms.css	Tue Apr 21 21:16:56 2009
@@ -183,3 +183,6 @@
     width: 7em;
 }
 
+.value a {
+    font-weight: bold;
+}


More information about the Rt-commit mailing list