]> iEval git - plack-app-gruntmaster.git/blobdiff - lib/Plack/App/Gruntmaster.pm
Disallow submissions where the problem does not belong to the contest
[plack-app-gruntmaster.git] / lib / Plack / App / Gruntmaster.pm
index 9775b960c10d729d96c7984f5661dcf8f6e99073..4f2d6e18f3d9a6d3f11c0dc14ebaab6604c346a9 100644 (file)
@@ -112,7 +112,7 @@ sub dispatch_request{
 
                sub (/src/:job) {
                        return NOT_FOUND if !job;
-                       forbid job->private || job->problem->private || job->contest && job->contest->private;
+                       forbid job->private || job->problem->private || job->contest && job->contest->is_running;
                        my @headers = ('X-Forever' => 1, 'Cache-Control' => 'public, max-age=604800', 'Content-Type' => CONTENT_TYPES->{job->format});
                        [200, \@headers, [job->source]]
                },
@@ -179,6 +179,10 @@ sub dispatch_request{
                        $_{contest} = $contest;
                        return NOT_FOUND if !contest && !problem->is_in_archive || contest && !db->contest_problems->find($_{contest}, $_{problem});
                        forbid problem->is_private;
+                       if (contest && contest->is_running) {
+                               forbid !remote_user;
+                               $privacy = 'private';
+                       }
                        response pb_entry => problem->name, db->problem_entry($_{problem}, $_{contest}, remote_user && remote_user->id);
                },
                sub (/sol/:problem) {
@@ -217,6 +221,7 @@ sub dispatch_request{
                        forbid !remote_user;
                        return reply 'This contest has finished' if contest && contest->is_finished;
                        return reply 'This contest has not yet started' if !admin && contest && contest->is_pending;
+                       return reply 'This problem does not belong to this contest' if !contest && !problem->is_in_archive || contest && !db->contest_problems->find($_{contest}, $_{problem});
                        return reply 'Maximum source size is 10KB' if ($prog ? $prog->size : length $_{source_code}) > 10 * 1024;
                        return reply 'You must wait 30 seconds between jobs' if !admin && time <= remote_user->lastjob + 30;
                        remote_user->update({lastjob => time});
@@ -225,7 +230,7 @@ sub dispatch_request{
                        unlink $prog->path if $prog;
                        my $newjob = db->jobs->create({
                                maybe contest => $_{contest},
-                               maybe private => problem->private,
+                               maybe private => problem->private && !$_{contest},
                                date => time,
                                extension => FORMAT_EXTENSION->{$_{prog_format}},
                                format => $_{prog_format},
This page took 0.020765 seconds and 4 git commands to generate.