Bugzilla – Attachment 68991 Details for
Bug 19578
TT syntax for notices - There is no way to pre-process DB fields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19578: Remove MARC punctuation in notices (TT syntax)
Bug-19578-Remove-MARC-punctuation-in-notices-TT-sy.patch (text/plain), 3.96 KB, created by
Jonathan Druart
on 2017-11-06 18:41:43 UTC
(
hide
)
Description:
Bug 19578: Remove MARC punctuation in notices (TT syntax)
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-11-06 18:41:43 UTC
Size:
3.96 KB
patch
obsolete
>From 0803a85c0a83b58e31ff8269621b69d1a68f7f45 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 6 Nov 2017 15:35:50 -0300 >Subject: [PATCH] Bug 19578: Remove MARC punctuation in notices (TT syntax) > >--- > C4/Letters.pm | 26 +++++++++++++++++++- > t/db_dependent/Letters/TemplateToolkit.t | 42 +++++++++++++++++++++++++++++++- > 2 files changed, 66 insertions(+), 2 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index 3f23090c6b..3361e68257 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -1473,7 +1473,8 @@ sub _process_tt { > > my $tt_params = { %{ _get_tt_params( $tables ) }, %{ _get_tt_params( $loops, 'is_a_loop' ) }, %$substitute }; > >- $content = qq|[% USE KohaDates %]$content|; >+ $content = add_tt_filters( $content ); >+ $content = qq|[% USE KohaDates %][% USE Remove_MARC_punctuation %]$content|; > > my $output; > $template->process( \$content, $tt_params, \$output ) || croak "ERROR PROCESSING TEMPLATE: " . $template->error(); >@@ -1500,6 +1501,12 @@ sub _get_tt_params { > plural => 'biblios', > pk => 'biblionumber', > }, >+ biblioitems => { >+ module => 'Koha::Biblioitems', >+ singular => 'biblioitem', >+ plural => 'biblioitems', >+ pk => 'biblioitemnumber', >+ }, > borrowers => { > module => 'Koha::Patrons', > singular => 'borrower', >@@ -1649,6 +1656,23 @@ sub _get_tt_params { > return $params; > } > >+=head3 >+ >+$content = add_tt_filters( $content ); >+ >+Add TT filters to some specific fields if needed. >+ >+For now we only add the Remove_MARC_punctuation TT filter to biblio and biblioitem fields >+ >+=cut >+ >+sub add_tt_filters { >+ my ( $content ) = @_; >+ $content =~ s|\[%\s*biblio\.(.*?)\s*%\]|[% biblio.$1 \| \$Remove_MARC_punctuation %]|gxms; >+ $content =~ s|\[%\s*biblioitem\.(.*?)\s*%\]|[% biblioitem.$1 \| \$Remove_MARC_punctuation %]|gxms; >+ return $content; >+} >+ > =head2 get_item_content > > my $item = Koha::Items->find(...)->unblessed; >diff --git a/t/db_dependent/Letters/TemplateToolkit.t b/t/db_dependent/Letters/TemplateToolkit.t >index 611b936d6a..b3251ffb52 100644 >--- a/t/db_dependent/Letters/TemplateToolkit.t >+++ b/t/db_dependent/Letters/TemplateToolkit.t >@@ -19,7 +19,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 17; >+use Test::More tests => 18; > use Test::Warn; > > use MARC::Record; >@@ -894,6 +894,46 @@ subtest 'loops' => sub { > }; > }; > >+subtest 'add_tt_filters' => sub { >+ plan tests => 1; >+ my $code = "TEST"; >+ my $module = "TEST"; >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { surname => "with_punctuation_" } >+ } >+ ); >+ my $biblio = $builder->build_object( >+ { class => 'Koha::Biblios', value => { title => "with_punctuation_" } } >+ ); >+ my $biblioitem = $builder->build_object( >+ { >+ class => 'Koha::Biblioitems', >+ value => { >+ biblionumber => $biblio->biblionumber, >+ isbn => "with_punctuation_" >+ } >+ } >+ ); >+ >+ my $template = q|patron=[% borrower.surname %];biblio=[% biblio.title %];biblioitems=[% biblioitem.isbn %]|; >+ reset_template( { template => $template, code => $code, module => $module } ); >+ my $letter = GetPreparedLetter( >+ module => $module, >+ letter_code => $code, >+ tables => { >+ borrowers => $patron->borrowernumber, >+ biblio => $biblio->biblionumber, >+ biblioitems => $biblioitem->biblioitemnumber >+ } >+ ); >+ my $expected_letter = q|patron=with_punctuation_;biblio=with_punctuation;biblioitems=with_punctuation|; >+ is( $letter->{content}, $expected_letter, ); >+}; >+ >+ > sub reset_template { > my ( $params ) = @_; > my $template = $params->{template}; >-- >2.11.0
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 19578
:
68990
|
68991
|
73585
|
73596
|
73602