Bug 35581: Koha::*Illbatch* -> Koha::*ILL::*Batch*
Koha/Illbatch.pm -> Koha/ILL/Batch.pm Koha/Illbatches.pm -> Koha/ILL/Batches.pm Koha/REST/V1/Illbatches.pm -> Koha/REST/V1/ILL/Batches.pm t/db_dependent/Koha/Illbatch.t -> t/db_dependent/Koha/ILL/Batch.t t/db_dependent/Illbatches.t -> t/db_dependent/Koha/ILL/Batches.t Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
64c06fa87c
commit
daf37b85d7
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::Illbatch;
|
||||
package Koha::ILL::Batch;
|
||||
|
||||
# Copyright PTFS Europe 2022
|
||||
#
|
||||
|
|
@ -32,13 +32,13 @@ use base qw(Koha::Object);
|
|||
|
||||
=head1 NAME
|
||||
|
||||
Koha::Illbatch - Koha Illbatch Object class
|
||||
Koha::ILL::Batch - Koha Illbatch Object class
|
||||
|
||||
=head2 Class methods
|
||||
|
||||
=head3 status
|
||||
|
||||
my $status = Koha::Illbatch->status;
|
||||
my $status = Koha::ILL::Batch > status;
|
||||
|
||||
Return the status object associated with this batch
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ sub status {
|
|||
|
||||
=head3 patron
|
||||
|
||||
my $patron = Koha::Illbatch->patron;
|
||||
my $patron = Koha::ILL::Batch->patron;
|
||||
|
||||
Return the I<Koha::Patron> object associated with this batch
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ sub patron {
|
|||
|
||||
=head3 library
|
||||
|
||||
my $library = Koha::Illbatch->library;
|
||||
my $library = Koha::ILL::Batch->library;
|
||||
|
||||
Return the I<Koha::Library> object associated with this batch
|
||||
|
||||
|
|
@ -232,7 +232,7 @@ sub strings_map {
|
|||
|
||||
=head3 _type
|
||||
|
||||
my $type = Koha::Illbatch->_type;
|
||||
my $type = Koha::ILL::Batch->_type;
|
||||
|
||||
Return this object's type
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::Illbatches;
|
||||
package Koha::ILL::Batches;
|
||||
|
||||
# Copyright PTFS Europe 2022
|
||||
#
|
||||
|
|
@ -19,18 +19,18 @@ package Koha::Illbatches;
|
|||
|
||||
use Modern::Perl;
|
||||
use Koha::Database;
|
||||
use Koha::Illbatch;
|
||||
use Koha::ILL::Batch;
|
||||
use base qw(Koha::Objects);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Koha::Illbatches - Koha Illbatches Object class
|
||||
Koha::ILL::Batches - Koha Illbatches Object class
|
||||
|
||||
=head2 Internal methods
|
||||
|
||||
=head3 _type
|
||||
|
||||
my $type = Koha::Illbatches->_type;
|
||||
my $type = Koha::ILL::Batches->_type;
|
||||
|
||||
Return this object's type
|
||||
|
||||
|
|
@ -42,14 +42,14 @@ sub _type {
|
|||
|
||||
=head3 object_class
|
||||
|
||||
my $class = Koha::Illbatches->object_class;
|
||||
my $class = Koha::ILL::Batches->object_class;
|
||||
|
||||
Return this object's class name
|
||||
|
||||
=cut
|
||||
|
||||
sub object_class {
|
||||
return 'Koha::Illbatch';
|
||||
return 'Koha::ILL::Batch';
|
||||
}
|
||||
|
||||
=head1 AUTHOR
|
||||
|
|
@ -20,7 +20,7 @@ package Koha::IllbatchStatus;
|
|||
use Modern::Perl;
|
||||
use Koha::Database;
|
||||
use Koha::Illrequest::Logger;
|
||||
use Koha::Illbatch;
|
||||
use Koha::ILL::Batch;
|
||||
use JSON qw( to_json );
|
||||
use base qw(Koha::Object);
|
||||
|
||||
|
|
@ -124,7 +124,7 @@ sub delete_and_log {
|
|||
}
|
||||
|
||||
# Update all batches that use this status to have status UNKNOWN
|
||||
my $affected = Koha::Illbatches->search( { status_code => $self->code } );
|
||||
my $affected = Koha::ILL::Batches->search( { status_code => $self->code } );
|
||||
$affected->update( { status_code => 'UNKNOWN' } );
|
||||
|
||||
my $logger = Koha::Illrequest::Logger->new;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ use Koha::Illrequestattributes;
|
|||
use Koha::AuthorisedValue;
|
||||
use Koha::Illrequest::Logger;
|
||||
use Koha::Patron;
|
||||
use Koha::Illbatches;
|
||||
use Koha::ILL::Batches;
|
||||
use Koha::AuthorisedValues;
|
||||
use Koha::Biblios;
|
||||
use Koha::Items;
|
||||
|
|
@ -152,7 +152,7 @@ sub push_processor {
|
|||
|
||||
my $ill_batch = $request->ill_batch;
|
||||
|
||||
Returns the I<Koha::Illbatch> associated with the request
|
||||
Returns the I<Koha::ILL::Batch> associated with the request
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -161,7 +161,7 @@ sub ill_batch {
|
|||
|
||||
my $ill_batch = $self->_result->ill_batch;
|
||||
return unless $ill_batch;
|
||||
return Koha::Illbatch->_new_from_dbic($ill_batch);
|
||||
return Koha::ILL::Batch->_new_from_dbic($ill_batch);
|
||||
}
|
||||
|
||||
=head3 statusalias
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package Koha::REST::V1::Illbatches;
|
||||
package Koha::REST::V1::ILL::Batches;
|
||||
|
||||
# This file is part of Koha.
|
||||
#
|
||||
|
|
@ -19,7 +19,7 @@ use Modern::Perl;
|
|||
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
|
||||
use Koha::Illbatches;
|
||||
use Koha::ILL::Batches;
|
||||
use Koha::IllbatchStatuses;
|
||||
use Koha::Illrequests;
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ use Try::Tiny qw( catch try );
|
|||
|
||||
=head1 NAME
|
||||
|
||||
Koha::REST::V1::Illbatches
|
||||
Koha::REST::V1::ILL::Batches
|
||||
|
||||
=head2 Operations
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ sub list {
|
|||
return try {
|
||||
return $c->render(
|
||||
status => 200,
|
||||
openapi => $c->objects->search( Koha::Illbatches->new )
|
||||
openapi => $c->objects->search( Koha::ILL::Batches->new )
|
||||
);
|
||||
} catch {
|
||||
warn "$_";
|
||||
|
|
@ -61,7 +61,7 @@ sub get {
|
|||
my $c = shift->openapi->valid_input or return;
|
||||
|
||||
return try {
|
||||
my $ill_batch = $c->objects->find( Koha::Illbatches->new, $c->param('ill_batch_id') );
|
||||
my $ill_batch = $c->objects->find( Koha::ILL::Batches->new, $c->param('ill_batch_id') );
|
||||
|
||||
unless ($ill_batch) {
|
||||
return $c->render(
|
||||
|
|
@ -103,12 +103,12 @@ sub add {
|
|||
$body->{patron_id} = $patron->id;
|
||||
|
||||
return try {
|
||||
my $batch = Koha::Illbatch->new_from_api($body);
|
||||
my $batch = Koha::ILL::Batch->new_from_api($body);
|
||||
$batch->create_and_log;
|
||||
|
||||
$c->res->headers->location( $c->req->url->to_string . '/' . $batch->id );
|
||||
|
||||
my $ill_batch = $c->objects->find( Koha::Illbatches->new, $batch->id );
|
||||
my $ill_batch = $c->objects->find( Koha::ILL::Batches->new, $batch->id );
|
||||
|
||||
return $c->render(
|
||||
status => 201,
|
||||
|
|
@ -136,7 +136,7 @@ Update a batch
|
|||
sub update {
|
||||
my $c = shift->openapi->valid_input or return;
|
||||
|
||||
my $batch = Koha::Illbatches->find( $c->param('ill_batch_id') );
|
||||
my $batch = Koha::ILL::Batches->find( $c->param('ill_batch_id') );
|
||||
|
||||
unless ($batch) {
|
||||
return $c->render(
|
||||
|
|
@ -170,7 +170,7 @@ sub delete {
|
|||
|
||||
my $c = shift->openapi->valid_input or return;
|
||||
|
||||
my $batch = Koha::Illbatches->find( $c->param('ill_batch_id') );
|
||||
my $batch = Koha::ILL::Batches->find( $c->param('ill_batch_id') );
|
||||
|
||||
if ( not defined $batch ) {
|
||||
return $c->render( status => 404, openapi => { error => "ILL batch not found" } );
|
||||
|
|
@ -205,11 +205,11 @@ __PACKAGE__->has_many(
|
|||
);
|
||||
|
||||
sub koha_object_class {
|
||||
'Koha::Illbatch';
|
||||
'Koha::ILL::Batch';
|
||||
}
|
||||
|
||||
sub koha_objects_class {
|
||||
'Koha::Illbatches';
|
||||
'Koha::ILL::Batches';
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
/ill/batches:
|
||||
get:
|
||||
x-mojo-to: Illbatches#list
|
||||
x-mojo-to: ILL::Batches#list
|
||||
operationId: listIllbatches
|
||||
tags:
|
||||
- ill_batches
|
||||
|
|
@ -62,7 +62,7 @@
|
|||
permissions:
|
||||
ill: "1"
|
||||
post:
|
||||
x-mojo-to: Illbatches#add
|
||||
x-mojo-to: ILL::Batches#add
|
||||
operationId: addIllbatch
|
||||
tags:
|
||||
- ill_batches
|
||||
|
|
@ -131,7 +131,7 @@
|
|||
ill: "1"
|
||||
"/ill/batches/{ill_batch_id}":
|
||||
get:
|
||||
x-mojo-to: Illbatches#get
|
||||
x-mojo-to: ILL::Batches#get
|
||||
operationId: getIllbatches
|
||||
tags:
|
||||
- ill_batches
|
||||
|
|
@ -197,7 +197,7 @@
|
|||
permissions:
|
||||
ill: "1"
|
||||
put:
|
||||
x-mojo-to: Illbatches#update
|
||||
x-mojo-to: ILL::Batches#update
|
||||
operationId: updateIllBatch
|
||||
tags:
|
||||
- ill_batches
|
||||
|
|
@ -250,7 +250,7 @@
|
|||
permissions:
|
||||
ill: "1"
|
||||
delete:
|
||||
x-mojo-to: Illbatches#delete
|
||||
x-mojo-to: ILL::Batches#delete
|
||||
operationId: deleteBatch
|
||||
tags:
|
||||
- ill_batches
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ use Koha::AuthorisedValues;
|
|||
use Koha::Illcomment;
|
||||
use Koha::Illrequests;
|
||||
use Koha::Illrequest;
|
||||
use Koha::Illbatches;
|
||||
use Koha::ILL::Batches;
|
||||
use Koha::Illrequest::Workflow::Availability;
|
||||
use Koha::Illrequest::Workflow::TypeDisclaimer;
|
||||
use Koha::Libraries;
|
||||
|
|
@ -221,7 +221,7 @@ if ( $backends_available ) {
|
|||
# We simulate the API for backend requests for uniformity.
|
||||
# So, init:
|
||||
my $request = Koha::Illrequests->find($params->{illrequest_id});
|
||||
my $batches = Koha::Illbatches->search(undef, {
|
||||
my $batches = Koha::ILL::Batches->search(undef, {
|
||||
order_by => { -asc => 'name' }
|
||||
});
|
||||
if ( !$params->{stage} ) {
|
||||
|
|
@ -402,7 +402,7 @@ if ( $backends_available ) {
|
|||
if ($active_filters->{batch_id}) {
|
||||
my $batch_id = $active_filters->{batch_id};
|
||||
if ($batch_id) {
|
||||
my $batch = Koha::Illbatches->find($batch_id);
|
||||
my $batch = Koha::ILL::Batches->find($batch_id);
|
||||
$template->param(
|
||||
batch => $batch
|
||||
);
|
||||
|
|
|
|||
|
|
@ -191,12 +191,12 @@ my $status5 = Koha::IllbatchStatus->new(
|
|||
}
|
||||
);
|
||||
$status5->create_and_log;
|
||||
my $batch = Koha::Illbatch->new(
|
||||
my $batch = Koha::ILL::Batch->new(
|
||||
{
|
||||
name => "My test batch",
|
||||
patron_id => $patron->borrowernumber,
|
||||
library_id => $library->branchcode,
|
||||
backend => "TEST",
|
||||
name => "My test batch",
|
||||
patron_id => $patron->borrowernumber,
|
||||
library_id => $library->branchcode,
|
||||
backend => "TEST",
|
||||
status_code => $status5->code
|
||||
}
|
||||
);
|
||||
|
|
@ -205,7 +205,7 @@ $batch->create_and_log;
|
|||
# Delete the batch status and ensure the batch's status has been changed
|
||||
# to UNKNOWN
|
||||
$status5->delete_and_log;
|
||||
my $updated_code = Koha::Illbatches->find( { status_code => "UNKNOWN" } );
|
||||
my $updated_code = Koha::ILL::Batches->find( { status_code => "UNKNOWN" } );
|
||||
is( $updated_code->status_code, "UNKNOWN", "batches attached to deleted status have status changed to UNKNOWN" );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ subtest 'ill_batch() tests' => sub {
|
|||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
my $batch = $builder->build_object( { class => 'Koha::Illbatches' } );
|
||||
my $batch = $builder->build_object( { class => 'Koha::ILL::Batches' } );
|
||||
my $request = $builder->build_object( { class => 'Koha::Illrequests', value => { batch_id => undef } } );
|
||||
|
||||
is( $request->ill_batch, undef, 'Not having a linked batch makes the method return undef' );
|
||||
|
|
@ -42,7 +42,7 @@ subtest 'ill_batch() tests' => sub {
|
|||
$request->batch_id( $batch->id )->store;
|
||||
|
||||
my $linked_batch = $request->ill_batch;
|
||||
is( ref($linked_batch), 'Koha::Illbatch' );
|
||||
is( ref($linked_batch), 'Koha::ILL::Batch' );
|
||||
is( $linked_batch->id, $batch->id, 'Correct batch linked' );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
|
|
@ -18,8 +18,8 @@
|
|||
use Modern::Perl;
|
||||
|
||||
use Koha::Database;
|
||||
use Koha::Illbatch;
|
||||
use Koha::Illbatches;
|
||||
use Koha::ILL::Batch;
|
||||
use Koha::ILL::Batches;
|
||||
use Koha::Illrequests;
|
||||
use Koha::Patrons;
|
||||
use t::lib::Mocks;
|
||||
|
|
@ -31,8 +31,8 @@ use Test::More tests => 6;
|
|||
|
||||
my $schema = Koha::Database->new->schema;
|
||||
my $builder = t::lib::TestBuilder->new;
|
||||
use_ok('Koha::Illbatch');
|
||||
use_ok('Koha::Illbatches');
|
||||
use_ok('Koha::ILL::Batch');
|
||||
use_ok('Koha::ILL::Batches');
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
|
|
@ -53,8 +53,8 @@ my $branch = $builder->build( { source => 'Branch' } );
|
|||
# Create a batch
|
||||
my $illbatch = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::Illbatches',
|
||||
value => {
|
||||
class => 'Koha::ILL::Batches',
|
||||
value => {
|
||||
name => "My test batch",
|
||||
backend => "Mock",
|
||||
patron_id => $librarian->{borrowernumber},
|
||||
|
|
@ -25,8 +25,8 @@ use t::lib::Mocks;
|
|||
|
||||
use JSON qw(encode_json);
|
||||
|
||||
use Koha::Illbatch;
|
||||
use Koha::Illbatches;
|
||||
use Koha::ILL::Batch;
|
||||
use Koha::ILL::Batches;
|
||||
use Koha::Illrequests;
|
||||
use Koha::IllbatchStatuses;
|
||||
use Koha::Database;
|
||||
|
|
@ -58,7 +58,7 @@ subtest 'list() tests' => sub {
|
|||
$librarian->set_password( { password => $password, skip_validation => 1 } );
|
||||
my $userid = $librarian->userid;
|
||||
|
||||
my $batch_to_delete = $builder->build_object( { class => 'Koha::Illbatches' } );
|
||||
my $batch_to_delete = $builder->build_object( { class => 'Koha::ILL::Batches' } );
|
||||
my $deleted_batch_id = $batch_to_delete->id;
|
||||
$batch_to_delete->delete;
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ subtest 'list() tests' => sub {
|
|||
|
||||
my $batch_1 = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::Illbatches',
|
||||
class => 'Koha::ILL::Batches',
|
||||
value => {
|
||||
backend => "Mock",
|
||||
patron_id => $librarian->id,
|
||||
|
|
@ -100,7 +100,7 @@ subtest 'list() tests' => sub {
|
|||
->json_has( '/0/library', 'branch embedded' )->json_has( '/0/requests_count', 'request count' );
|
||||
|
||||
# Create a second batch with a different name
|
||||
my $batch_2 = $builder->build_object( { class => 'Koha::Illbatches' } );
|
||||
my $batch_2 = $builder->build_object( { class => 'Koha::ILL::Batches' } );
|
||||
|
||||
$query = { ill_batch_id => [ $batch_1->id, $batch_2->id ] };
|
||||
|
||||
|
|
@ -155,7 +155,7 @@ subtest 'get() tests' => sub {
|
|||
|
||||
my $batch = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::Illbatches',
|
||||
class => 'Koha::ILL::Batches',
|
||||
value => {
|
||||
backend => "Mock",
|
||||
patron_id => $librarian->id,
|
||||
|
|
@ -176,7 +176,7 @@ subtest 'get() tests' => sub {
|
|||
|
||||
$t->get_ok( "//$unauth_userid:$password@/api/v1/ill/batches/" . $batch->id )->status_is(403);
|
||||
|
||||
my $batch_to_delete = $builder->build_object( { class => 'Koha::Illbatches' } );
|
||||
my $batch_to_delete = $builder->build_object( { class => 'Koha::ILL::Batches' } );
|
||||
my $non_existent_id = $batch_to_delete->id;
|
||||
$batch_to_delete->delete;
|
||||
|
||||
|
|
@ -288,7 +288,7 @@ subtest 'update() tests' => sub {
|
|||
my $unauth_userid = $patron->userid;
|
||||
|
||||
my $library = $builder->build_object( { class => 'Koha::Libraries' } );
|
||||
my $batch_id = $builder->build_object( { class => 'Koha::Illbatches' } )->id;
|
||||
my $batch_id = $builder->build_object( { class => 'Koha::ILL::Batches' } )->id;
|
||||
|
||||
# Unauthorized attempt to update
|
||||
$t->put_ok( "//$unauth_userid:$password@/api/v1/ill/batches/$batch_id" => json =>
|
||||
|
|
@ -336,7 +336,7 @@ subtest 'update() tests' => sub {
|
|||
]
|
||||
);
|
||||
|
||||
my $batch_to_delete = $builder->build_object( { class => 'Koha::Illbatches' } );
|
||||
my $batch_to_delete = $builder->build_object( { class => 'Koha::ILL::Batches' } );
|
||||
my $non_existent_id = $batch_to_delete->id;
|
||||
$batch_to_delete->delete;
|
||||
|
||||
|
|
@ -378,7 +378,7 @@ subtest 'delete() tests' => sub {
|
|||
$patron->set_password( { password => $password, skip_validation => 1 } );
|
||||
my $unauth_userid = $patron->userid;
|
||||
|
||||
my $batch_id = $builder->build_object( { class => 'Koha::Illbatches' } )->id;
|
||||
my $batch_id = $builder->build_object( { class => 'Koha::ILL::Batches' } )->id;
|
||||
|
||||
# Unauthorized attempt to delete
|
||||
$t->delete_ok("//$unauth_userid:$password@/api/v1/ill/batches/$batch_id")->status_is(403);
|
||||
|
|
|
|||
Loading…
Reference in New Issue