|
Lines 40-50
sub list {
Link Here
|
| 40 |
my $can_manage_background_jobs = |
40 |
my $can_manage_background_jobs = |
| 41 |
$patron->has_permission( { parameters => 'manage_background_jobs' } ); |
41 |
$patron->has_permission( { parameters => 'manage_background_jobs' } ); |
| 42 |
|
42 |
|
| 43 |
my $background_jobs_set = |
43 |
my $background_jobs_set = Koha::BackgroundJobs->search; |
| 44 |
$can_manage_background_jobs |
|
|
| 45 |
? Koha::BackgroundJobs->new |
| 46 |
: Koha::BackgroundJobs->search( |
| 47 |
{ borrowernumber => $patron->borrowernumber } ); |
| 48 |
|
44 |
|
| 49 |
my $background_jobs = $c->objects->search( $background_jobs_set ); |
45 |
my $background_jobs = $c->objects->search( $background_jobs_set ); |
| 50 |
return $c->render( status => 200, openapi => $background_jobs ); |
46 |
return $c->render( status => 200, openapi => $background_jobs ); |
|
Lines 61-70
sub get {
Link Here
|
| 61 |
return try { |
57 |
return try { |
| 62 |
|
58 |
|
| 63 |
my $background_job_id = $c->validation->param('background_job_id'); |
59 |
my $background_job_id = $c->validation->param('background_job_id'); |
| 64 |
my $patron = $c->stash('koha.user'); |
|
|
| 65 |
|
| 66 |
my $can_manage_background_jobs = |
| 67 |
$patron->has_permission( { parameters => 'manage_background_jobs' } ); |
| 68 |
|
60 |
|
| 69 |
my $background_job = Koha::BackgroundJobs->find($background_job_id); |
61 |
my $background_job = Koha::BackgroundJobs->find($background_job_id); |
| 70 |
|
62 |
|
|
Lines 73-85
sub get {
Link Here
|
| 73 |
openapi => { error => "Object not found" } |
65 |
openapi => { error => "Object not found" } |
| 74 |
) unless $background_job; |
66 |
) unless $background_job; |
| 75 |
|
67 |
|
| 76 |
return $c->render( |
|
|
| 77 |
status => 403, |
| 78 |
openapi => { error => "Cannot see background job info" } |
| 79 |
) |
| 80 |
if !$can_manage_background_jobs |
| 81 |
&& $background_job->borrowernumber != $patron->borrowernumber; |
| 82 |
|
| 83 |
return $c->render( |
68 |
return $c->render( |
| 84 |
status => 200, |
69 |
status => 200, |
| 85 |
openapi => $background_job->to_api |
70 |
openapi => $background_job->to_api |