]> git.sesse.net Git - ccbs/commitdiff
Make it possible to edit scores.
authorSteinar H. Gunderson <sesse@samfundet.no>
Wed, 16 Feb 2005 14:33:30 +0000 (14:33 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Wed, 16 Feb 2005 14:33:30 +0000 (14:33 +0000)
html/do-edit-scores.pl
html/templates/show-tournament.tmpl

index 4b5d4828034597a8f2fe487ec1beb755a928d2ce..fe29c168abe76ddc895101fa02f0e67aaec502bc 100755 (executable)
@@ -8,18 +8,25 @@ my $dbh = ccbs::db_connect();
 my $cgi = new CGI;
 
 my $tournament = $cgi->param('tournament');
+my $round = $cgi->param('round');
+my $group = $cgi->param('group');
 
-# Loop through all parameters until we find the update button
-my $player;
-for my $param ($cgi->param()) {
-       if ($param =~ /^update(\d+)$/) {
-               $player = $1;
-               last;
+$dbh->{AutoCommit} = 0;
+
+# Loop through all parameters and see what parameters differ between old- and current
+# versions
+for my $p ($cgi->param()) {
+       next if ($p =~ /^old-(.*?)$/);
+       next unless (defined($cgi->param('old-' . $p)));
+       next if ($cgi->param($p) eq $cgi->param('old-' . $p));
+
+       if ($p =~ /^score(\d+)-(\d+)/) {
+               $dbh->do('UPDATE scores SET score=? WHERE tournament=? AND round=? AND parallel=? AND player=? AND songnumber=?', undef,
+                       $cgi->param($p), $tournament, $round, $group, $1, $2);
        }
 }
 
-die "Form-submit uten å trykke på noen update-knapp?" unless (defined($player));
-
+$dbh->commit;
 $dbh->disconnect;
 
 ccbs::print_see_other('show-tournament.pl?id=' . $tournament);
index 074e21eb482b3ce321559a52b4907b222773cef3..decfe5ed8e2e60362029170af157aa2c67e7d7f5 100644 (file)
       <th>
         <input type="hidden" name="tournament" value="[% tournament.tournament %]" />
         <input type="hidden" name="round" value="[% r.round %]" />
+        <input type="hidden" name="group" value="[% p.parallel %]" />
       </th>
     [% ELSE %]
       <th>
         <input type="hidden" name="tournament" value="[% tournament.tournament %]" />
         <input type="hidden" name="round" value="[% r.round %]" />
+        <input type="hidden" name="group" value="[% p.parallel %]" />
         Gruppe [% p.parallel %]
       </th>
     [% END %]