Bugzilla – Attachment 64333 Details for
Bug 17965
TT syntax for notices - Prove that DUEDGST is compatible
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17965: TT syntax for notices - Prove that DUEDGST is compatible
Bug-17965-TT-syntax-for-notices---Prove-that-DUEDG.patch (text/plain), 4.09 KB, created by
Kyle M Hall (khall)
on 2017-06-15 14:48:49 UTC
(
hide
)
Description:
Bug 17965: TT syntax for notices - Prove that DUEDGST is compatible
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2017-06-15 14:48:49 UTC
Size:
4.09 KB
patch
obsolete
>From aac9c8e4c0d8b93348f69d9a31abab2d4828bb26 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 16 Jan 2017 16:58:23 +0100 >Subject: [PATCH] Bug 17965: TT syntax for notices - Prove that DUEDGST is > compatible >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This notice template have the particular feature of using <<count>>. >This value is substitued during the process of the notice template. >For the TT syntax, all what we need is to send the values to substitute to the >template. > >Note that items.content can also be used in these template, you can have >a look at bug 17967 to see a better alternative to this marker. > >Test plan: >Generate DUEDGST and DUE notice messages. >You should be able to generate the same messages with the TT syntax. > >Signed-off-by: Marc Véron <veron@veron.ch> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > C4/Letters.pm | 4 +++- > t/db_dependent/Letters/TemplateToolkit.t | 30 +++++++++++++++++++++++++++++- > 2 files changed, 32 insertions(+), 2 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index cd7b785..1d87a46 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -782,6 +782,7 @@ sub GetPreparedLetter { > content => $letter->{content}, > tables => $tables, > loops => $loops, >+ substitute => $substitute, > } > ); > >@@ -1455,6 +1456,7 @@ sub _process_tt { > my $content = $params->{content}; > my $tables = $params->{tables}; > my $loops = $params->{loops}; >+ my $substitute = $params->{substitute} || {}; > > my $use_template_cache = C4::Context->config('template_cache_dir') && defined $ENV{GATEWAY_INTERFACE}; > my $template = Template->new( >@@ -1469,7 +1471,7 @@ sub _process_tt { > } > ) or die Template->error(); > >- my $tt_params = { %{ _get_tt_params( $tables ) }, %{ _get_tt_params( $loops, 'is_a_loop' ) } }; >+ my $tt_params = { %{ _get_tt_params( $tables ) }, %{ _get_tt_params( $loops, 'is_a_loop' ) }, %$substitute }; > > $content = qq|[% USE KohaDates %]$content|; > >diff --git a/t/db_dependent/Letters/TemplateToolkit.t b/t/db_dependent/Letters/TemplateToolkit.t >index b83c2b6..4fd000a 100644 >--- a/t/db_dependent/Letters/TemplateToolkit.t >+++ b/t/db_dependent/Letters/TemplateToolkit.t >@@ -286,7 +286,7 @@ $prepared_letter = GetPreparedLetter( > is( $prepared_letter->{content}, $modification->id(), 'Patron modification object used correctly' ); > > subtest 'regression tests' => sub { >- plan tests => 3; >+ plan tests => 4; > > my $library = $builder->build( { source => 'Branch' } ); > my $patron = $builder->build( { source => 'Borrower' } ); >@@ -472,6 +472,34 @@ Thank you for visiting [% branch.branchname %]. > is( $second_checkin_tt_letter->content, $second_checkin_letter->content, 'Verify second checkin letter' ); > > }; >+ >+ subtest 'DUEDGST|count' => sub { >+ plan tests => 1; >+ >+ my $code = 'DUEDGST'; >+ >+ my $dbh = C4::Context->dbh; >+ # Enable notification for DUEDGST - Things are hardcoded here but should work with default data >+ $dbh->do(q|INSERT INTO borrower_message_preferences( borrowernumber, message_attribute_id ) VALUES ( ?, ? )|, undef, $patron->{borrowernumber}, 1 ); >+ my $borrower_message_preference_id = $dbh->last_insert_id(undef, undef, "borrower_message_preferences", undef); >+ $dbh->do(q|INSERT INTO borrower_message_transport_preferences( borrower_message_preference_id, message_transport_type) VALUES ( ?, ? )|, undef, $borrower_message_preference_id, 'email' ); >+ >+ my $params = { >+ code => $code, >+ substitute => { count => 42 }, >+ }; >+ >+ my $template = q| >+You have <<count>> items due >+ |; >+ my $letter = process_letter( { template => $template, %$params }); >+ >+ my $tt_template = q| >+You have [% count %] items due >+ |; >+ my $tt_letter = process_letter( { template => $tt_template, %$params }); >+ is( $tt_letter->{content}, $letter->{content}, ); >+ }; > }; > > subtest 'loops' => sub { >-- >2.10.2
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 17965
:
59439
|
60625
|
63967
|
63971
|
63972
| 64333