From 127502dc7e692b871a5682b3e30e343f0827ca24 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 30 Jan 2023 12:57:32 -0300 Subject: [PATCH] Bug 31095: DBIC additions and relation name tweak Signed-off-by: Tomas Cohen Arazi (cherry picked from commit ebb3eac6a142d649df7bb900a7dcffed84090f66) Signed-off-by: Matt Blenkinsop --- Koha/Patron.pm | 2 +- Koha/Schema/Result/Borrower.pm | 7 +++++++ Koha/Schema/Result/BorrowerDebarment.pm | 7 ++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 26aa414f71..e027e0ce19 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -1268,7 +1268,7 @@ Returns the patron restrictions. sub restrictions { my ($self) = @_; - my $restrictions_rs = $self->_result->borrower_debarments; + my $restrictions_rs = $self->_result->restrictions; return Koha::Patron::Restrictions->_new_from_dbic($restrictions_rs); } diff --git a/Koha/Schema/Result/Borrower.pm b/Koha/Schema/Result/Borrower.pm index f32bb51afd..c8f4f32dd2 100644 --- a/Koha/Schema/Result/Borrower.pm +++ b/Koha/Schema/Result/Borrower.pm @@ -2061,6 +2061,13 @@ __PACKAGE__->many_to_many("permissions", "user_permissions", "permission"); # Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-11-10 17:43:30 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:5hh2lGCcKclyTnY7KNPkvg +__PACKAGE__->has_many( + "restrictions", + "Koha::Schema::Result::BorrowerDebarment", + { "foreign.borrowernumber" => "self.borrowernumber" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + __PACKAGE__->has_many( "extended_attributes", "Koha::Schema::Result::BorrowerAttribute", diff --git a/Koha/Schema/Result/BorrowerDebarment.pm b/Koha/Schema/Result/BorrowerDebarment.pm index 9c025284e5..da2b141328 100644 --- a/Koha/Schema/Result/BorrowerDebarment.pm +++ b/Koha/Schema/Result/BorrowerDebarment.pm @@ -165,6 +165,11 @@ __PACKAGE__->belongs_to( # Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-08-19 17:53:04 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:kDCkA7XrjKXlrFG5lk8Lgg +sub koha_objects_class { + 'Koha::Patron::Restrictions'; +} +sub koha_object_class { + 'Koha::Patron::Restriction'; +} -# You can replace this text with custom code or comments, and it will be preserved on regeneration 1; -- 2.39.5