[Rt-commit] r10680 - in rt/branches/3.999-DANGEROUS: html/Admin/Elements lib/RT t
jesse at bestpractical.com
jesse at bestpractical.com
Sat Feb 2 18:46:40 EST 2008
Author: jesse
Date: Sat Feb 2 18:46:39 2008
New Revision: 10680
Modified:
rt/branches/3.999-DANGEROUS/ (props changed)
rt/branches/3.999-DANGEROUS/html/Admin/Elements/ShowKeyInfo
rt/branches/3.999-DANGEROUS/lib/RT/SavedSearch.pm
rt/branches/3.999-DANGEROUS/t/savedsearch.t
Log:
r76113 at pinglin: jesse | 2008-02-02 18:36:12 -0500
key-info updates
r76114 at pinglin: jesse | 2008-02-02 18:45:35 -0500
t/savedsearch lowercased
Modified: rt/branches/3.999-DANGEROUS/html/Admin/Elements/ShowKeyInfo
==============================================================================
--- rt/branches/3.999-DANGEROUS/html/Admin/Elements/ShowKeyInfo (original)
+++ rt/branches/3.999-DANGEROUS/html/Admin/Elements/ShowKeyInfo Sat Feb 2 18:46:39 2008
@@ -52,20 +52,20 @@
<table>
% unless ( $Type eq 'private' ) {
-<tr><th><% _('Trust') %>:</th> <td><% loc( $res{'info'}{'Trust'} ) %></td></tr>
+<tr><th><% _('Trust') %>:</th> <td><% loc( $res{'info'}{'trust'} ) %></td></tr>
% }
<tr><th><% _('Created') %>:</th>
-<td><% $res{'info'}{'Created'}? $res{'info'}{'Created'}->as_string( Time => 0 ): _('never') %></td></tr>
+<td><% $res{'info'}{'created'}? $res{'info'}{'created'}->as_string( Time => 0 ): _('never') %></td></tr>
<tr><th><% _('Expire') %>:</th>
-<td><% $res{'info'}{'Expire'}? $res{'info'}{'Expire'}->as_string( Time => 0 ): _('never') %></td></tr>
+<td><% $res{'info'}{'expire'}? $res{'info'}{'expire'}->as_string( Time => 0 ): _('never') %></td></tr>
-% foreach my $uinfo( @{ $res{'info'}{'User'} } ) {
+% foreach my $uinfo( @{ $res{'info'}{'user'} } ) {
<tr><th><% _('User (Created - expire)') %>:</th>
-<td><% $uinfo->{'String'} %>\
-(<% $uinfo->{'Created'}? $uinfo->{'Created'}->as_string( Time => 0 ): _('never') %> - \
-<% $uinfo->{'Expire'}? $uinfo->{'Expire'}->as_string( Time => 0 ): _('never') %>)
+<td><% $uinfo->{'string'} %>\
+(<% $uinfo->{'created'}? $uinfo->{'created'}->as_string( Time => 0 ): _('never') %> - \
+<% $uinfo->{'expire'}? $uinfo->{'expire'}->as_string( Time => 0 ): _('never') %>)
</td></tr>
% }
Modified: rt/branches/3.999-DANGEROUS/lib/RT/SavedSearch.pm
==============================================================================
--- rt/branches/3.999-DANGEROUS/lib/RT/SavedSearch.pm (original)
+++ rt/branches/3.999-DANGEROUS/lib/RT/SavedSearch.pm Sat Feb 2 18:46:39 2008
@@ -99,11 +99,11 @@
my $object = $self->_get_object($privacy);
if ($object) {
- $self->{'Attribute'} = $object->attributes->with_id($id);
- if ( $self->{'Attribute'}->id ) {
- $self->{'id'} = $self->{'Attribute'}->id;
- $self->{'Privacy'} = $privacy;
- $self->{'type'} = $self->{'Attribute'}->sub_value('SearchType');
+ $self->{'attribute'} = $object->attributes->with_id($id);
+ if ( $self->{'attribute'}->id ) {
+ $self->{'id'} = $self->{'attribute'}->id;
+ $self->{'privacy'} = $privacy;
+ $self->{'type'} = $self->{'attribute'}->sub_value('SearchType');
return ( 1, _( "Loaded search %1", $self->name ) );
} else {
Jifty->log->error( "Could not load attribute "
@@ -126,26 +126,26 @@
search parameters. Saves the given parameters to the appropriate user/
group object, and loads the resulting search. Returns a tuple of status
and message, where status is true on success. Defaults are:
- Privacy: undef
+ privacy: undef
Type: Ticket
name: "new search"
- SearchParams: (empty hash)
+ search_params: (empty hash)
=cut
sub save {
my $self = shift;
my %args = (
- 'Privacy' => 'RT::Model::User-' . $self->current_user->id,
+ 'privacy' => 'RT::Model::User-' . $self->current_user->id,
'type' => 'Ticket',
'name' => 'new search',
- 'SearchParams' => {},
+ 'search_params' => {},
@_
);
- my $privacy = $args{'Privacy'};
+ my $privacy = $args{'privacy'};
my $type = $args{'type'};
my $name = $args{'name'};
- my %params = %{ $args{'SearchParams'} };
+ my %params = %{ $args{'search_params'} };
$params{'SearchType'} = $type;
my $object = $self->_get_object($privacy);
@@ -167,9 +167,9 @@
'content' => \%params
);
if ($att_id) {
- $self->{'Attribute'} = $object->attributes->with_id($att_id);
+ $self->{'attribute'} = $object->attributes->with_id($att_id);
$self->{'id'} = $att_id;
- $self->{'Privacy'} = $privacy;
+ $self->{'privacy'} = $privacy;
$self->{'type'} = $type;
return ( 1, _( "Saved search %1", $name ) );
} else {
@@ -181,7 +181,7 @@
=head2 Update
Updates the parameters of an existing search. Takes the arguments
-"name" and "SearchParams"; SearchParams should be a hashref containing
+"name" and "search_params"; search_params should be a hashref containing
the new parameters of the search. If name is not specified, the name
will not be changed.
@@ -191,18 +191,18 @@
my $self = shift;
my %args = (
'name' => '',
- 'SearchParams' => {},
+ 'search_params' => {},
@_
);
return ( 0, _("No search loaded") ) unless $self->id;
return ( 0, _("Could not load search attribute") )
- unless $self->{'Attribute'}->id;
+ unless $self->{'attribute'}->id;
my ( $status, $msg )
- = $self->{'Attribute'}->set_sub_values( %{ $args{'SearchParams'} } );
+ = $self->{'attribute'}->set_sub_values( %{ $args{'search_params'} } );
if ( $status && $args{'name'} ) {
( $status, $msg )
- = $self->{'Attribute'}->set_description( $args{'name'} );
+ = $self->{'attribute'}->set_description( $args{'name'} );
}
return ( $status, _( "Search update: %1", $msg ) );
}
@@ -217,7 +217,7 @@
sub delete {
my $self = shift;
- my ( $status, $msg ) = $self->{'Attribute'}->delete;
+ my ( $status, $msg ) = $self->{'attribute'}->delete;
if ($status) {
# we need to do_search to refresh current user's attributes
@@ -238,21 +238,21 @@
sub name {
my $self = shift;
- return unless ref( $self->{'Attribute'} ) eq 'RT::Model::Attribute';
- return $self->{'Attribute'}->description();
+ return unless ref( $self->{'attribute'} ) eq 'RT::Model::Attribute';
+ return $self->{'attribute'}->description();
}
=head2 GetParameter
-Returns the given named parameter of the search, e.g. 'Query', 'format'.
+Returns the given named parameter of the search, e.g. 'query', 'format'.
=cut
sub get_parameter {
my $self = shift;
my $param = shift;
- return unless ref( $self->{'Attribute'} ) eq 'RT::Model::Attribute';
- return $self->{'Attribute'}->sub_value($param);
+ return unless ref( $self->{'attribute'} ) eq 'RT::Model::Attribute';
+ return $self->{'attribute'}->sub_value($param);
}
=head2 id
@@ -266,7 +266,7 @@
return $self->{'id'};
}
-=head2 Privacy
+=head2 privacy
Returns the principal object to whom this search belongs, in a string
"<class>-<id>", e.g. "RT::Model::Group-16".
@@ -275,7 +275,7 @@
sub privacy {
my $self = shift;
- return $self->{'Privacy'};
+ return $self->{'privacy'};
}
=head2 Type
Modified: rt/branches/3.999-DANGEROUS/t/savedsearch.t
==============================================================================
--- rt/branches/3.999-DANGEROUS/t/savedsearch.t (original)
+++ rt/branches/3.999-DANGEROUS/t/savedsearch.t Sat Feb 2 18:46:39 2008
@@ -43,8 +43,8 @@
my $ticket = RT::Model::Ticket->new(current_user => RT->system_user);
$ticket->create(queue => $queue->id,
- Requestor => [ $searchuser->name ],
- Owner => $searchuser,
+ requestor => [ $searchuser->name ],
+ owner => $searchuser,
subject => 'saved search test');
@@ -67,44 +67,44 @@
warn "My search user = ".$searchuser->id;
my $mysearch = RT::SavedSearch->new( current_user => $curruser );
( $ret, $msg ) = $mysearch->save(
- Privacy => 'RT::Model::User-' . $searchuser->id,
+ privacy => 'RT::Model::User-' . $searchuser->id,
type => 'Ticket',
name => 'owned by me',
- SearchParams => {
+ search_params => {
'format' => $format,
- 'Query' => "Owner = '" . $searchuser->name . "'"
+ 'query' => "Owner = '" . $searchuser->name . "'"
}
);
-ok($ret, "mysearch was Created");
+ok($ret, "mysearch was Created - $msg");
my $groupsearch = RT::SavedSearch->new(current_user => $curruser);
-($ret, $msg) = $groupsearch->save(Privacy => 'RT::Model::Group-' . $ingroup->id,
+($ret, $msg) = $groupsearch->save(privacy => 'RT::Model::Group-' . $ingroup->id,
type => 'Ticket',
name => 'search queue',
- SearchParams => {'format' => $format,
- 'Query' => "Queue = '"
+ search_params => {'format' => $format,
+ 'query' => "Queue = '"
. $queue->name . "'"});
ok($ret, "groupsearch was Created");
my $othersearch = RT::SavedSearch->new(current_user => $curruser);
-($ret, $msg) = $othersearch->save(Privacy => 'RT::Model::Group-' . $outgroup->id,
+($ret, $msg) = $othersearch->save(privacy => 'RT::Model::Group-' . $outgroup->id,
type => 'Ticket',
name => 'searchuser requested',
- SearchParams => {'format' => $format,
- 'Query' =>
+ search_params => {'format' => $format,
+ 'query' =>
"Requestor.name LIKE 'search'"});
ok(!$ret, "othersearch NOT Created");
like($msg, qr/Failed to load object for/, "...for the right reason");
$othersearch = RT::SavedSearch->new(current_user => RT->system_user);
-($ret, $msg) = $othersearch->save(Privacy => 'RT::Model::Group-' . $outgroup->id,
+($ret, $msg) = $othersearch->save(privacy => 'RT::Model::Group-' . $outgroup->id,
type => 'Ticket',
name => 'searchuser requested',
- SearchParams => {'format' => $format,
- 'Query' =>
+ search_params => {'format' => $format,
+ 'query' =>
"Requestor.name LIKE 'search'"});
ok($ret, "othersearch Created by systemuser");
@@ -114,17 +114,18 @@
my $loadedsearch1 = RT::SavedSearch->new(current_user => $curruser);
$loadedsearch1->load('RT::Model::User-'.$curruser->id, $mysearch->id);
is($loadedsearch1->id, $mysearch->id, "Loaded mysearch");
-like($loadedsearch1->get_parameter('Query'), qr/Owner/,
+like($loadedsearch1->get_parameter('query'), qr/Owner/,
"Retrieved query of mysearch");
# Check through the other accessor methods.
is($loadedsearch1->privacy, 'RT::Model::User-' . $curruser->id,
- "Privacy of mysearch correct");
+ "privacy of mysearch correct");
is($loadedsearch1->name, 'owned by me', "name of mysearch correct");
is($loadedsearch1->type, 'Ticket', "Type of mysearch correct");
# See if it can be used to search for tickets.
my $tickets = RT::Model::TicketCollection->new(current_user => $curruser);
-$tickets->from_sql($loadedsearch1->get_parameter('Query'));
+$tickets->from_sql($loadedsearch1->get_parameter('query'));
+diag $loadedsearch1->get_parameter('query');
is($tickets->count, 1, "Found a ticket");
# This should fail -- wrong object.
@@ -135,11 +136,11 @@
my $loadedsearch3 = RT::SavedSearch->new(current_user => $curruser);
$loadedsearch3->load('RT::Model::Group-'.$ingroup->id, $groupsearch->id);
is($loadedsearch3->id, $groupsearch->id, "Loaded groupsearch");
-like($loadedsearch3->get_parameter('Query'), qr/Queue/,
+like($loadedsearch3->get_parameter('query'), qr/Queue/,
"Retrieved query of groupsearch");
# Can it get tickets?
$tickets = RT::Model::TicketCollection->new(current_user => $curruser);
-$tickets->from_sql($loadedsearch3->get_parameter('Query'));
+$tickets->from_sql($loadedsearch3->get_parameter('query'));
is($tickets->count, 1, "Found a ticket");
# This should fail -- no permission.
@@ -148,14 +149,14 @@
isnt($loadedsearch4->id, $othersearch->id, "Did not load othersearch");
# Try to update an existing search.
-$loadedsearch1->update( SearchParams => {'format' => $format,
- 'Query' => "Queue = '" . $queue->name . "'" } );
-like($loadedsearch1->get_parameter('Query'), qr/Queue/,
+$loadedsearch1->update( search_params => {'format' => $format,
+ 'query' => "Queue = '" . $queue->name . "'" } );
+like($loadedsearch1->get_parameter('query'), qr/Queue/,
"Updated mysearch parameter");
is($loadedsearch1->type, 'Ticket', "mysearch is still for tickets");
is($loadedsearch1->privacy, 'RT::Model::User-'.$curruser->id,
"mysearch still belongs to searchuser");
-like($mysearch->get_parameter('Query'), qr/Queue/, "other mysearch object updated");
+like($mysearch->get_parameter('query'), qr/Queue/, "other mysearch object updated");
## right ho. Test the pseudo-collection object.
@@ -163,7 +164,7 @@
my $genericsearch = RT::SavedSearch->new(current_user => $curruser);
$genericsearch->save(name => 'generic search',
type => 'all',
- SearchParams => {'Query' => "Queue = 'General'"});
+ search_params => {'query' => "Queue = 'General'"});
my $ticketsearches = RT::SavedSearches->new(current_user => $curruser);
$ticketsearches->limit_to_privacy('RT::Model::User-'.$curruser->id, 'Ticket');
More information about the Rt-commit
mailing list