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

(-)a/Koha/REST/V1/DisplayItems.pm (-3 / +14 lines)
Lines 21-26 use Modern::Perl; Link Here
21
21
22
use Mojo::Base 'Mojolicious::Controller';
22
use Mojo::Base 'Mojolicious::Controller';
23
23
24
use Koha::DateUtils qw( dt_from_string );
24
use Koha::DisplayItem;
25
use Koha::DisplayItem;
25
use Koha::DisplayItems;
26
use Koha::DisplayItems;
26
use Koha::Displays;
27
use Koha::Displays;
Lines 157-164 sub list_public { Link Here
157
    my $c = shift->openapi->valid_input or return;
158
    my $c = shift->openapi->valid_input or return;
158
159
159
    return try {
160
    return try {
160
        my $displayitems = $c->objects->search( Koha::DisplayItems->new );
161
        my $today        = dt_from_string()->truncate( to => 'day' )->ymd;
161
        return $c->render( status => 200, openapi => $displayitems );
162
        my $displayitems = Koha::DisplayItems->search(
163
            {
164
                'display.enabled' => 1,
165
                -and              => [
166
                    -or => [ { 'display.start_date' => undef }, { 'display.start_date' => { '<=' => $today } } ],
167
                    -or => [ { 'display.end_date'   => undef }, { 'display.end_date'   => { '>=' => $today } } ],
168
                ],
169
                -or => [ { 'me.date_remove' => undef }, { 'me.date_remove' => { '>=' => $today } } ],
170
            },
171
            { join => 'display' }
172
        );
173
        return $c->render( status => 200, openapi => $c->objects->search($displayitems) );
162
    } catch {
174
    } catch {
163
        $c->unhandled_exception($_);
175
        $c->unhandled_exception($_);
164
    };
176
    };
165
- 

Return to bug 14962