<tr>
<th>Name</th>
<th>Patrons in list</th>
+ <th>Shared</th>
<th class="NoSort"> </th>
</tr>
</thead>
<tbody>
[% FOREACH l IN lists %]
+ [% SET shared_by_other = l.owner.id != logged_in_user %]
<tr>
<td><a href="/cgi-bin/koha/patron_lists/list.pl?patron_list_id=[% l.patron_list_id %]">[% l.name |html%]</a></td>
<td>[% l.patron_list_patrons_rs.count || 0 %]</td>
<td>
+ [% IF l.shared %]
+ [% IF shared_by_other %]
+ by <a href=/cgi-bin/koha/members/moremember.pl?borrowernumber=[% l.owner.id %]">[% INCLUDE 'patron-title.inc' patron=l.owner %]</a>
+ [% ELSE %]
+ by you
+ [% END %]
+ [% END %]
+ </td>
+ <td>
<div class="dropdown">
<a class="btn btn-default btn-xs dropdown-toggle" id="listactions[% l.patron_list_id %]" role="button" data-toggle="dropdown" href="#">
Actions <b class="caret"></b>
</a>
<ul class="dropdown-menu pull-right" role="menu" aria-labelledby="listactions[% l.patron_list_id %]">
<li><a href="/cgi-bin/koha/patron_lists/list.pl?patron_list_id=[% l.patron_list_id %]"><i class="fa fa-user"></i> Add patrons</a></li>
- <li><a href="/cgi-bin/koha/patron_lists/add-modify.pl?patron_list_id=[% l.patron_list_id %]"><i class="fa fa-pencil"></i> Edit list</a></li>
- <li><a class="delete_patron" href="/cgi-bin/koha/patron_lists/delete.pl?patron_list_id=[% l.patron_list_id %]" data-list-name="[% l.name %]"><i class="fa fa-trash"></i> Delete list</a></li>
+ [% UNLESS shared_by_other %]
+ <li><a href="/cgi-bin/koha/patron_lists/add-modify.pl?patron_list_id=[% l.patron_list_id %]"><i class="fa fa-pencil"></i> Edit list</a></li>
+ <li><a class="delete_patron" href="/cgi-bin/koha/patron_lists/delete.pl?patron_list_id=[% l.patron_list_id %]" data-list-name="[% l.name %]"><i class="fa fa-trash"></i> Delete list</a></li>
+ [% END %]
[% IF ( l.patron_list_patrons_rs.count ) %]
<li class="divider"></li>
<li>
my $id = $cgi->param('patron_list_id');
my $name = $cgi->param('name');
+my $shared = $cgi->param('shared') ? 1 : 0;
if ($id) {
my ($list) = GetPatronLists( { patron_list_id => $id } );
if ($name) {
if ($id) {
- ModPatronList( { patron_list_id => $id, name => $name } );
+ ModPatronList( { patron_list_id => $id, name => $name, shared => $shared } );
print $cgi->redirect('lists.pl');
}
else {
- my $list = AddPatronList( { name => $name } );
+ my $list = AddPatronList( { name => $name, shared => $shared } );
print $cgi->redirect(
"list.pl?patron_list_id=" . $list->patron_list_id() );
}
use Modern::Perl;
-use Test::More tests => 7;
+use Test::More tests => 9;
use t::lib::TestBuilder;
use Koha::Database;
push @borrowers, $builder->build({ source => 'Borrower' });
}
-my $owner = $borrowers[0]->{borrowernumber};
+my $owner = $borrowers[0]->{borrowernumber};
+my $owner2 = $borrowers[1]->{borrowernumber};
my @lists = GetPatronLists( { owner => $owner } );
my $list_count_original = @lists;
my $list1 = AddPatronList( { name => 'Test List 1', owner => $owner } );
-ok( $list1->name() eq 'Test List 1', 'AddPatronList works' );
+is( $list1->name(), 'Test List 1', 'AddPatronList works' );
my $list2 = AddPatronList( { name => 'Test List 2', owner => $owner } );
}
);
$list2->discard_changes();
-ok( $list2->name() eq 'Test List 3', 'ModPatronList works' );
+is( $list2->name(), 'Test List 3', 'ModPatronList works' );
AddPatronsToList(
{ list => $list1, cardnumbers => [ map { $_->{cardnumber} } @borrowers ] }
);
-ok(
- scalar @borrowers ==
+is(
+ scalar @borrowers,
$list1->patron_list_patrons()->search_related('borrowernumber')->all(),
'AddPatronsToList works for cardnumbers'
);
borrowernumbers => [ map { $_->{borrowernumber} } @borrowers ]
}
);
-ok(
- scalar @borrowers ==
+is(
+ scalar @borrowers,
$list2->patron_list_patrons()->search_related('borrowernumber')->all(),
'AddPatronsToList works for borrowernumbers'
);
}
);
$list1->discard_changes();
-ok( !$list1->patron_list_patrons()->count(), 'DelPatronsFromList works.' );
+is( $list1->patron_list_patrons()->count(), 0, 'DelPatronsFromList works.' );
@lists = GetPatronLists( { owner => $owner } );
-ok( @lists == $list_count_original + 2, 'GetPatronLists works' );
+is( scalar @lists, $list_count_original + 2, 'GetPatronLists works' );
+
+my $list3 = AddPatronList( { name => 'Test List 3', owner => $owner2, shared => 0 } );
+@lists = GetPatronLists( { owner => $owner } );
+is( scalar @lists, $list_count_original + 2, 'GetPatronLists does not return non-shared list' );
+
+my $list4 = AddPatronList( { name => 'Test List 4', owner => $owner2, shared => 1 } );
+@lists = GetPatronLists( { owner => $owner } );
+is( scalar @lists, $list_count_original + 3, 'GetPatronLists does return shared list' );
DelPatronList( { patron_list_id => $list1->patron_list_id(), owner => $owner } );
DelPatronList( { patron_list_id => $list2->patron_list_id(), owner => $owner } );
@lists =
GetPatronLists( { patron_list_id => $list1->patron_list_id(), owner => $owner } );
-ok( !@lists, 'DelPatronList works' );
+is( scalar @lists, 0, 'DelPatronList works' );
$schema->storage->txn_rollback;