From: Marius Gavrilescu Date: Fri, 12 Feb 2016 00:37:21 +0000 (+0000) Subject: Prevent participation in both divisions of a round X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=5c5c76a0c8a2e0fed56ae94894e87c1d10a7ccbc;p=gruntmaster-page.git Prevent participation in both divisions of a round --- diff --git a/lib/Plack/App/Gruntmaster.pm b/lib/Plack/App/Gruntmaster.pm index 7b927d5..8d96842 100644 --- a/lib/Plack/App/Gruntmaster.pm +++ b/lib/Plack/App/Gruntmaster.pm @@ -190,6 +190,11 @@ sub dispatch_request{ return reply 'This contest has finished' if $contest->{finished}; return reply 'This problem is private' if !admin && $private; return reply 'This problem does not belong to this contest' unless contest_has_problem $_{contest}, $_{problem}; + if ($_{contest} =~ /d[12]$/) { + my $other = $_{contest} =~ y/12/21/r; + my ($ans) = db->query('SELECT COUNT(*) FROM jobs WHERE owner = ? AND contest = ?', remote_user->{id}, $other)->flat; + return reply 'You are not allowed to participate in both divisions of a round' if $ans; + } } 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;