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

(-)a/Koha/ArticleRequest.pm (+4 lines)
Lines 266-271 sub store { Link Here
266
    if ( !$self->in_storage ) {
266
    if ( !$self->in_storage ) {
267
        $self->created_on( dt_from_string() );
267
        $self->created_on( dt_from_string() );
268
    }
268
    }
269
    my $format = $self->format;
270
    if ( C4::Context->preference('ArticleRequestsSupportedFormats') !~ /\b$format\b/ ) {
271
        Koha::Exceptions::ArticleRequest::WrongFormat->throw;
272
    }
269
273
270
    return $self->SUPER::store;
274
    return $self->SUPER::store;
271
}
275
}
(-)a/Koha/Exceptions/ArticleRequest.pm (+4 lines)
Lines 27-32 use Exception::Class ( Link Here
27
        isa         => 'Koha::Exceptions::ArticleRequest',
27
        isa         => 'Koha::Exceptions::ArticleRequest',
28
        description => 'Article request limit was reached'
28
        description => 'Article request limit was reached'
29
    },
29
    },
30
    'Koha::Exceptions::ArticleRequest::WrongFormat' => {
31
        isa         => 'Koha::Exceptions::ArticleRequest',
32
        description => 'Passed format is not locally supported'
33
    },
30
);
34
);
31
35
32
=head1 NAME
36
=head1 NAME
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-request-article.tt (-1 / +1 lines)
Lines 296-302 $(document).ready( function() { Link Here
296
    });
296
    });
297
297
298
    // Initialize format(s)
298
    // Initialize format(s)
299
    var supported_formats = "[% Koha.Preference('ArticleRequestsSupportedFormats') | $raw %]";
299
    var supported_formats = "[% Koha.Preference('ArticleRequestsSupportedFormats') | html %]";
300
    if( !supported_formats.match(/PHOTOCOPY/) )
300
    if( !supported_formats.match(/PHOTOCOPY/) )
301
        $('#format option[value="PHOTOCOPY"]').remove();
301
        $('#format option[value="PHOTOCOPY"]').remove();
302
    if( !supported_formats.match(/SCAN/) )
302
    if( !supported_formats.match(/SCAN/) )
(-)a/t/db_dependent/Koha/ArticleRequest.t (-2 / +17 lines)
Lines 17-29 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 5;
20
use Test::More tests => 6;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Exception;
22
23
23
use t::lib::TestBuilder;
24
use t::lib::TestBuilder;
24
use t::lib::Mocks;
25
use t::lib::Mocks;
25
26
26
use Koha::ArticleRequests;
27
use Koha::ArticleRequests;
28
use Koha::Exceptions::ArticleRequest;
27
29
28
my $schema  = Koha::Database->new->schema;
30
my $schema  = Koha::Database->new->schema;
29
my $builder = t::lib::TestBuilder->new;
31
my $builder = t::lib::TestBuilder->new;
Lines 209-211 subtest 'cancel() tests' => sub { Link Here
209
211
210
    $schema->storage->txn_rollback;
212
    $schema->storage->txn_rollback;
211
};
213
};
212
- 
214
215
subtest 'store' => sub {
216
    plan tests => 2;
217
    $schema->storage->txn_begin;
218
219
    t::lib::Mocks::mock_preference( 'ArticleRequestsSupportedFormats', 'SCAN' );
220
    my $ar = $builder->build_object( { class => 'Koha::ArticleRequests', value => { format => 'PHOTOCOPY' } } );
221
    throws_ok { $ar->format('test')->store } 'Koha::Exceptions::ArticleRequest::WrongFormat',
222
        'Format not supported';
223
    t::lib::Mocks::mock_preference( 'ArticleRequestsSupportedFormats', 'SCAN|PHOTOCOPY|ELSE' );
224
    lives_ok { $ar->format('PHOTOCOPY')->store } 'Now we do support it';
225
226
    $schema->storage->txn_rollback;
227
};

Return to bug 36081