Bugzilla – Attachment 60625 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), 3.83 KB, created by
Marc Véron
on 2017-02-23 22:17:12 UTC
(
hide
)
Description:
Bug 17965: TT syntax for notices - Prove that DUEDGST is compatible
Filename:
MIME Type:
Creator:
Marc Véron
Created:
2017-02-23 22:17:12 UTC
Size:
3.83 KB
patch
obsolete
>From 5360121e127e395f56ffcd83449e5bc5ad0e4d07 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> >--- > C4/Letters.pm | 3 +++ > t/db_dependent/Letters/TemplateToolkit.t | 31 ++++++++++++++++++++++++++++++- > 2 files changed, 33 insertions(+), 1 deletion(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index 6349d1a..b2ce083 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -770,6 +770,7 @@ sub GetPreparedLetter { > { > content => $letter->{content}, > tables => $tables, >+ substitute => $substitute, > } > ); > >@@ -1440,6 +1441,7 @@ sub _process_tt { > > my $content = $params->{content}; > my $tables = $params->{tables}; >+ my $substitute = $params->{substitute} || {}; > > my $use_template_cache = C4::Context->config('template_cache_dir') && defined $ENV{GATEWAY_INTERFACE}; > my $template = Template->new( >@@ -1455,6 +1457,7 @@ sub _process_tt { > ) or die Template->error(); > > my $tt_params = _get_tt_params( $tables ); >+ $tt_params = { %$tt_params, %$substitute }; > > $content = qq|[% USE KohaDates %]$content|; > >diff --git a/t/db_dependent/Letters/TemplateToolkit.t b/t/db_dependent/Letters/TemplateToolkit.t >index 810961a..f0aa490 100644 >--- a/t/db_dependent/Letters/TemplateToolkit.t >+++ b/t/db_dependent/Letters/TemplateToolkit.t >@@ -285,7 +285,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' } ); >@@ -471,6 +471,35 @@ Thank you for visiting [% branch.branchname %]. > is( $second_checkin_tt_letter->content, $second_checkin_letter->content, ); > > }; >+ >+ 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}, ); >+ }; >+ > }; > > 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 17965
:
59439
|
60625
|
63967
|
63971
|
63972
|
64333