[Rt-commit] rt branch, 3.8-trunk, updated. rt-3.8.7-251-ge337176

Ruslan Zakirov ruz at bestpractical.com
Wed Mar 17 19:48:58 EDT 2010


The branch, 3.8-trunk has been updated
       via  e3371764b9c4ea60d2adcdc6b057d4106c2ac072 (commit)
       via  286b714a063c6ccd554a9fd2f261bdf868e2d8c9 (commit)
       via  adba202b584879391046b5d79da7147efc0e3760 (commit)
       via  39210a04743a1826b88e513a26912084b224c798 (commit)
       via  769ba69fd7b34c8e42ba710ea1ced7b4a8f3bdf3 (commit)
       via  22466fdcf884406564ccd8987358628b0bae94f3 (commit)
       via  f176f4ff5eb4ee1ec41f956a29566d79a8848794 (commit)
       via  bf0002a3aa6ee6691280bf603ff7bb1628d7d03e (commit)
       via  3420559433dc3e2b610c257ad94a6084fb0dcc7d (commit)
       via  9bed33fe428eb6946a3cc3af17b40c63eabe6175 (commit)
       via  c36dfb67061ed7d1e056b18428da8347a73da9e0 (commit)
       via  b6b85d8e0ea1d975974ac32dd3dc446a136b4ccd (commit)
       via  ed42b4a9ba0562c051b13e76cbf498f54061575b (commit)
       via  c3be37cc6f281d294f423ca2c6bcab2039ac4cbd (commit)
       via  78d66a7404f645a960c02483645ffc5451ee889c (commit)
       via  056a0468baf500df6aec26303a4d8b60bfd62dd2 (commit)
       via  80295ad5258cce7ed6c0d7f036091d627d783827 (commit)
       via  2d43d74931150b7ede6b84fdfdb1087515aa4322 (commit)
       via  c367a2fb7285d8388adc188b1fa70bcb9b1eabc7 (commit)
       via  0ea2012828971c6ae4dab0d96f66bad1b44c5b3e (commit)
       via  f375754156410edfa5fa2b29e5d7e1519efe2dab (commit)
       via  08533c90f683a601a1da22ab808e1c05c3237c18 (commit)
       via  ff4e8895d7ca573d33f0fbf362601d00a90f8988 (commit)
       via  2eaeeef02f3dbd1b276134c14c42c5372331f148 (commit)
       via  021df5a91e0a6c142362626514b420fafe6816da (commit)
       via  079b7e0f86b00f2a5d16df00b81497af0dc090d5 (commit)
       via  328d2bc53ccf88aab68ecabe871abe55d07426fe (commit)
       via  badaf96195e2a8b707901d3763d6714cd9f70958 (commit)
       via  21a0afb8eca5dcdff120ca555c89fe0a7b4359ad (commit)
       via  e5e4fd5949c2fce02c7f6d88fd7275e1b48cdafc (commit)
       via  bcb0e0e513facad0a0f67e6009b67b3d6fdfd3b2 (commit)
       via  f0728b438deca261773163bfcd1dd18fdd241351 (commit)
       via  14385ac042a7a21495adcc7fa7b2d64117dafe1a (commit)
       via  13f0044c7e55a5705d3d741b547181a421fc4a2b (commit)
       via  d73690c727f644203d4928370b68bda0ede22c98 (commit)
       via  4727407270d8a3cec1b2411032b26b2df139a1b0 (commit)
       via  268186cfce2dd4801ba16e2032d9f030d79f21c1 (commit)
       via  4040272696bbd568a1f34c4762efb3f34323886a (commit)
       via  c5f14ffaba354a3b63a8449f9d6e64cc73b70bfc (commit)
       via  d6ae7cd6026682acd5c3afb825a1834988f49db5 (commit)
       via  cbf4d082c62406d71b19d40c83a3c7daae5f3dcf (commit)
       via  e960f754d1219566fef994edb5b2e9906f9566e1 (commit)
       via  04dd230d3080f24bcca29335086087a072ad4a03 (commit)
       via  e4943b14c017d7d3a6fe1a36928acb0f8421622b (commit)
       via  5a15272d5f1923b85a01e84ab5c6c340f3af6c2a (commit)
       via  15d142ca6a3470875e0b3e412b8d80defdccef28 (commit)
       via  1d792f78cc96d33edd3b698fc7a500db3a4291f8 (commit)
       via  63aec6a6cc614dcd20b6f4f29593da15f511b1b5 (commit)
       via  364103ccdbb99e74b89549fbb9cf3fcb96679706 (commit)
       via  9def8e5d0c9cf511f752822ee5f7abc533bd2b0e (commit)
      from  67e4aab95fc9b56f04b1897980a3edb218764ab9 (commit)

