Bugzilla – Attachment 61711 Details for
Bug 17971
TT syntax for notices - Add support for plurals
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17971: Add support for objects represented by fk
Bug-17971-Add-support-for-objects-represented-by-f.patch (text/plain), 3.03 KB, created by
Nick Clemens (kidclamp)
on 2017-03-29 20:12:38 UTC
(
hide
)
Description:
Bug 17971: Add support for objects represented by fk
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2017-03-29 20:12:38 UTC
Size:
3.03 KB
patch
obsolete
>From 4f126128f066f03be998a9a58102becc8e232e12 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 17 Jan 2017 16:18:54 +0100 >Subject: [PATCH] Bug 17971: Add support for objects represented by fk > >For instance an issue is not fetch from its fk but using the fk >itemnumber. >We need to support them. > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > C4/Letters.pm | 6 ++++-- > t/db_dependent/Letters/TemplateToolkit.t | 16 +++++++++++++++- > 2 files changed, 19 insertions(+), 3 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index 9e3b59c..6715213 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -1557,10 +1557,12 @@ sub _get_tt_params { > my $fk = $config->{$table}->{fk}; > > if ( $is_a_loop ) { >- unless ( ref( $tables->{$table} ) eq 'ARRAY' ) { >+ my $values = $tables->{$table} || []; >+ unless ( ref( $values ) eq 'ARRAY' ) { > croak "ERROR processing table $table. Wrong API call."; > } >- my $objects = $module->search( { $pk => { -in => $tables->{$table} } } ); >+ my $key = $pk ? $pk : $fk; >+ my $objects = $module->search( { $key => { -in => $values } } ); > $params->{ $config->{$table}->{plural} } = $objects; > } > elsif ( $ref eq q{} || $ref eq 'HASH' ) { >diff --git a/t/db_dependent/Letters/TemplateToolkit.t b/t/db_dependent/Letters/TemplateToolkit.t >index 64df56c..d6023c5 100644 >--- a/t/db_dependent/Letters/TemplateToolkit.t >+++ b/t/db_dependent/Letters/TemplateToolkit.t >@@ -327,7 +327,7 @@ subtest 'regression tests' => sub { > }; > > subtest 'loops' => sub { >- plan tests => 1; >+ plan tests => 2; > my $code = "TEST"; > my $module = "TEST"; > >@@ -342,6 +342,20 @@ subtest 'loops' => sub { > my $expected_letter = join '', ( $patron_1->{surname}, $patron_2->{surname} ); > is( $letter->{content}, $expected_letter, ); > }; >+ >+ subtest 'foreign key is used' => sub { >+ plan tests => 1; >+ my $patron_1 = $builder->build({ source => 'Borrower' }); >+ my $patron_2 = $builder->build({ source => 'Borrower' }); >+ my $checkout_1 = $builder->build({ source => 'Issue', value => { borrowernumber => $patron_1->{borrowernumber} } } ); >+ my $checkout_2 = $builder->build({ source => 'Issue', value => { borrowernumber => $patron_1->{borrowernumber} } } ); >+ >+ my $template = q|[% FOREACH checkout IN checkouts %][% checkout.issue_id %][% END %]|; >+ reset_template( { template => $template, code => $code, module => $module } ); >+ my $letter = GetPreparedLetter( module => $module, letter_code => $code, loops => { issues => [ $checkout_1->{itemnumber}, $checkout_2->{itemnumber} ] } ); >+ my $expected_letter = join '', ( $checkout_1->{issue_id}, $checkout_2->{issue_id} ); >+ is( $letter->{content}, $expected_letter, ); >+ }; > }; > > sub reset_template { >-- >2.1.4
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 17971
:
59426
|
59427
|
59529
|
59530
|
60987
|
60988
|
61710
| 61711 |
61712