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

(-)a/Koha/REST/V1/Displays.pm (-8 / +12 lines)
Lines 233-249 sub get_public { Link Here
233
    my $c = shift->openapi->valid_input or return;
233
    my $c = shift->openapi->valid_input or return;
234
234
235
    return try {
235
    return try {
236
        my $display = Koha::Displays->find( $c->param('display_id') );
236
        my $today = dt_from_string->truncate( to => 'day' )->ymd;
237
238
        my $display = Koha::Displays->search(
239
            {
240
                display_id => $c->param('display_id'),
241
                enabled    => 1,
242
                -and       => [
243
                    -or => [ { start_date => undef }, { start_date => { '<=' => $today } } ],
244
                    -or => [ { end_date   => undef }, { end_date   => { '>=' => $today } } ],
245
                ],
246
            }
247
        )->next;
237
248
238
        return $c->render_resource_not_found("Display")
249
        return $c->render_resource_not_found("Display")
239
            unless $display;
250
            unless $display;
240
251
241
        my $today = dt_from_string->truncate( to => 'day' )->ymd;
242
243
        if ( $display->end_date && $display->end_date < $today ) {
244
            return $c->render_resource_not_found("Display");
245
        }
246
247
        return $c->render( status => 200, openapi => $c->objects->to_api($display), );
252
        return $c->render( status => 200, openapi => $c->objects->to_api($display), );
248
    } catch {
253
    } catch {
249
        $c->unhandled_exception($_);
254
        $c->unhandled_exception($_);
250
- 

Return to bug 14962