View | Details | Raw Unified | Return to bug 28854
Collapse All | Expand All

(-)a/Koha/Exceptions/Item/Bundle.pm (+49 lines)
Line 0 Link Here
1
package Koha::Exceptions::Item::Bundle;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Koha::Exception;
21
22
use Exception::Class (
23
24
    'Koha::Exceptions::Item::Bundle' => {
25
        isa => 'Koha::Exception',
26
    },
27
    'Koha::Exceptions::Item::Bundle::IsBundle' => {
28
        isa         => 'Koha::Exceptions::Item::Bundle',
29
        description => "A bundle cannot be added to a bundle",
30
    }
31
);
32
33
=head1 NAME
34
35
Koha::Exceptions::Item::Bundle - Base class for Bundle exceptions
36
37
=head1 Exceptions
38
39
=head2 Koha::Exceptions::Item::Bundle
40
41
Generic Item::Bundle exception
42
43
=head2 Koha::Exceptions::Item::Bundle::IsBundle
44
45
Exception to be used when attempting to add one bundle into another.
46
47
=cut
48
49
1;
(-)a/Koha/Item.pm (+4 lines)
Lines 37-42 use Koha::CirculationRules; Link Here
37
use Koha::CoverImages;
37
use Koha::CoverImages;
38
use Koha::SearchEngine::Indexer;
38
use Koha::SearchEngine::Indexer;
39
use Koha::Exceptions::Item::Transfer;
39
use Koha::Exceptions::Item::Transfer;
40
use Koha::Exceptions::Item::Bundle;
40
use Koha::Item::Transfer::Limits;
41
use Koha::Item::Transfer::Limits;
41
use Koha::Item::Transfers;
42
use Koha::Item::Transfers;
42
use Koha::Item::Attributes;
43
use Koha::Item::Attributes;
Lines 1548-1553 Adds the bundle_item passed to this item Link Here
1548
sub add_to_bundle {
1549
sub add_to_bundle {
1549
    my ( $self, $bundle_item ) = @_;
1550
    my ( $self, $bundle_item ) = @_;
1550
1551
1552
    Koha::Exceptions::Item::Bundle::IsBundle->throw()
1553
      if $bundle_item->is_bundle;
1554
1551
    my $schema = Koha::Database->new->schema;
1555
    my $schema = Koha::Database->new->schema;
1552
1556
1553
    my $BundleNotLoanValue = C4::Context->preference('BundleNotLoanValue');
1557
    my $BundleNotLoanValue = C4::Context->preference('BundleNotLoanValue');
(-)a/Koha/REST/V1/Items.pm (+8 lines)
Lines 229-234 sub add_to_bundle { Link Here
229
                }
229
                }
230
            );
230
            );
231
        }
231
        }
232
        elsif ( ref($_) eq 'Koha::Exceptions::Item::Bundle::IsBundle' ) {
233
            return $c->render(
234
                status => 400,
235
                openapi => {
236
                    error => 'Bundles cannot be nested'
237
                }
238
            );
239
        }
232
        else {
240
        else {
233
            $c->unhandled_exception($_);
241
            $c->unhandled_exception($_);
234
        }
242
        }
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-1 / +7 lines)
Lines 1617-1622 Note that permanent location is a code, and location may be an authval. Link Here
1617
                          }
1617
                          }
1618
                      } else if ( data.status === 404 ) {
1618
                      } else if ( data.status === 404 ) {
1619
                          $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Item '%s' not found").format(barcode)+'</div>');
1619
                          $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Item '%s' not found").format(barcode)+'</div>');
1620
                      } else if ( data.status === 400 ) {
1621
                          var response = data.responseJSON;
1622
                          if ( response.error === "Bundles cannot be nested" ) {
1623
                              $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Item '%s' is a bundle and bundles cannot be nested").format(barcode)+'</div>');
1624
                          } else {
1625
                              $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Check the logs for details")+'</div>');
1626
                          }
1620
                      } else {
1627
                      } else {
1621
                          $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Check the logs for details")+'</div>');
1628
                          $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Check the logs for details")+'</div>');
1622
                      }
1629
                      }
1623
- 

Return to bug 28854