Bugzilla – Attachment 140081 Details for
Bug 31503
Allow several consent types on the consents tab of OPAC account page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31503: Add $patron->consent
Bug-31503-Add-patron-consent.patch (text/plain), 3.02 KB, created by
Marcel de Rooy
on 2022-09-02 08:02:21 UTC
(
hide
)
Description:
Bug 31503: Add $patron->consent
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2022-09-02 08:02:21 UTC
Size:
3.02 KB
patch
obsolete
>From 5057f0c2d779b87816ee16716af1cf06fbfd1c5a Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 1 Sep 2022 08:25:20 +0000 >Subject: [PATCH] Bug 31503: Add $patron->consent >Content-Type: text/plain; charset=utf-8 > >Test plan: >Run t/db_dependent/Koha/Patron.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/Patron.pm | 23 +++++++++++++++++++++++ > t/db_dependent/Koha/Patron.t | 21 ++++++++++++++++++++- > 2 files changed, 43 insertions(+), 1 deletion(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 8031257304..358f9241aa 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -43,6 +43,7 @@ use Koha::CurbsidePickups; > use Koha::Old::Checkouts; > use Koha::Patron::Attributes; > use Koha::Patron::Categories; >+use Koha::Patron::Consents; > use Koha::Patron::Debarments; > use Koha::Patron::HouseboundProfile; > use Koha::Patron::HouseboundRole; >@@ -2196,6 +2197,28 @@ sub virtualshelves { > return Koha::Virtualshelves->_new_from_dbic( scalar $self->_result->virtualshelves ); > } > >+=head3 consent >+ >+ my $consent = $patron->consent(TYPE); >+ >+ Returns the first consent of type TYPE (there should be only one) or a new instance >+ of Koha::Patron::Consent. >+ >+=cut >+ >+sub consent { >+ my ( $self, $type ) = @_; >+ Koha::Exceptions::MissingParameter->throw('Missing consent type') >+ if !$type; >+ my $consents = Koha::Patron::Consents->search({ >+ borrowernumber => $self->borrowernumber, >+ type => $type, >+ }); >+ return $consents && $consents->count >+ ? $consents->next >+ : Koha::Patron::Consent->new({ borrowernumber => $self->borrowernumber, type => $type }); >+} >+ > =head2 Internal methods > > =head3 _type >diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t >index 977ec261d6..1d65f8e919 100755 >--- a/t/db_dependent/Koha/Patron.t >+++ b/t/db_dependent/Koha/Patron.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 18; >+use Test::More tests => 19; > use Test::Exception; > use Test::Warn; > >@@ -28,6 +28,7 @@ use Koha::Database; > use Koha::DateUtils qw(dt_from_string); > use Koha::ArticleRequests; > use Koha::Patrons; >+use Koha::Patron::Consents; > use Koha::Patron::Relationships; > > use t::lib::TestBuilder; >@@ -1292,3 +1293,21 @@ subtest 'encode_secret and decoded_secret' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'test patron_consent' => sub { >+ plan tests => 4; >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ throws_ok { $patron->consent } 'Koha::Exceptions::MissingParameter', 'missing type'; >+ >+ my $consent = $patron->consent('GDPR_PROCESSING'); >+ is( ref $consent, 'Koha::Patron::Consent', 'return type check' ); >+ $consent->given_on( '2021-02-03' )->store; >+ undef $consent; >+ is( $patron->consent('GDPR_PROCESSING')->given_on, '2021-02-03 00:00:00', 'check date' ); >+ >+ is( $patron->consent('NOT_EXIST')->refused_on, undef, 'New empty object for new type' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.20.1
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 31503
:
140047
|
140048
|
140049
|
140050
|
140080
|
140081
|
140082
|
140083
|
140084
|
140085
|
140087
|
140088
|
140089
|
140090
|
140666
|
140667
|
140668
|
140669
|
140670
|
140671
|
140672
|
141216
|
141217
|
141218
|
141219
|
141220
|
141221
|
141222
|
141263
|
141264
|
141265
|
141266
|
141267
|
141268
|
141269
|
141302
|
141570
|
155000
|
155001
|
155002
|
155003
|
155177
|
155178
|
155179
|
155180
|
155189
|
155190
|
155191
|
155656
|
155657
|
155658
|
155659
|
155660
|
155661
|
155691
|
155694
|
155783
|
155784
|
155785
|
155786
|
155787
|
155788
|
155789
|
155790
|
155791
|
157117
|
157118
|
157119
|
157120
|
157121
|
157122
|
157123
|
157124
|
157125
|
157126
|
157773
|
157774
|
157775
|
157776
|
157777
|
157778
|
157779
|
157780
|
157781
|
157782
|
157783