Bug 40850: (follow-up) Use add_or_update_attributes in copyright clearance methods

This patch simplifies the set_copyright_clearance_confirmed() method
to use the new add_or_update_attributes() method instead of custom
update/create logic.

Benefits:
- Reduces code complexity from 20+ lines to 6 lines
- Eliminates duplicate update/create logic
- Uses the new standardized method for attribute management
- Maintains all existing functionality and test coverage

Test plan:
1. Apply patch
2. Run:
   $ ktd --shell
  k$ prove t/db_dependent/Koha/ILL/Request.t
=> SUCCESS: Tests pass! Copyright clearance methods work with new implementation
3. Test copyright clearance workflow still works in ILL module
4. Sign off :-D

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Tomás Cohen Arazi 2025-09-22 15:16:12 -03:00 committed by Lucas Gass
parent 4753b73285
commit ea3065aeef
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 2 additions and 18 deletions

View File

@ -1319,25 +1319,9 @@ sub set_copyright_clearance_confirmed {
# Normalize to boolean: 0 or 1
my $value = $confirmed ? 1 : 0;
# Check if attribute already exists
my $existing_attr = $self->extended_attributes->find( { type => 'copyrightclearance_confirmed' } );
$self->add_or_update_attributes( { copyrightclearance_confirmed => $value } );
if ($existing_attr) {
# Update existing attribute
$existing_attr->value($value)->store;
} else {
# Create new attribute
$self->extended_attributes(
[
{
type => 'copyrightclearance_confirmed',
value => $value,
}
]
);
}
return $self;
}
=head3 add_or_update_attributes