Pull in player editing code from --baby.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 23 Apr 2005 14:50:21 +0000 (14:50 +0000)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 23 Apr 2005 14:50:21 +0000 (14:50 +0000)
Patches applied:

 * sgunderson@bigfoot.com--2005-baby/ccbs--baby--0.1--patch-14
   Make a link from the "players registered in this tournament" list to the player pages.

 * sgunderson@bigfoot.com--2005-baby/ccbs--baby--0.1--patch-15
   Add backend for editing players. Update TODO.

 * sgunderson@bigfoot.com--2005-baby/ccbs--baby--0.1--patch-16
   Actually commit backend for editing players.

TODO
html/do-edit-player.pl [new file with mode: 0755]
html/player.pl
html/templates/player.tmpl
html/templates/registration.tmpl

diff --git a/TODO b/TODO
index 1c799a69d7fed3381ff2c96e07cb1a963e4b9492..3caf74052229ddc72bc2041ce3cfff001af4d36a 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,5 +1,4 @@
 - Proper functionality for editing groups (adding/deleting players and songs)
-- Ability to edit players (in particular, fix country/group)
 - Multiple variations on short titles
 - Add DP/pass in addition to score
 - Auto-reset of the song selector on first elimination round?
diff --git a/html/do-edit-player.pl b/html/do-edit-player.pl
new file mode 100755 (executable)
index 0000000..de85f45
--- /dev/null
@@ -0,0 +1,22 @@
+#! /usr/bin/perl
+
+use ccbs;
+use strict;
+use warnings;
+
+ccbs::admin_only();
+
+my $dbh = ccbs::db_connect();
+my $cgi = new CGI;
+
+my $player = $cgi->param('player');
+my $nick = $cgi->param('nick');
+my $country = $cgi->param('country');
+my $club = $cgi->param('club');
+
+$club = undef if ($club == -1);
+
+$dbh->do('UPDATE players SET nick=?, country=?, club=? WHERE player=?', undef, $nick, $country, $club, $player);
+ccbs::print_see_other('player.pl?id=' . $player);
+
+$dbh->disconnect;
index 80011b0d6ba0c0b1acea1e226d95e81b276e3f17..93d93282d5a57a77b73f5fd33793854b38cb221d 100755 (executable)
@@ -12,6 +12,12 @@ my $dbh = ccbs::db_connect();
 my $player = $dbh->selectrow_hashref('SELECT * FROM players NATURAL JOIN countries NATURAL LEFT JOIN clubs WHERE player=?', undef, $id);
 my $bestsongs = ccbs::db_fetch_all($dbh, 'SELECT song,title,score,tournament,tournamentname FROM ( SELECT DISTINCT ON (song) song,score,tournament FROM scores WHERE player=? AND score IS NOT NULL ORDER BY song,score DESC ) t1 NATURAL JOIN songs NATURAL JOIN tournaments ORDER BY score DESC LIMIT 10', $id);
 
+my ($countries, $clubs);
+unless ($ccbs::ccbs_noadmin) {
+       $countries = ccbs::db_fetch_all($dbh, 'SELECT * FROM countries ORDER BY countrycode');
+       $clubs = ccbs::db_fetch_all($dbh, 'SELECT * FROM clubs ORDER BY clubcode');
+}
+
 # Fetch all scores and count a bit
 my $columns = 0;
 my @allsongs = ();
@@ -38,6 +44,8 @@ ccbs::process_template('player.tmpl', $player->{'nick'}, {
        player => $player,
        bestsongs => $bestsongs,
        allsongs => \@allsongs,
-       columns => $columns
+       columns => $columns,
+       countries => $countries,
+       clubs => $clubs
 });
 $dbh->disconnect;
index 91a4d7970cd9499b9f584c82ca03f45a9eb31d4f..b41aeb7a146fb3431d79efa5464cd28fe69b55bc 100644 (file)
     </ul>
   </div>
 
+[% IF !public %]
+  <h2>Rediger spiller</h2>
+
+  <div>
+    <form method="post" action="do-edit-player.pl">
+      <input type="hidden" name="player" value="[% player.player %]" />
+      <table>
+        <tr>
+          <th>Nick</th>
+          <td><input name="nick" value="[% player.nick %]" /></td>
+       </tr>
+        <tr>
+          <th>Land</th>
+          <td>
+            <select name="country">
+[% FOR c = countries %]
+  [% IF c.country == player.country %]
+    <option value="[% c.country %]" selected="selected">[% c.countrycode %] - [% c.countryname %]</option>
+  [% ELSE %]
+    <option value="[% c.country %]">[% c.countrycode %] - [% c.countryname %]</option>
+  [% END %]
+[% END %]
+            </select>
+          </td>
+        </tr>
+        <tr>
+          <th>Klubb</th>
+          <td>
+            <select name="club">
+              <option value="-1"></option>
+[% FOR c = clubs %]
+  [% IF c.club == player.club %]
+              <option value="[% c.club %]" selected="selected">[% c.clubname %]</option>
+  [% ELSE %]
+              <option value="[% c.club %]">[% c.clubname %]</option>
+  [% END %]
+[% END %]
+           </select>
+         </td>
+        </tr>
+        <tr>
+          <th colspan="2">
+           <input type="submit" value="Rediger" />
+         </th>
+       </tr>
+      </table>
+    </form>
+  </div>
+[% END %]
+
   <h2>Beste sanger</h2>
 
   <div>
index dca65b0d48322b0890ec75ed3b831f068374339b..3278c8f8db3bf44b566338287a2e986417f9bbd6 100644 (file)
@@ -87,7 +87,7 @@
   <table>
 [% FOR r = registered %]
     <tr>
-      <td>[% r.nick %]</td>
+      <td><a href="player.pl?id=[% r.player %]">[% r.nick %]</a></td>
 [% IF r.paid %]
       <td>betalt</td>
 [% ELSE %]
           </p>
         </form>
       </td>
+      <td>
+        <form method="post" action="edit-player.pl">
+          <p class="button">
+            <input type="hidden" name="player" value="[% r.player %]" />
+           <input type="submit" value="Editer spiller" />
+          </p>
+        </form>
+      </td>
     </tr>
 [% END %]
   </table>