View | Details | Raw Unified | Return to bug 39600
Collapse All | Expand All

(-)a/Koha/ILL/Request.pm (-3 / +5 lines)
Lines 2143-2151 This method returns the list of publicly readable database fields for both API a Link Here
2143
=cut
2143
=cut
2144
2144
2145
sub public_read_list {
2145
sub public_read_list {
2146
    return [qw(
2146
    return [
2147
        illrequest_id backend status extended_attributes placed updated
2147
        qw(
2148
    )];
2148
            illrequest_id backend status extended_attributes placed updated
2149
        )
2150
    ];
2149
}
2151
}
2150
2152
2151
=head2 Internal methods
2153
=head2 Internal methods
(-)a/Koha/ILL/Request/Attribute.pm (+6 lines)
Lines 58-63 sub request { Link Here
58
    return Koha::ILL::Request->_new_from_dbic( $self->_result->illrequest );
58
    return Koha::ILL::Request->_new_from_dbic( $self->_result->illrequest );
59
}
59
}
60
60
61
=head3 public_read_list
62
63
This method returns the list of publicly readable database fields for both API and UI output purposes
64
65
=cut
66
61
sub public_read_list {
67
sub public_read_list {
62
    return [qw(backend illrequest_id readonly type value)];
68
    return [qw(backend illrequest_id readonly type value)];
63
}
69
}
(-)a/Koha/REST/V1/ILL/Requests.pm (-7 / +15 lines)
Lines 58-79 sub list { Link Here
58
    };
58
    };
