Bugzilla – Attachment 157741 Details for
Bug 31383
Additional contents: We need a parent and child table
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31383: (follow-up) Remove get_opac_news_by_id
Bug-31383-follow-up-Remove-getopacnewsbyid.patch (text/plain), 4.08 KB, created by
Jonathan Druart
on 2023-10-24 13:14:08 UTC
(
hide
)
Description:
Bug 31383: (follow-up) Remove get_opac_news_by_id
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-10-24 13:14:08 UTC
Size:
4.08 KB
patch
obsolete
>From 97414af0593f948fdba9e9a3b6dec02cca065c00 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 24 Oct 2023 15:12:44 +0200 >Subject: [PATCH] Bug 31383: (follow-up) Remove get_opac_news_by_id > >Keep the same behaviour, but wondering why we don't return 'content' >when there is no match. > >ie. >+ is( $additional_contents, undef ); >should certainly be >+ is( $additional_contents->{content}->count, 0 ); >--- > Koha/AdditionalContents.pm | 1 + > Koha/Template/Plugin/AdditionalContents.pm | 1 + > koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt | 2 +- > t/db_dependent/Template/Plugin/AdditionalContents.t | 7 ++++++- > 4 files changed, 9 insertions(+), 2 deletions(-) > >diff --git a/Koha/AdditionalContents.pm b/Koha/AdditionalContents.pm >index bbad4869a2a..9ad3c0f9c2a 100644 >--- a/Koha/AdditionalContents.pm >+++ b/Koha/AdditionalContents.pm >@@ -81,6 +81,7 @@ sub search_for_display { > qq|(SELECT COUNT(*) FROM additional_contents_localizations WHERE lang='$lang' AND additional_content_id=me.additional_content_id)=0|; > > my $search_params; >+ $search_params->{'additional_content.id'} = $params->{id} if $params->{id}; > $search_params->{location} = $params->{location}; > $search_params->{branchcode} = $params->{library_id} ? [ $params->{library_id}, undef ] : undef; > $search_params->{published_on} = { '<=' => \'CAST(NOW() AS DATE)' }; >diff --git a/Koha/Template/Plugin/AdditionalContents.pm b/Koha/Template/Plugin/AdditionalContents.pm >index a44de966dc9..41330e4b3f6 100644 >--- a/Koha/Template/Plugin/AdditionalContents.pm >+++ b/Koha/Template/Plugin/AdditionalContents.pm >@@ -44,6 +44,7 @@ sub get { > location => $location, > lang => $lang, > ( $library ? ( library_id => $library ) : () ), >+ ( $id ? ( id => $id ) : () ), > } > ); > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt >index e8cf85bc9d7..592368ab381 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt >@@ -89,7 +89,7 @@ > [% END %] > > [% IF news_id %] >- [% SET koha_news = AdditionalContents.get( category => 'news', location => ['opac_only', 'staff_and_opac'], lang => lang, news_id => news_id ) %] >+ [% SET koha_news = AdditionalContents.get( category => 'news', location => ['opac_only', 'staff_and_opac'], lang => lang, id => news_id ) %] > [% ELSE %] > [% SET koha_news = AdditionalContents.get( category => 'news', location => ['opac_only', 'staff_and_opac'], lang => lang, library => branchcode ) %] > [% END %] >diff --git a/t/db_dependent/Template/Plugin/AdditionalContents.t b/t/db_dependent/Template/Plugin/AdditionalContents.t >index cf30973e1e2..01743bd765e 100755 >--- a/t/db_dependent/Template/Plugin/AdditionalContents.t >+++ b/t/db_dependent/Template/Plugin/AdditionalContents.t >@@ -33,7 +33,7 @@ my $builder = t::lib::TestBuilder->new; > $schema->storage->txn_begin; > > subtest 'get' => sub { >- plan tests => 2; >+ plan tests => 4; > > my $additional_contents = Koha::Template::Plugin::AdditionalContents->get({ category => 'news', location => ['opac_only', 'staff_and_opac'], lang => 'default', library => '%' }); > my $before_count = $additional_contents ? $additional_contents->{content}->count() : 0; >@@ -61,6 +61,11 @@ subtest 'get' => sub { > > is( $additional_contents->{blocktitle}, 'blockhead', "Block title is passed through"); > >+ $additional_contents = Koha::Template::Plugin::AdditionalContents->get({ id => $additional_content->id, category => 'news', location => ['opac_only', 'staff_and_opac'], lang => 'default' }); >+ is( $additional_contents->{content}->count, 1 ); >+ >+ $additional_contents = Koha::Template::Plugin::AdditionalContents->get({ id => $additional_content->id, category => 'html_customizations', location => ['opac_only', 'staff_and_opac'], lang => 'default' }); >+ is( $additional_contents, undef ); > > }; > >-- >2.34.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 31383
:
147891
|
147892
|
147893
|
147894
|
147895
|
147896
|
149813
|
149814
|
149815
|
149816
|
149817
|
149818
|
152423
|
152424
|
152425
|
152426
|
152427
|
152428
|
152545
|
152546
|
152547
|
152566
|
152660
|
152661
|
152662
|
152663
|
152664
|
152665
|
152666
|
152667
|
152668
|
152669
|
153013
|
153666
|
153667
|
153668
|
153669
|
153670
|
153671
|
153672
|
153673
|
153674
|
153675
|
153676
|
156048
|
156049
|
156050
|
156051
|
156052
|
156053
|
156054
|
156055
|
156056
|
156057
|
156058
|
156265
|
156266
|
156267
|
156268
|
156269
|
156270
|
156271
|
156272
|
156273
|
156274
|
156275
|
156276
|
157539
|
157540
|
157541
|
157542
|
157543
|
157544
|
157545
|
157546
|
157547
|
157548
|
157549
|
157550
|
157580
|
157585
|
157640
|
157741
|
157742