Lines 73-94
Controller function that handles cancelling a patron's Koha::ArticleRequest obje
Link Here
|
73 |
sub patron_cancel { |
73 |
sub patron_cancel { |
74 |
my $c = shift->openapi->valid_input or return; |
74 |
my $c = shift->openapi->valid_input or return; |
75 |
|
75 |
|
76 |
my $patron = Koha::Patrons->find( $c->param('patron_id') ); |
76 |
my $patron_id = $c->param('patron_id'); |
|
|
77 |
return try { |
78 |
$c->auth->public($patron_id); |
79 |
my $patron = Koha::Patrons->find($patron_id); |
77 |
|
80 |
|
78 |
return $c->render_resource_not_found("Patron") |
81 |
return $c->render_resource_not_found("Patron") |
79 |
unless $patron; |
82 |
unless $patron; |
80 |
|
83 |
|
81 |
# patron_id has been validated by the allow-owner check, so the following call to related |
84 |
# patron_id has been validated by the $c->auth->public check, so the following call to related |
82 |
# article requests covers the case of article requests not belonging to the patron |
85 |
# article requests covers the case of article requests not belonging to the patron |
83 |
my $article_request = $patron->article_requests->find( $c->param('article_request_id') ); |
86 |
my $article_request = $patron->article_requests->find( $c->param('article_request_id') ); |
84 |
|
87 |
|
85 |
return $c->render_resource_not_found("Article request") |
88 |
return $c->render_resource_not_found("Article request") |
86 |
unless $article_request; |
89 |
unless $article_request; |
87 |
|
90 |
|
88 |
my $reason = $c->param('cancellation_reason'); |
91 |
my $reason = $c->param('cancellation_reason'); |
89 |
my $notes = $c->param('notes'); |
92 |
my $notes = $c->param('notes'); |
90 |
|
|
|
91 |
return try { |
92 |
|
93 |
|
93 |
$article_request->cancel( |
94 |
$article_request->cancel( |
94 |
{ |
95 |
{ |