Bugzilla – Attachment 43403 Details for
Bug 14544
Move the list related code to Koha::Virtualshelves
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14544: allow_delete_own == 0 could represent a read-only list
Bug-14544-allowdeleteown--0-could-represent-a-read.patch (text/plain), 5.94 KB, created by
Jonathan Druart
on 2015-10-14 14:11:03 UTC
(
hide
)
Description:
Bug 14544: allow_delete_own == 0 could represent a read-only list
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2015-10-14 14:11:03 UTC
Size:
5.94 KB
patch
obsolete
>From 5025420992a0feec8e757e2a9f49a23266e90c26 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 14 Oct 2015 15:09:33 +0100 >Subject: [PATCH] Bug 14544: allow_delete_own == 0 could represent a read-only > list > >This patch reintroduces the previous behavior. >--- > Koha/Virtualshelf.pm | 5 ++--- > .../intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt | 1 + > koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt | 2 +- > t/db_dependent/Virtualshelves.t | 13 +++++-------- > 4 files changed, 9 insertions(+), 12 deletions(-) > >diff --git a/Koha/Virtualshelf.pm b/Koha/Virtualshelf.pm >index 7ce2738..6253e33 100644 >--- a/Koha/Virtualshelf.pm >+++ b/Koha/Virtualshelf.pm >@@ -192,7 +192,7 @@ sub remove_biblios { > > my $number_removed = 0; > for my $biblionumber ( @$biblionumbers ) { >- if ( $self->owner == $borrowernumber or $self->allow_delete_own ) { >+ if ( $self->allow_delete_own ) { > $number_removed += $self->get_contents->search( > { > biblionumber => $biblionumber, >@@ -267,8 +267,7 @@ sub can_biblios_be_removed { > > return 1 > if $borrowernumber >- and ( $self->owner == $borrowernumber >- or $self->allow_delete_own >+ and ( $self->allow_delete_own > or $self->allow_delete_other ); > return 0; > } >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >index 59ffa65..c36a183 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >@@ -609,6 +609,7 @@ function placeHold () { > <div class="help"><ul> > <li><b>Private list:</b> Is managed by you and can be seen only by you.</li> > <li><b>Public list:</b> Can be seen by everybody, but managed only by you.</li> >+ <li>The owner of a list is always allowed to add entries, but needs permission to remove.</li> > </ul> > </div> > </div> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt >index 113c056..cadce37 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt >@@ -17,7 +17,7 @@ > [% IF shelf.allow_add %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %] > [% IF shelf.allow_add %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %] > </select> >- <span>anyone else to add entries.</span> >+ <span>anyone else to add entries. (The owner of a list is always allowed to add entries, but needs permission to remove.)</span> > </li> > <li> > <label> </label> >diff --git a/t/db_dependent/Virtualshelves.t b/t/db_dependent/Virtualshelves.t >index 42c7ea9..7051ecb 100644 >--- a/t/db_dependent/Virtualshelves.t >+++ b/t/db_dependent/Virtualshelves.t >@@ -12,12 +12,10 @@ use Koha::Virtualshelfcontents; > > use t::lib::TestBuilder; > >+my $builder = t::lib::TestBuilder->new; > my $dbh = C4::Context->dbh; >-$dbh->{AutoCommit} = 0; > teardown(); > >-my $builder = t::lib::TestBuilder->new; >- > subtest 'CRUD' => sub { > plan tests => 13; > my $patron = $builder->build({ >@@ -207,10 +205,9 @@ subtest 'Shelf content' => sub { > $shelf->allow_delete_own(0); > $shelf->store; > $number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio2->{biblionumber} ], borrowernumber => $patron1->{borrowernumber} } ); >- is( $number_of_deleted_biblios, 1, ); >+ is( $number_of_deleted_biblios, 0, 'A patron is not allowed to delete his own content if allow_delete_own=0, even if he is the owner of the list'); > $number_of_contents = Koha::Virtualshelfcontents->search->count; >- is( $number_of_contents, 0, 'The biblio should have been deleted to the shelf by the patron, it is his own content (allow_delete_own=0)' ); >- $shelf->add_biblio( $biblio2->{biblionumber}, $patron1->{borrowernumber} ); >+ is( $number_of_contents, 1, 'The biblio should not have been deleted to the shelf by the patron, it is his own content (allow_delete_own=0)' ); > > # allow_add = 1, allow_delete_own = 1 > $shelf->allow_add(1); >@@ -273,7 +270,7 @@ subtest 'Shelf permissions' => sub { > is( $public_shelf->can_biblios_be_added( $patron1->{borrowernumber} ), 1, 'The owner should be able to add biblios to his list' ); > is( $public_shelf->can_biblios_be_added( $patron2->{borrowernumber} ), 0, 'Public list should not be modified (add) by someone else' ); > >- is( $public_shelf->can_biblios_be_removed( $patron1->{borrowernumber} ), 1, 'The owner should be able to remove biblios to his list' ); >+ is( $public_shelf->can_biblios_be_removed( $patron1->{borrowernumber} ), 0, 'The owner not should be able to remove biblios to his list' ); > is( $public_shelf->can_biblios_be_removed( $patron2->{borrowernumber} ), 0, 'Public list should not be modified (remove) by someone else' ); > > >@@ -320,7 +317,7 @@ subtest 'Shelf permissions' => sub { > is( $private_shelf->can_biblios_be_added( $patron1->{borrowernumber} ), 1, 'The owner should be able to add biblios to his list' ); > is( $private_shelf->can_biblios_be_added( $patron2->{borrowernumber} ), 0, 'Private list should not be modified (add) by someone else' ); > >- is( $private_shelf->can_biblios_be_removed( $patron1->{borrowernumber} ), 1, 'The owner should be able to remove biblios to his list' ); >+ is( $private_shelf->can_biblios_be_removed( $patron1->{borrowernumber} ), 0, 'The owner should not be able to remove biblios to his list' ); > is( $private_shelf->can_biblios_be_removed( $patron2->{borrowernumber} ), 0, 'Private list should not be modified (remove) by someone else' ); > > >-- >2.1.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 14544
:
41034
|
41035
|
41036
|
41037
|
41038
|
41039
|
41040
|
41041
|
41042
|
41403
|
41404
|
41405
|
41406
|
41407
|
41408
|
41409
|
41410
|
41411
|
41412
|
41584
|
41585
|
41586
|
41587
|
41588
|
41589
|
41590
|
41591
|
41592
|
41593
|
41594
|
41595
|
41596
|
41597
|
41598
|
41599
|
41600
|
41601
|
41716
|
41717
|
41718
|
41719
|
41720
|
41721
|
41722
|
41723
|
41724
|
41725
|
41726
|
41727
|
41728
|
41729
|
41730
|
41731
|
41732
|
41733
|
41766
|
41909
|
41910
|
41913
|
41914
|
41915
|
41917
|
41918
|
41919
|
41924
|
41927
|
41931
|
41932
|
41953
|
41954
|
41955
|
41956
|
41957
|
41958
|
41959
|
41960
|
41961
|
41962
|
41963
|
41964
|
41965
|
41966
|
41967
|
41968
|
41969
|
41970
|
41973
|
41974
|
41975
|
41976
|
41977
|
41978
|
41979
|
41980
|
41981
|
41982
|
41983
|
41986
|
41988
|
42192
|
42199
|
42200
|
42201
|
42202
|
42203
|
42204
|
42205
|
42206
|
42207
|
42208
|
42209
|
42210
|
42211
|
42212
|
42213
|
42214
|
42215
|
42216
|
42217
|
42218
|
42219
|
42638
|
43223
|
43224
|
43225
|
43226
|
43227
|
43228
|
43229
|
43230
|
43231
|
43232
|
43233
|
43234
|
43235
|
43236
|
43237
|
43238
|
43239
|
43240
|
43241
|
43242
|
43243
|
43296
|
43334
|
43335
|
43403
|
43456
|
43457
|
43458
|
43459
|
43460
|
43461
|
43462
|
43463
|
43464
|
43465
|
43466
|
43467
|
43469
|
43470
|
43471
|
43472
|
43473
|
43474
|
43475
|
43476
|
43477
|
43478
|
43479
|
43480
|
43481
|
43482
|
43485
|
43486
|
43487
|
44467
|
44468
|
44469
|
44470
|
44471
|
44472
|
44473
|
44474
|
44475
|
44476
|
44477
|
44478
|
44479
|
44480
|
44481
|
44482
|
44483
|
44484
|
44485
|
44486
|
44487
|
44758
|
44845
|
44852
|
44863
|
44872