59
}
59
}
60
60
61
=head3 patron_list
62
63
Controller function that handles listing Koha::ILL::Request objects for a given patron.
64
65
The patron must match the requesting user unless the requesting user is a superlibrarian.
66
67
This is a public route, so some request details are omitted.
68
69
=cut
70
61
sub patron_list {
71
sub patron_list {
62
    my $c = shift->openapi->valid_input or return;
72
    my $c    = shift->openapi->valid_input or return;
63
    my $user = $c->stash('koha.user');
73
    my $user = $c->stash('koha.user');
64
    $c->stash(is_public => 1);
74
    $c->stash( is_public => 1 );
65
75
66
    if ($user->borrowernumber != $c->param('patron_id') and !$user->is_superlibrarian) {
76
    if ( $user->borrowernumber != $c->param('patron_id') and !$user->is_superlibrarian ) {
67
        return $c->render(
77
        return $c->render(
68
            status => 403,
78
            status  => 403,
69
            openapi => { error => "Cannot lookup ILL requests for other users" }
79
            openapi => { error => "Cannot lookup ILL requests for other users" }
70
        );
80
        );
71
    }
81
    }
72
82
73
    return try {
83
    return try {
74
        my $reqs = $c->objects->search(Koha::ILL::Requests->search(
84
        my $reqs = $c->objects->search( Koha::ILL::Requests->search( { borrowernumber => $c->param('patron_id') } ) );
75
            { borrowernumber => $c->param('patron_id') }
76
        ));
77
85
78
        return $c->render(
86
        return $c->render(
79
            status  => 200,
87
            status  => 200,
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt (-3 / +2 lines)
Lines 151-158 Link Here
151
                                        <th class="no-sort"></th>
151
                                        <th class="no-sort"></th>
152
                                    </tr>
152
                                    </tr>
153
                                </thead>
153
                                </thead>
154
                                <tbody>
154
                                <tbody> </tbody>
155
                                </tbody>
156
                            </table>
155
                            </table>
157
                        [% ELSIF op == 'view' %]
156
                        [% ELSIF op == 'view' %]
158
                            <h1>View interlibrary loan request</h1>
157
                            <h1>View interlibrary loan request</h1>
Lines 445-451 Link Here
445
            "serverSide": true,
444
            "serverSide": true,
446
            "ajax": {
445
            "ajax": {
447
                "cache": true,
446
                "cache": true,
448
                "url": '/api/v1/patrons/[% logged_in_user.borrowernumber %]/ill/requests',
447
                "url": '/api/v1/patrons/[% logged_in_user.borrowernumber | html %]/ill/requests',
449
                'beforeSend': function (xhr, settings) {
448
                'beforeSend': function (xhr, settings) {
450
                    this._xhr = xhr;
449
                    this._xhr = xhr;
451
                    xhr.setRequestHeader('x-koha-embed', '+strings,extended_attributes');
450
                    xhr.setRequestHeader('x-koha-embed', '+strings,extended_attributes');
(-)a/opac/opac-illrequests.pl (+1 lines)
Lines 99-104 if ( $op eq 'list' ) { Link Here
99
    $template->param( request => $request );
99
    $template->param( request => $request );
100
} elsif ( $op eq 'cud-update' ) {
100
} elsif ( $op eq 'cud-update' ) {
101
    $request->notesopac( $params->{notesopac} )->store;
101
    $request->notesopac( $params->{notesopac} )->store;
102
102
    # Send a notice to staff alerting them of the update
103
    # Send a notice to staff alerting them of the update
103
    $request->send_staff_notice('ILL_REQUEST_MODIFIED');
104
    $request->send_staff_notice('ILL_REQUEST_MODIFIED');
104
    print $query->redirect(
105
    print $query->redirect(
(-)a/t/db_dependent/api/v1/ill_requests.t (-9 / +13 lines)
Lines 310-319 subtest 'patron_list() tests' => sub { Link Here
310
    my $observer_number = $observer->borrowernumber;
310
    my $observer_number = $observer->borrowernumber;
311
311
312
    # No requests yet, expect empty for both
312
    # No requests yet, expect empty for both
313
    $t->get_ok("//$requester_userid:$password@/api/v1/patrons/$requester_number/ill/requests")->status_is(200)->json_is( [] );
313
    $t->get_ok("//$requester_userid:$password@/api/v1/patrons/$requester_number/ill/requests")->status_is(200)
314
    $t->get_ok("//$observer_userid:$password@/api/v1/patrons/$observer_number/ill/requests")->status_is(200)->json_is( [] );
314
        ->json_is( [] );
315
    $t->get_ok("//$observer_userid:$password@/api/v1/patrons/$observer_number/ill/requests")->status_is(200)
316
        ->json_is( [] );
315
317
316
    for (0..25) {
318
    for ( 0 .. 25 ) {
317
        $builder->build_object(
319
        $builder->build_object(
318
            {
320
            {
319
                class => 'Koha::ILL::Requests',
321
                class => 'Koha::ILL::Requests',
Lines 329-345 subtest 'patron_list() tests' => sub { Link Here
329
    }
331
    }
330
332
331
    # Other user should not see anything
333
    # Other user should not see anything
332
    $t->get_ok("//$observer_userid:$password@/api/v1/patrons/$observer_number/ill/requests")->status_is(200)->json_is( [] );
334
    $t->get_ok("//$observer_userid:$password@/api/v1/patrons/$observer_number/ill/requests")->status_is(200)
335
        ->json_is( [] );
333
336
334
    # Staff notes hidden in the public API
337
    # Staff notes hidden in the public API
335
    $t->get_ok("//$requester_userid:$password@/api/v1/patrons/$requester_number/ill/requests")->status_is(200)->json_is(
338
    $t->get_ok("//$requester_userid:$password@/api/v1/patrons/$requester_number/ill/requests")->status_is(200)
339
        ->json_is(
336
        '/0/staff_notes' => undef,
340
        '/0/staff_notes' => undef,
337
    );
341
        );
338
342
339
    # Not all requests get returned, pagination works
343
    # Not all requests get returned, pagination works
340
    $t->get_ok("//$requester_userid:$password@/api/v1/patrons/$requester_number/ill/requests")->status_is(200)->json_is(
344
    $t->get_ok("//$requester_userid:$password@/api/v1/patrons/$requester_number/ill/requests")->status_is(200)
345
        ->json_is(
341
        '/21' => undef,
346
        '/21' => undef,
342
    );
347
        );
343
348
344
    $schema->storage->txn_rollback;
349
    $schema->storage->txn_rollback;
345
};
350
};
346
- 

Return to bug 39600