[Rt-commit] rt branch, 4.2/rest-search-refactor, repushed

? sunnavy sunnavy at bestpractical.com
Fri Nov 15 20:52:37 EST 2013


The branch 4.2/rest-search-refactor was deleted and repushed:
       was 1fa9c23dfb9386dab689c8443de621b1e6de778d
       now 36a73378ddfc61d8d6b9600eff3a266f179f30a9

 1:  7404f3a =  1:  7404f3a prepare to support restful searches for queues, users and groups
 2:  af00e71 =  2:  af00e71 restful search support for queues/users/groups
 3:  1d15587 =  3:  1d15587 merge restful ticket search to dhandler to avoid replicated code
 4:  3489bde =  4:  3489bde clean some replicated code
 5:  a3310a6 =  5:  a3310a6 shouldn't allow user to search password field
 6:  debbccd =  6:  debbccd allow restful user search only if current user has AdminUsers right
 7:  c06ae90 =  7:  c06ae90 search user defined groups only
 8:  ed96938 =  8:  ed96938 whitelist of restful search fields
 9:  96c6f12 =  9:  96c6f12 allow < and > ops too
10:  ed5a660 = 10:  ed5a660 REST: show Disabled column for queues/groups
11:  f80a254 ! 11:  225c801 REST: handle Disabled column search for queues/groups/users
    @@ -18,15 +18,24 @@
     -                );
     +                if ( $field eq 'Disabled' ) {
     +                    if ($value) {
    -+                        $objects->FindAllRows;
     +                        if ( $type eq 'queue' ) {
    -+                            # special case for queue that
    -+                            # Disabled could be 2(___Approvals)
    ++                            $objects->FindAllRows;
     +                            $objects->Limit(
     +                                FIELD    => $field,
     +                                OPERATOR => uc $op,
     +                                VALUE    => $value
     +                            );
    ++                        }
    ++                        else {
    ++                            $objects->LimitToDeleted;
    ++                        }
    ++                    }
    ++                    else {
    ++                        if ( $type eq 'queue' ) {
    ++                            $objects->UnLimit;
    ++                        }
    ++                        else {
    ++                            $objects->LimitToEnabled;
     +                        }
     +                    }
     +                }
    @@ -42,6 +51,14 @@
                  else {
                      $output = "Invalid query specification: $query";
     @@
    +     }
    + 
    +     while ( my $object = $objects->Next ) {
    ++        next if $type eq 'user' && ( $object->id == RT->SystemUser->id || $object->id == RT->Nobody->id );
    +         $n++;
    + 
    +         my $id = $object->Id;
    +@@
                keys %{ $RT::Record::_TABLE_ATTR->{'RT::Queue'} }
          },
          user => {
12:  1fa9c23 ! 12:  36a7337 tests for restful search of queue/group/user
    @@ -17,6 +17,10 @@
     +my $group_bar = RT::Group->new($RT::SystemUser);
     +$group_bar->CreateUserDefinedGroup( Name => 'bar' );
     +
    ++my $group_baz = RT::Group->new($RT::SystemUser);
    ++$group_baz->CreateUserDefinedGroup( Name => 'baz' );
    ++$group_baz->SetDisabled(1);
    ++
     +my ( $baseurl, $m ) = RT::Test->started_ok;
     +
     +ok( $m->login, 'logged in' );
    @@ -71,6 +75,18 @@
     +    { query => '', orderby => '-name' },
     +    [ $group_foo->id . ': foo', $group_bar->id . ': bar' ],
     +    'order by -name'
    ++);
    ++
    ++search_groups_ok(
    ++    { query => 'Disabled = 0', orderby => 'id' },
    ++    [ $group_foo->id . ': foo', $group_bar->id . ': bar' ],
    ++    'enabled groups'
    ++);
    ++
    ++search_groups_ok(
    ++    { query => 'Disabled = 1', orderby => 'id' },
    ++    [ $group_baz->id . ': baz' ],
    ++    'disabled groups'
     +);
     +
     +sub search_groups_ok {
    @@ -105,6 +121,8 @@
     +
     +my $queue_foo = RT::Test->load_or_create_queue( Name => 'foo' );
     +my $queue_bar = RT::Test->load_or_create_queue( Name => 'bar' );
    ++my $queue_baz = RT::Test->load_or_create_queue( Name => 'baz' );
    ++$queue_baz->SetDisabled(1);
     +
     +my ( $baseurl, $m ) = RT::Test->started_ok;
     +
    @@ -161,6 +179,24 @@
     +    { query => '', orderby => '-name' },
     +    [ '1: General', $queue_foo->id . ': foo', $queue_bar->id . ': bar', ],
     +    'order by -name'
    ++);
    ++
    ++search_queues_ok(
    ++    { query => 'Disabled = 0', orderby => 'id' },
    ++    [ '1: General', $queue_foo->id . ': foo', $queue_bar->id . ': bar', ],
    ++    'enabled queues'
    ++);
    ++
    ++search_queues_ok(
    ++    { query => 'Disabled = 1', orderby => 'id' },
    ++    [ $queue_baz->id . ': baz', ],
    ++    'disabled queues'
    ++);
    ++
    ++search_queues_ok(
    ++    { query => 'Disabled = 2', orderby => 'id' },
    ++    [ '2: ___Approvals', ],
    ++    'special Approvals queue'
     +);
     +
     +sub search_queues_ok {
    @@ -199,6 +235,8 @@
     +    Password => 'password',
     +);
     +my $user_bar = RT::Test->load_or_create_user( Name => 'bar' );
    ++my $user_baz = RT::Test->load_or_create_user( Name => 'baz' );
    ++$user_baz->SetDisabled(1);
     +
     +my ( $baseurl, $m ) = RT::Test->started_ok;
     +
    @@ -263,6 +301,18 @@
     +    'order by -name'
     +);
     +
    ++search_users_ok(
    ++    { query => 'Disabled = 0', orderby => 'id' },
    ++    [ $root->id . ': root', $user_foo->id . ': foo', $user_bar->id . ': bar', ],
    ++    'enabled users'
    ++);
    ++
    ++search_users_ok(
    ++    { query => 'Disabled = 1', orderby => 'id' },
    ++    [ $user_baz->id . ': baz', ],
    ++    'disabled users'
    ++);
    ++
     +ok( $m->login( 'foo', 'password', logout => 1 ), 'logged in as foo' );
     +search_users_ok(
     +    { query => 'id = ' . $user_foo->id },



More information about the rt-commit mailing list