From: Marius Gavrilescu Date: Wed, 27 Nov 2013 20:58:55 +0000 (+0200) Subject: Add contest support X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=2a1215b3e1653723eb89ee83a1a0e7ff3b860040;p=gruntmaster-handlers.git Add contest support --- diff --git a/lib/Gruntmaster/Handlers.pm b/lib/Gruntmaster/Handlers.pm index cb2393f..2ce155b 100644 --- a/lib/Gruntmaster/Handlers.pm +++ b/lib/Gruntmaster/Handlers.pm @@ -28,9 +28,15 @@ sub submit{ my $r = shift; chdir $r->dir_config('root'); my $req = Apache2::Request->new($r); - my ($problem, $format) = ($req->param('problem'), $req->param('prog_format')); + my ($problem, $format, $contest) = map {scalar $req->param($_)} 'problem', 'prog_format', 'contest'; my $ext = FORMAT_EXTENSION->{$format}; my $prog = $req->upload('prog'); + die if defined $contest && $contest !~ /^\w+$/; + + if (defined $contest) { + my $meta = LoadFile "ct/$contest/meta.yml"; + die unless time >= $meta->{start} && time <= $meta->{end} + } my $dir = tempdir; $prog->link("$dir/prog.$ext"); @@ -43,6 +49,8 @@ sub submit{ }, problem => $problem, user => $r->user, + date => time, + defined $contest ? (contest => $contest) : (), }; my $jobname = int rand 1_000_000_000;