Bugzilla – Attachment 173213 Details for
Bug 30955
Send a notice to new owner when transferring shared list
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30955: Sends notice to new owner at transfer
Bug-30955-Sends-notice-to-new-owner-at-transfer.patch (text/plain), 9.39 KB, created by
Martin Renvoize (ashimema)
on 2024-10-23 13:31:03 UTC
(
hide
)
Description:
Bug 30955: Sends notice to new owner at transfer
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-10-23 13:31:03 UTC
Size:
9.39 KB
patch
obsolete
>From a1a50e9d7568d251e084d0ba41340f98c126630f Mon Sep 17 00:00:00 2001 >From: PerplexedTheta <jahdobble@llownd.net> >Date: Wed, 10 Jul 2024 16:18:26 +0100 >Subject: [PATCH] Bug 30955: Sends notice to new owner at transfer > >This patch adds a new notice, TRANSFER_OWNERSHIP, under a new module, >Lists. When a list is transferred to a new owner, this notice is >triggered, containing a short paragraph detailing the list name. > >TO TEST: >a) log in as a koha superlibrarian >b) go to the lists module, create a public list, and make a note of the > title used >c) on the lists module, transfer the list to some other user, and make > a note of the user used >d) go to the patron notices page for the user in step c >e) ensure that a notice has been generated > 1) check the contents of the notice, it should contain > - the new owner's name > - the list's title > - the old owner's name & (if set) email >f) under tools > notices, modify the notice for TRANSFER_OWNERSHIP >g) repeat steps c-e > 1) ensure the modifications you've made are now visible in the notice > >Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl> >Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Virtualshelf.pm | 37 ++++++++++++++++++- > .../mysql/en/mandatory/sample_notices.yml | 16 ++++++++ > .../prog/en/modules/tools/letter.tt | 7 ++++ > t/db_dependent/Koha/Virtualshelf.t | 27 +++++++++++++- > virtualshelves/shelves.pl | 2 +- > 5 files changed, 86 insertions(+), 3 deletions(-) > >diff --git a/Koha/Virtualshelf.pm b/Koha/Virtualshelf.pm >index 930c4d62394..1cb82a1c5cb 100644 >--- a/Koha/Virtualshelf.pm >+++ b/Koha/Virtualshelf.pm >@@ -360,8 +360,43 @@ sub transfer_ownership { > Koha::Exceptions::MissingParameter->throw("Mandatory parameter 'patron' missing") > unless $patron_id; > >+ ## before we change the owner, collect some details >+ my $old_owner = Koha::Patrons->find( $self->owner ); >+ my $new_owner = Koha::Patrons->find($patron_id); >+ my $library = $new_owner->library->unblessed; >+ >+ ## first we change the owner > $self->remove_share($patron_id) if $self->is_private; >- return $self->set( { owner => $patron_id } )->store; >+ $self->set( { owner => $patron_id } )->store; >+ >+ ## now we message the new owner >+ my $letter = C4::Letters::GetPreparedLetter( >+ module => 'lists', >+ letter_code => 'TRANSFER_OWNERSHIP', >+ branchcode => $library->{branchcode}, >+ lang => $new_owner->lang || 'default', >+ objects => { >+ old_owner => $old_owner, >+ new_owner => $new_owner, >+ shelf => $self, >+ }, >+ tables => { >+ 'branches' => $library->{branchcode}, >+ }, >+ message_transport_type => 'email', >+ ); >+ >+ if ($letter) { >+ my $message_id = C4::Letters::EnqueueLetter( >+ { >+ letter => $letter, >+ borrowernumber => $patron_id, >+ message_transport_type => 'email', >+ } >+ ) or warn "can't enqueue letter $letter"; >+ } >+ >+ return $self; > } > > =head2 Internal methods >diff --git a/installer/data/mysql/en/mandatory/sample_notices.yml b/installer/data/mysql/en/mandatory/sample_notices.yml >index ec0e2386dab..3354e24b30e 100644 >--- a/installer/data/mysql/en/mandatory/sample_notices.yml >+++ b/installer/data/mysql/en/mandatory/sample_notices.yml >@@ -1305,6 +1305,22 @@ tables: > - "[% branch.branchillemail %]" > - "[% branch.branchemail %]" > >+ - module: lists >+ code: TRANSFER_OWNERSHIP >+ branchcode: "" >+ name: "Transfer ownership" >+ is_html: 1 >+ title: "A list has been transferred to you" >+ message_transport_type: email >+ lang: default >+ content: >+ - "Dear [%- INCLUDE 'patron-title.inc' patron => new_owner -%],<br>" >+ - "<br>" >+ - "A public list, titled <em>[% shelf.shelfname | html %]</em>, has been transferred to you[% IF ( old_owner ) %] by [%- INCLUDE 'patron-title.inc' patron => old_owner%][% IF ( old_owner.email ) %] <em>([% old_owner.email | html %])</em>[% END %][% END %].<br>" >+ - "<br>" >+ - "Thank you<br>" >+ - "<br>" >+ > - module: members > code: DISCHARGE > branchcode: "" >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt >index d24fa422b3d..784d15d0f84 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt >@@ -194,6 +194,7 @@ > <li><a class="dropdown-item" href="/cgi-bin/koha/tools/letter.pl?op=add_form&module=claimissues">Claim serial issue</a></li> > <li><a class="dropdown-item" href="/cgi-bin/koha/tools/letter.pl?op=add_form&module=reserves">Holds</a></li> > <li><a class="dropdown-item" href="/cgi-bin/koha/tools/letter.pl?op=add_form&module=ill">Interlibrary loans</a></li> >+ <li><a class="dropdown-item" href="/cgi-bin/koha/tools/letter.pl?op=add_form&module=lists">Lists</a></li> > <li><a class="dropdown-item" href="/cgi-bin/koha/tools/letter.pl?op=add_form&module=orderacquisition">Order acquisition</a></li> > <li><a class="dropdown-item" href="/cgi-bin/koha/tools/letter.pl?op=add_form&module=members">Patrons</a></li> > <li><a class="dropdown-item" href="/cgi-bin/koha/tools/letter.pl?op=add_form&module=patron_slip">Patrons (custom slip)</a></li> >@@ -257,6 +258,7 @@ > [% CASE 'claimissues' %]<span>Claim serial issue</span> > [% CASE 'reserves' %]<span>Holds</span> > [% CASE 'ill' %]<span>Interlibrary loans</span> >+ [% CASE 'lists' %]<span>Lists</span> > [% CASE 'members' %]<span>Patrons</span> > [% CASE 'patron_slip' %]<span>Patrons (custom slip)</span> > [% CASE 'add_message' %]<span>Patrons (custom message)</span> >@@ -420,6 +422,11 @@ > [% IF ( module == "ill" ) %] > <option value="ill" selected="selected">Interlibrary loans</option> > [% ELSE %] >+ [% IF ( module == "lists" ) %] >+ <option value="lists" selected="selected">Lists</option> >+ [% ELSE %] >+ <option value="lists">Lists</option> >+ [% END %] > <option value="ill">Interlibrary loans</option> > [% END %] > [% IF ( module == "members" ) %] >diff --git a/t/db_dependent/Koha/Virtualshelf.t b/t/db_dependent/Koha/Virtualshelf.t >index af6c2e1b326..c7061cc7b96 100755 >--- a/t/db_dependent/Koha/Virtualshelf.t >+++ b/t/db_dependent/Koha/Virtualshelf.t >@@ -30,7 +30,7 @@ my $builder = t::lib::TestBuilder->new; > > subtest 'transfer_ownership() tests' => sub { > >- plan tests => 8; >+ plan tests => 13; > > $schema->storage->txn_begin; > >@@ -95,5 +95,30 @@ subtest 'transfer_ownership() tests' => sub { > is( $private_list_shares->count, 1, 'Count is correct' ); > is( $private_list_shares->next->borrowernumber, $patron_3->id, "Private lists get the share for the new owner removed" ); > >+ my %params; >+ my $mocked_letters = Test::MockModule->new('C4::Letters'); >+ $mocked_letters->mock( >+ 'GetPreparedLetter', >+ sub { >+ %params = @_; >+ return 1; >+ } >+ ); >+ $mocked_letters->mock( >+ 'EnqueueLetter', >+ sub { >+ return 1; >+ } >+ ); >+ >+ $public_list->transfer_ownership( $patron_1->id ); >+ $public_list->discard_changes; >+ >+ is( $params{module}, "lists", "Enqueued letter with module lists correctly" ); >+ is( $params{letter_code}, "TRANSFER_OWNERSHIP", "Enqueued letter with code TRANSFER_OWNERSHIP correctly" ); >+ is( $params{objects}->{old_owner}->borrowernumber, $patron_2->borrowernumber, "old_owner passed to enqueue letter correctly" ); >+ is( $params{objects}->{new_owner}->borrowernumber, $patron_1->borrowernumber, "new_owner passed to enqueue letter correctly" ); >+ is( $params{objects}->{shelf}->shelfnumber, $public_list->shelfnumber, "shelf passed to enqueue letter correctly" ); >+ > $schema->storage->txn_rollback; > }; >diff --git a/virtualshelves/shelves.pl b/virtualshelves/shelves.pl >index e3e7a868e41..c60038fddd4 100755 >--- a/virtualshelves/shelves.pl >+++ b/virtualshelves/shelves.pl >@@ -266,7 +266,7 @@ if ( $op eq 'add_form' ) { > push @messages, { type => 'error', code => $error_code }; > $op = 'list'; > } else { >- $shelf->owner($new_owner)->store; >+ $shelf->transfer_ownership($new_owner); > $op = 'list'; > } > } >-- >2.47.0
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 30955
:
168970
|
169252
|
169267
|
170748
|
170826
|
172443
|
172445
|
173213
|
173214
|
173215
|
173216
|
173254
|
173255