Bugzilla – Attachment 159864 Details for
Bug 35581
ILL Koha classes are not consistent
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35581: Illbatch.pm -> ILL/Batch.pm
Bug-35581-Illbatchpm---ILLBatchpm.patch (text/plain), 17.06 KB, created by
Pedro Amorim
on 2023-12-15 11:03:59 UTC
(
hide
)
Description:
Bug 35581: Illbatch.pm -> ILL/Batch.pm
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2023-12-15 11:03:59 UTC
Size:
17.06 KB
patch
obsolete
>From 00d9764398317a10a12b7793ace5290fb0e60ff2 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Thu, 14 Dec 2023 14:46:11 +0000 >Subject: [PATCH] Bug 35581: Illbatch.pm -> ILL/Batch.pm > >Illbatches.pm -> ILL/Batches.pm >--- > Koha/{Illbatch.pm => ILL/Batch.pm} | 12 +++++------ > Koha/{Illbatches.pm => ILL/Batches.pm} | 12 +++++------ > Koha/IllbatchStatus.pm | 4 ++-- > Koha/Illrequest.pm | 6 +++--- > .../REST/V1/{Illbatches.pm => ILL/Batches.pm} | 18 ++++++++--------- > Koha/Schema/Result/Illbatch.pm | 4 ++-- > api/v1/swagger/paths/ill_batches.yaml | 10 +++++----- > ill/ill-requests.pl | 6 +++--- > t/db_dependent/IllbatchStatuses.t | 4 ++-- > .../Koha/{Illbatch.t => ILL/Batch.t} | 4 ++-- > .../{Illbatches.t => Koha/ILL/Batches.t} | 10 +++++----- > t/db_dependent/api/v1/ill_batches.t | 20 +++++++++---------- > 12 files changed, 55 insertions(+), 55 deletions(-) > rename Koha/{Illbatch.pm => ILL/Batch.pm} (95%) > rename Koha/{Illbatches.pm => ILL/Batches.pm} (82%) > rename Koha/REST/V1/{Illbatches.pm => ILL/Batches.pm} (86%) > rename t/db_dependent/Koha/{Illbatch.t => ILL/Batch.t} (91%) > rename t/db_dependent/{Illbatches.t => Koha/ILL/Batches.t} (94%) > >diff --git a/Koha/Illbatch.pm b/Koha/ILL/Batch.pm >similarity index 95% >rename from Koha/Illbatch.pm >rename to Koha/ILL/Batch.pm >index 31048670f6..cce981bc8c 100644 >--- a/Koha/Illbatch.pm >+++ b/Koha/ILL/Batch.pm >@@ -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 > >diff --git a/Koha/Illbatches.pm b/Koha/ILL/Batches.pm >similarity index 82% >rename from Koha/Illbatches.pm >rename to Koha/ILL/Batches.pm >index ee65a262d6..507b5a45e5 100644 >--- a/Koha/Illbatches.pm >+++ b/Koha/ILL/Batches.pm >@@ -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 >diff --git a/Koha/IllbatchStatus.pm b/Koha/IllbatchStatus.pm >index e098762f90..b5c26c72f4 100644 >--- a/Koha/IllbatchStatus.pm >+++ b/Koha/IllbatchStatus.pm >@@ -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; >diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm >index 8db53d30e3..471242c654 100644 >--- a/Koha/Illrequest.pm >+++ b/Koha/Illrequest.pm >@@ -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; >@@ -151,7 +151,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 > >@@ -160,7 +160,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 >diff --git a/Koha/REST/V1/Illbatches.pm b/Koha/REST/V1/ILL/Batches.pm >similarity index 86% >rename from Koha/REST/V1/Illbatches.pm >rename to Koha/REST/V1/ILL/Batches.pm >index b4e7d6aa02..0f932e3622 100644 >--- a/Koha/REST/V1/Illbatches.pm >+++ b/Koha/REST/V1/ILL/Batches.pm >@@ -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" } ); >diff --git a/Koha/Schema/Result/Illbatch.pm b/Koha/Schema/Result/Illbatch.pm >index d7e758cae7..a0c61a0a7e 100644 >--- a/Koha/Schema/Result/Illbatch.pm >+++ b/Koha/Schema/Result/Illbatch.pm >@@ -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; >diff --git a/api/v1/swagger/paths/ill_batches.yaml b/api/v1/swagger/paths/ill_batches.yaml >index 3d747be2a5..d7ea3a0b5c 100644 >--- a/api/v1/swagger/paths/ill_batches.yaml >+++ b/api/v1/swagger/paths/ill_batches.yaml >@@ -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 >diff --git a/ill/ill-requests.pl b/ill/ill-requests.pl >index a668b25979..3672e4932b 100755 >--- a/ill/ill-requests.pl >+++ b/ill/ill-requests.pl >@@ -27,7 +27,7 @@ use Koha::Notice::Templates; > use Koha::AuthorisedValues; > use Koha::Illcomment; > use Koha::Illrequests; >-use Koha::Illbatches; >+use Koha::ILL::Batches; > use Koha::Illrequest::Workflow::Availability; > use Koha::Illrequest::Workflow::TypeDisclaimer; > use Koha::Libraries; >@@ -224,7 +224,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} ) { >@@ -403,7 +403,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 > ); >diff --git a/t/db_dependent/IllbatchStatuses.t b/t/db_dependent/IllbatchStatuses.t >index 8748d73b56..771f7aaa0f 100755 >--- a/t/db_dependent/IllbatchStatuses.t >+++ b/t/db_dependent/IllbatchStatuses.t >@@ -191,7 +191,7 @@ 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, >@@ -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; >diff --git a/t/db_dependent/Koha/Illbatch.t b/t/db_dependent/Koha/ILL/Batch.t >similarity index 91% >rename from t/db_dependent/Koha/Illbatch.t >rename to t/db_dependent/Koha/ILL/Batch.t >index c18b686386..7d95e66df6 100755 >--- a/t/db_dependent/Koha/Illbatch.t >+++ b/t/db_dependent/Koha/ILL/Batch.t >@@ -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; >diff --git a/t/db_dependent/Illbatches.t b/t/db_dependent/Koha/ILL/Batches.t >similarity index 94% >rename from t/db_dependent/Illbatches.t >rename to t/db_dependent/Koha/ILL/Batches.t >index d0c465217a..8607eb3e9a 100755 >--- a/t/db_dependent/Illbatches.t >+++ b/t/db_dependent/Koha/ILL/Batches.t >@@ -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,7 +53,7 @@ my $branch = $builder->build( { source => 'Branch' } ); > # Create a batch > my $illbatch = $builder->build_object( > { >- class => 'Koha::Illbatches', >+ class => 'Koha::ILL::Batches', > value => { > name => "My test batch", > backend => "Mock", >diff --git a/t/db_dependent/api/v1/ill_batches.t b/t/db_dependent/api/v1/ill_batches.t >index aae636d829..bc8e2a514d 100755 >--- a/t/db_dependent/api/v1/ill_batches.t >+++ b/t/db_dependent/api/v1/ill_batches.t >@@ -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); >-- >2.30.2
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 35581
:
159863
|
159864
|
159865
|
159866
|
159867
|
159868
|
159869
|
159870
|
159871
|
159872
|
159873
|
160422
|
160423
|
160424
|
160425
|
160426
|
160427
|
160428
|
160429
|
160430
|
160431
|
160432
|
160620
|
160622
|
162020
|
162021
|
162022
|
162023
|
162024
|
162025
|
162026
|
162027
|
162028
|
162029
|
162030
|
162031
|
162032
|
162817
|
162818
|
162819
|
162820
|
162821
|
162822
|
162823
|
162824
|
162825
|
162826
|
162827
|
162828
|
162829
|
162880
|
162881
|
162882
|
162883
|
162884
|
162885
|
162886
|
162887
|
162888
|
162889
|
162890
|
162891
|
162892
|
163803
|
163804
|
163805
|
163806
|
163807
|
163808
|
163809
|
163810
|
163811
|
163812
|
163813
|
163814
|
163815
|
163816
|
164069
|
164070
|
164071
|
164072
|
164073
|
164074
|
164075
|
164076
|
164077
|
164078
|
164079
|
164080
|
164081
|
164082
|
165448