Summary of changes:
 etc/RT_Config.pm.in                                |   40 +++
 etc/upgrade/3.8.8/content                          |   38 +++
 lib/RT/CustomField_Overlay.pm                      |  207 ++++++++++++---
 lib/RT/CustomFields_Overlay.pm                     |  290 +++++++++++++-------
 lib/RT/Groups_Overlay.pm                           |   27 +-
 lib/RT/ObjectCustomField_Overlay.pm                |  142 ++++++++++
 lib/RT/Queue_Overlay.pm                            |    2 +
 lib/RT/Queues_Overlay.pm                           |   25 +--
 lib/RT/Record.pm                                   |    1 +
 lib/RT/SearchBuilder.pm                            |   62 +++--
 lib/RT/Shredder/Plugin/Users.pm                    |   10 +-
 lib/RT/Users_Overlay.pm                            |   52 ++--
 share/html/Admin/CustomFields/Objects.html         |  152 ++++++-----
 share/html/Admin/CustomFields/index.html           |   58 ++--
 share/html/Admin/Elements/EditCustomFields         |  213 ++++++--------
 share/html/Admin/Elements/EditScrips               |    5 +-
 share/html/Admin/Elements/EditTemplates            |    5 +-
 share/html/Admin/Groups/index.html                 |    5 +-
 share/html/Admin/Queues/index.html                 |    6 +-
 share/html/Admin/Users/Memberships.html            |    4 +-
 share/html/Admin/Users/index.html                  |    6 +-
 share/html/Elements/CollectionList                 |    2 +-
 share/html/Elements/ColumnMap                      |    2 +
 .../html/Elements/{ => RT__CustomField}/ColumnMap  |  167 ++++++------
 share/html/Elements/RT__Queue/ColumnMap            |   54 ++---
 share/html/Elements/RT__Scrip/ColumnMap            |    4 +
 share/html/Elements/RT__Template/ColumnMap         |   11 +
 t/customfields/sort_order.t                        |    6 +-
 t/web/cf_access.t                                  |   12 +-
 t/web/cf_onqueue.t                                 |   11 +-
 t/web/cf_select_one.t                              |    4 +-
 31 files changed, 1019 insertions(+), 604 deletions(-)
 create mode 100644 etc/upgrade/3.8.8/content
 copy share/html/Elements/{ => RT__CustomField}/ColumnMap (51%)

- Log -----------------------------------------------------------------
commit 22466fdcf884406564ccd8987358628b0bae94f3
Merge: 67e4aab f176f4f
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Mar 16 21:26:52 2010 +0300

    Merge branch 'admin_collections_formats' into 3.8-trunk


commit 769ba69fd7b34c8e42ba710ea1ced7b4a8f3bdf3
Merge: 22466fd 5a15272
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Mar 16 21:27:13 2010 +0300

    Merge branch 'find_disabled_rows' into 3.8-trunk


commit 39210a04743a1826b88e513a26912084b224c798
Merge: 769ba69 bf0002a
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Mar 16 22:28:25 2010 +0300

    Merge branch 'custom_fields_application' into 3.8-trunk
    
    Conflicts:
    	etc/RT_Config.pm.in
    	lib/RT/CustomFields_Overlay.pm

