Bugzilla – Attachment 31476 Details for
Bug 12833
Patron search no longer searches extended attributes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 12833: Patron search should search on extended attributes
PASSED-QA-Bug-12833-Patron-search-should-search-on.patch (text/plain), 5.70 KB, created by
Katrin Fischer
on 2014-09-08 21:32:12 UTC
(
hide
)
Description:
[PASSED QA] Bug 12833: Patron search should search on extended attributes
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2014-09-08 21:32:12 UTC
Size:
5.70 KB
patch
obsolete
>From d2a391138afe59887f9b1a79a564febedfd657b3 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Thu, 28 Aug 2014 10:51:03 +0200 >Subject: [PATCH] [PASSED QA] Bug 12833: Patron search should search on > extended attributes > >Before Bug 9811, the patron search searched on extended attributes. > >This patch restore this behavior. > >Test plan: >0/ Create a patron attribute PA >1/ Create a patron A (cardnumber CNA) with PA="foo" >2/ Create a patron B (cardnumber CNB) with PA="foo bar" >3/ Search for CNA should redirect on the patron detail page. >4/ Search for "foo" should display the search result with 2 results. > >Signed-off-by: Nick Clemens <nick@quecheelibrary.org> >Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> >'Searchable' patron attributes can now be searched for again. >Works as described, passes stests and QA script. >--- > C4/Utils/DataTables/Members.pm | 9 ++++++ > svc/members/search | 14 ++++++-- > t/db_dependent/Utils/Datatables_Members.t | 53 ++++++++++++++++++++++++++----- > 3 files changed, 66 insertions(+), 10 deletions(-) > >diff --git a/C4/Utils/DataTables/Members.pm b/C4/Utils/DataTables/Members.pm >index aa0f838..95f6a82 100644 >--- a/C4/Utils/DataTables/Members.pm >+++ b/C4/Utils/DataTables/Members.pm >@@ -79,6 +79,15 @@ sub search { > push @where_args, $term; > } > >+ if ( C4::Context->preference('ExtendedPatronAttributes') and $searchmember ) { >+ my $matching_borrowernumbers = C4::Members::Attributes::SearchIdMatchingAttribute($searchmember); >+ >+ for my $borrowernumber ( @$matching_borrowernumbers ) { >+ push @where_strs_or, "borrowers.borrowernumber = ?"; >+ push @where_args, $borrowernumber; >+ } >+ } >+ > push @where_strs, '('. join (' OR ', @where_strs_or) . ')' > if @where_strs_or; > } >diff --git a/svc/members/search b/svc/members/search >index 1b3a02a..e0b64a5 100755 >--- a/svc/members/search >+++ b/svc/members/search >@@ -57,8 +57,18 @@ foreach (grep {$_ =~ /^mDataProp/} keys %dt_params) { > $dt_params{$_} =~ s/^dt_//; > } > >+my $results; >+if ( $searchfieldstype and $searchfieldstype eq 'standard' ) { >+ my $member = C4::Members::GetMember( cardnumber => $searchmember ); >+ $results = { >+ iTotalRecords => 1, >+ iTotalDisplayRecords => 1, >+ patrons => [ $member ], >+ } if $member; >+} >+ > # Perform the patrons search >-my $results = C4::Utils::DataTables::Members::search( >+$results = C4::Utils::DataTables::Members::search( > { > searchmember => $searchmember, > firstletter => $firstletter, >@@ -69,7 +79,7 @@ my $results = C4::Utils::DataTables::Members::search( > dt_params => \%dt_params, > > } >-); >+) unless $results; > > $template->param( > sEcho => $sEcho, >diff --git a/t/db_dependent/Utils/Datatables_Members.t b/t/db_dependent/Utils/Datatables_Members.t >index 1c85423..e0deaae 100644 >--- a/t/db_dependent/Utils/Datatables_Members.t >+++ b/t/db_dependent/Utils/Datatables_Members.t >@@ -17,16 +17,20 @@ > > use Modern::Perl; > >-use Test::More tests => 11; >+use Test::More tests => 13; > > use C4::Context; > use C4::Branch; > use C4::Members; > >+use C4::Members::Attributes; >+use C4::Members::AttributeTypes; >+ >+use t::lib::Mocks; >+ > use_ok( "C4::Utils::DataTables::Members" ); > > my $dbh = C4::Context->dbh; >-my $res; > > # Start transaction > $dbh->{AutoCommit} = 0; >@@ -83,12 +87,12 @@ my %jane_doe = ( > userid => 'jane.doe' > ); > >-$res = AddMember( %john_doe ); >-warn "Error adding John Doe, check your tests" unless $res; >-$res = AddMember( %john_smith ); >-warn "Error adding John Smith, check your tests" unless $res; >-$res = AddMember( %jane_doe ); >-warn "Error adding Jane Doe, check your tests" unless $res; >+$john_doe{borrowernumber} = AddMember( %john_doe ); >+warn "Error adding John Doe, check your tests" unless $john_doe{borrowernumber}; >+$john_smith{borrowernumber} = AddMember( %john_smith ); >+warn "Error adding John Smith, check your tests" unless $john_smith{borrowernumber}; >+$jane_doe{borrowernumber} = AddMember( %jane_doe ); >+warn "Error adding Jane Doe, check your tests" unless $jane_doe{borrowernumber}; > > # Set common datatables params > my %dt_params = ( >@@ -168,6 +172,39 @@ is( $search_results->{ patrons }[1]->{ cardnumber }, > $jane_doe{ cardnumber }, > "Jane Doe is the second result"); > >+my $attribute_type = C4::Members::AttributeTypes->new( 'ATM_1', 'my attribute type' ); >+$attribute_type->{staff_searchable} = 1; >+$attribute_type->store; >+ >+ >+C4::Members::Attributes::SetBorrowerAttributes( >+ $john_doe{borrowernumber}, [ { code => $attribute_type->{code}, value => 'the default value for a common user' } ] >+); >+C4::Members::Attributes::SetBorrowerAttributes( >+ $jane_doe{borrowernumber}, [ { code => $attribute_type->{code}, value => 'the default value for another common user' } ] >+); >+ >+t::lib::Mocks::mock_preference('ExtendedPatronAttributes', 1); >+$search_results = C4::Utils::DataTables::Members::search({ >+ searchmember => "common user", >+ searchfieldstype => 'standard', >+ searchtype => 'contains', >+ branchcode => $branchcode, >+ dt_params => \%dt_params >+}); >+ >+is( $search_results->{ iTotalDisplayRecords}, 2, "There are 2 common users" ); >+ >+t::lib::Mocks::mock_preference('ExtendedPatronAttributes', 0); >+$search_results = C4::Utils::DataTables::Members::search({ >+ searchmember => "common user", >+ searchfieldstype => 'standard', >+ searchtype => 'contains', >+ branchcode => $branchcode, >+ dt_params => \%dt_params >+}); >+is( $search_results->{ iTotalDisplayRecords}, 0, "There are still 2 common users, but the patron attribute is not searchable " ); >+ > $dbh->rollback; > > 1; >-- >1.9.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12833
:
31263
|
31335
| 31476