From: Marius Gavrilescu Date: Sat, 14 Feb 2015 09:07:15 +0000 (+0200) Subject: Make contest_* only return public columns (all of them but editorial) X-Git-Tag: 5999.000_014~71 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=d5046b3d2251583196d2e2e25e17e64c913bf690;p=gruntmaster-data.git Make contest_* only return public columns (all of them but editorial) --- diff --git a/lib/Gruntmaster/Data.pm b/lib/Gruntmaster/Data.pm index bcb3571..28b520a 100644 --- a/lib/Gruntmaster/Data.pm +++ b/lib/Gruntmaster/Data.pm @@ -25,6 +25,7 @@ use HTTP::Tiny; use PerlX::Maybe qw/maybe/; use Sub::Name qw/subname/; +use constant CONTEST_PUBLIC_COLUMNS => [qw/id name description start stop owner/]; use constant PROBLEM_PUBLIC_COLUMNS => [qw/id author writer level name owner private timeout olimit value/]; use constant USER_PUBLIC_COLUMNS => [qw/id admin name town university country level/]; use constant JOBS_PER_PAGE => 10; @@ -118,7 +119,7 @@ sub problem_entry { sub contest_list { my ($self, %args) = @_; - my $rs = $self->contests->search(undef, {order_by => {-desc => 'start'}, prefetch => 'owner'}); + my $rs = $self->contests->search(undef, {columns => CONTEST_PUBLIC_COLUMNS, order_by => {-desc => 'start'}, prefetch => 'owner'}); $rs = $rs->search({owner => $args{owner}}) if $args{owner}; my %params; for ($rs->all) { @@ -131,7 +132,7 @@ sub contest_list { sub contest_entry { my ($self, $id) = @_; - my $ct = $self->contest($id); + my $ct = $self->contests->find($id,{columns => CONTEST_PUBLIC_COLUMNS}); +{ $ct->get_columns, started => !$ct->is_pending, finished => $ct->is_finished, owner_name => $ct->owner->name } }