fedora-vote castvote.cgi,1.5,1.6 votingadmin.py,1.3,1.4
Toshio Ernie Kuratomi (toshio)
fedora-extras-commits at redhat.com
Tue Jun 13 07:04:00 UTC 2006
Author: toshio
Update of /cvs/fedora/fedora-vote
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv24472
Modified Files:
castvote.cgi votingadmin.py
Log Message:
* castvote.cgi:
- Add boilerplate header.
- Give a more informative error to the voter if they've already cast a
ballot.
* votingadmin.py:
- process_ballot(): Change call to nonexistent fetchrow() into fetchall()
and then extract the id from teh result.
+ Change call to nonexistent commit() into execute('COMMIT').
+ Change call to nonexistent prepend() to a slice operation.
Index: castvote.cgi
===================================================================
RCS file: /cvs/fedora/fedora-vote/castvote.cgi,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- castvote.cgi 12 Jun 2006 08:26:38 -0000 1.5
+++ castvote.cgi 13 Jun 2006 07:03:54 -0000 1.6
@@ -1,5 +1,15 @@
#!/usr/bin/python
# castvote.cgi
+# Author: Tom "spot" Callaway
+# Toshio Kuratomi
+# Date: 23 June 2006
+# Copyright: Tom Callaway
+# License: License granted to Red Hat, Inc under the terms
+# specified in the Fedora Project Individual Contributor License
+# Agreement.
+# Description: The cgi script to enter the voter's ballot into the
+# database.
+# Id: $Id$
import cgi
import os
@@ -36,6 +46,8 @@
title=pageTitle, require_auth = True)
try:
election = votingadmin.ElectionAdmin(dbh=dbh, commonName=electionName)
+ ### FIXME: These checks need to be performed within process_ballot; not
+ # here.
inProgress = election.occurring()
authorized = election.authorize_user(username)
except (voting.VotingError, pgdb.Error), e:
@@ -69,14 +81,18 @@
try:
receipt = election.process_ballot(username, ballotCandidates)
except voting.VotingError, e:
- website.send_email(voting.sendAs, voting.sendErrorsTo,
- 'Voting Error',
- '''The Fedora Voting Application failed to save a ballot
-cast by %s in the %s election. It received a VotingError with message %s in
-castvote.cgi.''' % (username, electionName, str(e)))
- content = '<p class="error">The ballot you have attempted to' \
- ' cast is not valid. The admins have been emailed to' \
- ' see why the website is trying to send malformed' \
+ if e.args[0] == 'Already voted in this election':
+ content = '<p class="error">You have already submitted a' \
+ ' ballot in this election. You can only vote once.</p>'
+ else:
+ website.send_email(voting.sendAs, voting.sendErrorsTo,
+ 'Voting Error',
+ '''The Fedora Voting Application failed to save a
+ballot cast by %s in the %s election. It received a VotingError with message
+%s in castvote.cgi.''' % (username, electionName, str(e)))
+ content = '<p class="error">The ballot you have attempted' \
+ ' to cast is not valid. The admins have been emailed' \
+ ' to see why the website is trying to send malformed' \
' ballots. </p>'
except (pgdb.Error, pg.Error), e:
website.send_email(voting.sendAs, voting.sendErrorsTo,
Index: votingadmin.py
===================================================================
RCS file: /cvs/fedora/fedora-vote/votingadmin.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- votingadmin.py 12 Jun 2006 08:26:38 -0000 1.3
+++ votingadmin.py 13 Jun 2006 07:03:54 -0000 1.4
@@ -66,15 +66,15 @@
self.dbCmd.execute("select id from ballots where voter = '%s'"
" and election_id = '%s'" % (userId,
self.electionId))
- ballotId = self.dbCmd.fetchrow()[0]
+ ballotId = self.dbCmd.fetchall()[0][0]
for candidate in tally.keys():
self.dbCmd.execute('insert into votes (ballot_id, candidate_id,'
" election_id, points) values ('%s', '%s', '%s', '%s')" %
(ballotId, candidate, self.electionId, 1))
# If all of that completed with no exceptions, go ahead and commit the
# ballot.
- self.dbCmd.commit()
+ self.dbCmd.execute('COMMIT')
- receiptList.prepend('<p>Your ballot number was: %s</p>' % ballotId)
+ receiptList[0:0] = ('<p>Your ballot number was: %s</p>' % ballotId,)
return '\n'.join(receiptList)
More information about the fedora-extras-commits
mailing list