diff --cc lib/RT/CustomFields_Overlay.pm
index 4f3b280,7e802f3..a672b3c
--- a/lib/RT/CustomFields_Overlay.pm
+++ b/lib/RT/CustomFields_Overlay.pm
@@@ -69,30 -70,114 +70,124 @@@ use warnings
  no warnings qw(redefine);
  use DBIx::SearchBuilder::Unique;
  
 +sub _Init {
 +    my $self = shift;
 +    $self->{'table'} = 'CustomFields';
 +    $self->{'primary_key'} = 'id';
 +    $self->{'with_disabled_column'} = 1;
 +
 +    return $self->SUPER::_Init(@_);
 +}
 +
- sub _OCFAlias {
++
+ =head2 LimitToLookupType
+ 
+ Takes LookupType and limits collection.
+ 
+ =cut
+ 
+ sub LimitToLookupType  {
      my $self = shift;
-     unless ($self->{_sql_ocfalias}) {
+     my $lookup = shift;
+ 
+     $self->Limit( FIELD => 'LookupType', VALUE => "$lookup" );
+ }
+ 
+ =head2 LimitToChildType
+ 
+ Takes partial LookupType and limits collection to records
+ where LookupType is equal or ends with the value.
+ 
+ =cut
+ 
+ sub LimitToChildType  {
+     my $self = shift;
+     my $lookup = shift;
+ 
+     $self->Limit( FIELD => 'LookupType', VALUE => "$lookup" );
+     $self->Limit( FIELD => 'LookupType', ENDSWITH => "$lookup" );
+ }
+ 
+ 
+ =head2 LimitToParentType
+ 
+ Takes partial LookupType and limits collection to records
+ where LookupType is equal or starts with the value.
+ 
+ =cut
+ 
+ sub LimitToParentType  {
+     my $self = shift;
+     my $lookup = shift;
+ 
+     $self->Limit( FIELD => 'LookupType', VALUE => "$lookup" );
+     $self->Limit( FIELD => 'LookupType', STARTSWITH => "$lookup" );
+ }
+ 
+ 
+ =head2 LimitToGlobalOrObjectId
+ 
+ Takes list of object IDs and limits collection to custom
+ fields that are applied to these objects or globally.
+ 
+ =cut
  
-         $self->{'_sql_ocfalias'} = $self->NewAlias('ObjectCustomFields');
-     $self->Join( ALIAS1 => 'main',
-                 FIELD1 => 'id',
-                 ALIAS2 => $self->_OCFAlias,
-                 FIELD2 => 'CustomField' );
+ sub LimitToGlobalOrObjectId {
+     my $self = shift;
+     my $global_only = 1;
+ 
+ 
+     foreach my $id (@_) {
+ 	$self->Limit( ALIAS           => $self->_OCFAlias,
+ 		    FIELD           => 'ObjectId',
+ 		    OPERATOR        => '=',
+ 		    VALUE           => $id || 0,
+ 		    ENTRYAGGREGATOR => 'OR' );
+ 	$global_only = 0 if $id;
      }
-     return($self->{_sql_ocfalias});
+ 
+     $self->Limit( ALIAS           => $self->_OCFAlias,
+                  FIELD           => 'ObjectId',
+                  OPERATOR        => '=',
+                  VALUE           => 0,
+                  ENTRYAGGREGATOR => 'OR' ) unless $global_only;
  }
  
+ =head2 LimitToNotApplied
+ 
+ Takes either list of object ids or nothing. Limits collection
+ to custom fields to listed objects or any corespondingly. Use
+ zero to mean global.
+ 
+ =cut
  
- # {{{ sub LimitToGlobalOrQueue 
+ sub LimitToNotApplied {
+     my $self = shift;
+     my @ids = @_;
+ 
+     my $ocfs_alias = $self->_OCFAlias( New => 1, Left => 1 );
+     if ( @ids ) {
+         # XXX: we need different EA in join clause, but DBIx::SB
+         # doesn't support them, use IN (X) instead
+         my $dbh = $self->_Handle->dbh;
+         $self->Limit(
+             LEFTJOIN   => $ocfs_alias,
+             ALIAS      => $ocfs_alias,
+             FIELD      => 'ObjectId',
+             OPERATOR   => 'IN',
+             QUOTEVALUE => 0,
+             VALUE      => "(". join( ',', map $dbh->quote($_), @ids ) .")",
+         );
+     }
+ 
+     $self->Limit(
+         ENTRYAGGREGATOR => 'AND',
+         ALIAS    => $ocfs_alias,
+         FIELD    => 'id',
+         OPERATOR => 'IS',
+         VALUE    => 'NULL',
+     );
+ }
  
  =head2 LimitToGlobalOrQueue QUEUEID
  
@@@ -185,67 -271,87 +281,67 @@@ sub ContextObject 
      return $self->{'context_object'};
  }
  
- sub NewItem {
-     my $self = shift;
-     my $res = RT::CustomField->new($self->CurrentUser);
-     $res->SetContextObject($self->ContextObject);
-     return $res;
- }
  
- # }}}
+ =head2 SetContextObject
  
- sub LimitToLookupType  {
-     my $self = shift;
-     my $lookup = shift;
-  
-     $self->Limit( FIELD => 'LookupType', VALUE => "$lookup" );
- }
+ Sets context object for this collection of custom fields.
  
- sub LimitToChildType  {
+ =cut
+ 
+ sub SetContextObject {
      my $self = shift;
-     my $lookup = shift;
-  
-     $self->Limit( FIELD => 'LookupType', VALUE => "$lookup" );
-     $self->Limit( FIELD => 'LookupType', ENDSWITH => "$lookup" );
+     return $self->{'context_object'} = shift;
  }
  
- sub LimitToParentType  {
+ 
+ sub _OCFAlias {
      my $self = shift;
-     my $lookup = shift;
-  
-     $self->Limit( FIELD => 'LookupType', VALUE => "$lookup" );
-     $self->Limit( FIELD => 'LookupType', STARTSWITH => "$lookup" );
+     my %args = ( New => 0, Left => 0, @_ );
+ 
+     return $self->{'_sql_ocfalias'} if $self->{'_sql_ocfalias'} && !$args{'New'};
+ 
+     my $alias = $self->Join(
+         $args{'Left'} ? (TYPE => 'LEFT') : (),
+         ALIAS1 => 'main',
+         FIELD1 => 'id',
+         TABLE2 => 'ObjectCustomFields',
+         FIELD2 => 'CustomField'
+     );
+     return $alias if $args{'New'};
+     return $self->{'_sql_ocfalias'} = $alias;
  }
  
- sub LimitToGlobalOrObjectId {
+ 
+ =head2 Next
+ 
+ Returns the next custom field that this user can see.
+ 
+ =cut
+ 
+ sub Next {
      my $self = shift;
-     my $global_only = 1;
  
+     my $CF = $self->SUPER::Next();
+     return $CF unless $CF;
  
-     foreach my $id (@_) {
- 	$self->Limit( ALIAS           => $self->_OCFAlias,
- 		    FIELD           => 'ObjectId',
- 		    OPERATOR        => '=',
- 		    VALUE           => $id || 0,
- 		    ENTRYAGGREGATOR => 'OR' );
- 	$global_only = 0 if $id;
-     }
+     $CF->SetContextOject( $self->ContextObject );
  
-     $self->Limit( ALIAS           => $self->_OCFAlias,
-                  FIELD           => 'ObjectId',
-                  OPERATOR        => '=',
-                  VALUE           => 0,
-                  ENTRYAGGREGATOR => 'OR' ) unless $global_only;
+     return $self->Next unless $CF->CurrentUserHasRight('SeeCustomField');
+     return $CF;
+ }
  
-     $self->OrderByCols(
- 	{ ALIAS => $self->_OCFAlias, FIELD => 'ObjectId', ORDER => 'DESC' },
- 	{ ALIAS => $self->_OCFAlias, FIELD => 'SortOrder' },
-     );
-     
-     # This doesn't work on postgres. 
-     #$self->OrderBy( ALIAS => $class_cfs , FIELD => "SortOrder", ORDER => 'ASC');
+ =head2 Next
+ 
+ Overrides <RT::SearchBuilder/Next> to make sure </ContextObject>
+ is inherited.
  
+ =cut
+ 
+ sub NewItem {
+     my $self = shift;
+     my $res = RT::CustomField->new($self->CurrentUser);
+     $res->SetContextObject($self->ContextObject);
+     return $res;
  }
  
 -=head2 _DoSearch
 -
 -A subclass of DBIx::SearchBuilder::_DoSearch that makes sure that
 - _Disabled rows never get seen unless we're explicitly trying to see
 -them.
 -
 -=cut
 -
 -sub _DoSearch {
 -    my $self = shift;
 -
 -    # unless we really want to find disabled rows,
 -    # make sure we're only finding enabled ones.
 -    unless($self->{'find_disabled_rows'}) {
 -        $self->LimitToEnabled();
 -    }
 -
 -    return($self->SUPER::_DoSearch(@_));
 -}
 -
  1;
- 
diff --cc share/html/Admin/CustomFields/index.html
index 1164a6b,513caa3..16fb593
--- a/share/html/Admin/CustomFields/index.html
+++ b/share/html/Admin/CustomFields/index.html
@@@ -102,7 -104,9 +104,9 @@@ if ( !$Type && $ARGS{'type'} ) 
  
  my $CustomFields = RT::CustomFields->new($session{'CurrentUser'});
  $CustomFields->UnLimit;
 -$CustomFields->{'find_disabled_rows'} = 1 if $ShowDisabled;
 +$CustomFields->FindAllRows if $ShowDisabled;
  $CustomFields->LimitToLookupType( $Type ) if $Type;
- $CustomFields->OrderByCols( { FIELD => 'LookupType' }, { FIELD => 'Name' } );
+ 
+ $Format ||= RT->Config->Get('AdminSearchResultFormat')->{'CustomFields'};
+ 
  </%INIT>

commit adba202b584879391046b5d79da7147efc0e3760
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Mar 18 00:47:43 2010 +0300

    apply sort order in RT::Queue->XxxCustomFields

diff --git a/lib/RT/Queue_Overlay.pm b/lib/RT/Queue_Overlay.pm
index a839679..00d684c 100755
--- a/lib/RT/Queue_Overlay.pm
+++ b/lib/RT/Queue_Overlay.pm
@@ -636,6 +636,7 @@ sub TicketCustomFields {
         $cfs->SetContextObject( $self );
 	$cfs->LimitToGlobalOrObjectId( $self->Id );
 	$cfs->LimitToLookupType( 'RT::Queue-RT::Ticket' );
+        $cfs->ApplySortOrder;
     }
     return ($cfs);
 }
@@ -658,6 +659,7 @@ sub TicketTransactionCustomFields {
     if ( $self->CurrentUserHasRight('SeeQueue') ) {
 	$cfs->LimitToGlobalOrObjectId( $self->Id );
 	$cfs->LimitToLookupType( 'RT::Queue-RT::Ticket-RT::Transaction' );
+        $cfs->ApplySortOrder;
     }
     return ($cfs);
 }

commit 286b714a063c6ccd554a9fd2f261bdf868e2d8c9
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Mar 18 00:48:11 2010 +0300

    fix tests according to new reality, nothing terrible

diff --git a/t/customfields/sort_order.t b/t/customfields/sort_order.t
index 472eb6b..c5c808c 100644
--- a/t/customfields/sort_order.t
+++ b/t/customfields/sort_order.t
@@ -56,9 +56,9 @@ diag "reorder CFs: C, A and B" if $ENV{TEST_VERBOSE};
     my @tmp = ($m->content =~ /(CF [ABC])/g);
     is_deeply(\@tmp, ['CF B', 'CF A', 'CF C']);
 
-    $m->follow_link_ok( {text => 'Move up', n => 2} );
-    $m->follow_link_ok( {text => 'Move up', n => 1} );
-    $m->follow_link_ok( {text => 'Move up', n => 2} );
+    $m->follow_link_ok( {text => '[Up]', n => 3} );
+    $m->follow_link_ok( {text => '[Up]', n => 2} );
+    $m->follow_link_ok( {text => '[Up]', n => 3} );
 
     @tmp = ($m->content =~ /(CF [ABC])/g);
     is_deeply(\@tmp, ['CF C', 'CF A', 'CF B']);

commit e3371764b9c4ea60d2adcdc6b057d4106c2ac072
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Mar 18 02:47:58 2010 +0300

    fix CF tests, new admin UI

diff --git a/t/web/cf_access.t b/t/web/cf_access.t
index 1022c6d..183597b 100644
--- a/t/web/cf_access.t
+++ b/t/web/cf_access.t
@@ -43,16 +43,14 @@ my ( $cf, $cfid, $tid );
     $m->form_name('EditCustomFields');
 
     # Sort by numeric IDs in names
-    my @names = map  { $_->[1] }
-                sort { $a->[0] <=> $b->[0] }
-                map  { /Object-1-CF-(\d+)/ ? [ $1 => $_ ] : () }
-                grep defined, map $_->name, $m->current_form->inputs;
+    my @names = sort grep defined,
+        $m->current_form->find_input('AddCustomField')->possible_values;
     $cf = pop(@names);
     $cf =~ /(\d+)$/ or die "Hey this is impossible dude";
     $cfid = $1;
-    $m->field( $cf => 1 );         # Associate the new CF with this queue
-    $m->field( $_ => undef ) for @names;    # ...and not any other. ;-)
-    $m->submit;
+    $m->tick( AddCustomField => $cf => 1 ); # Associate the new CF with this queue
+    $m->tick( AddCustomField => $_  => 0 ) for @names; # ...and not any other. ;-)
+    $m->click('UpdateCFs');
 
     $m->content_like( qr/Object created/, 'TCF added to the queue' );
 }
diff --git a/t/web/cf_onqueue.t b/t/web/cf_onqueue.t
index dcd5852..bed4dd1 100644
--- a/t/web/cf_onqueue.t
+++ b/t/web/cf_onqueue.t
@@ -34,12 +34,11 @@ diag "Apply the new CF globally" if $ENV{'TEST_VERBOSE'};
     $m->follow_link( url => 'Queues.html' );
     $m->title_is(q/Edit Custom Fields for all queues/, 'global custom field for all queues configuration screen');
     $m->content_like( qr/QueueCFTest/, 'CF QueueCFTest displayed on page' );
-    $m->submit_form(
-        form_name => "EditCustomFields",
-        fields => {
-            'Object--CF-1' => '1',
-        },
-    );
+
+    $m->form_name('EditCustomFields');
+    $m->tick( AddCustomField => 1 );
+    $m->click('UpdateCFs');
+
     $m->content_like( qr/Object created/, 'CF QueueCFTest enabled globally' );
 }
 
diff --git a/t/web/cf_select_one.t b/t/web/cf_select_one.t
index e009af7..39a8080 100644
--- a/t/web/cf_select_one.t
+++ b/t/web/cf_select_one.t
@@ -58,8 +58,8 @@ diag "apply the CF to General queue" if $ENV{'TEST_VERBOSE'};
     $m->title_is(q/Edit Custom Fields for General/, 'admin-queue: general cfid');
 
     $m->form_name('EditCustomFields');
-    $m->field( "Object-". $queue->id ."-CF-$cfid" => 1 );
-    $m->submit;
+    $m->tick( "AddCustomField" => $cfid );
+    $m->click('UpdateCFs');
 
     $m->content_like( qr/Object created/, 'TCF added to the queue' );
 }

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


More information about the Rt-commit mailing list