Add contest support Petru
authorMarius Gavrilescu <marius@ieval.ro>
Wed, 27 Nov 2013 20:58:55 +0000 (22:58 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Wed, 27 Nov 2013 20:58:55 +0000 (22:58 +0200)
lib/Gruntmaster/Handlers.pm

index cb2393f68bb327ac1e4cb51b8a2959b1a529ec57..2ce155bc5566e0ff036dc26a7e55d6a6353bbaca 100644 (file)
@@ -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;
This page took 0.011186 seconds and 4 git commands to generate.