Bug 11943: Prevent double accepts in Koha::Virtualshelfshare
This 'bug' existed long enough now to finally remove it ;)
We do so by deleting the invitation if the borrower already has a share
on this list. Actually not that hard.
We still need: a unit test and a db revision.
Test plan:
[1] Share a list. Let user B accept.
[2] Without this patch: Share again and let B accept again.
[3] Verify that you have two shares for this list in virtualshelfshares.
[4] With this patch: Share another list, let B accept.
[5] Share this other list again, let B accept again.
[6] Verify that virtualshelfshares does not contain double entries now.
(Note: This pertains to the second list only.)
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
7ecc125786
commit
5a185e0d1a
|
|
@ -51,10 +51,20 @@ sub accept {
|
|||
if ( $self->invitekey ne $invitekey ) {
|
||||
Koha::Exceptions::Virtualshelves::InvalidInviteKey->throw;
|
||||
}
|
||||
$self->invitekey(undef);
|
||||
$self->sharedate(dt_from_string);
|
||||
$self->borrowernumber($borrowernumber);
|
||||
$self->store;
|
||||
|
||||
# If this borrower already has a share, there is no need to accept twice
|
||||
# We solve this by 'pretending' to reaccept, but delete instead
|
||||
my $search = Koha::Virtualshelfshares->search({ shelfnumber => $self->shelfnumber, borrowernumber => $borrowernumber, invitekey => undef });
|
||||
if( $search->count ) {
|
||||
$self->delete;
|
||||
return $search->next;
|
||||
} else {
|
||||
$self->invitekey(undef);
|
||||
$self->sharedate(dt_from_string);
|
||||
$self->borrowernumber($borrowernumber);
|
||||
$self->store;
|
||||
return $self;
|
||||
}
|
||||
}
|
||||
|
||||
sub has_expired {
|
||||
|
|
|
|||
Loading…
Reference in New Issue