fedora-vote newelection.py, NONE, 1.1 voting.py, 1.3, 1.4 votingdb.sql, 1.2, 1.3
Toshio Ernie Kuratomi (toshio)
fedora-extras-commits at redhat.com
Sat Jun 10 06:42:48 UTC 2006
Author: toshio
Update of /cvs/fedora/fedora-vote
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv3041
Modified Files:
voting.py votingdb.sql
Added Files:
newelection.py
Log Message:
* voting.py: get_candidates(): Fix a call to website.get_user_info().
* votingdb.sql: Comment the initial election creation. We'll do this in
a script instead.
* newelection.py: Script to setup a new election. It creates the election,
discovers the candidates ids and enters them into the database, and
will soon create the legalVoters groups as well.
--- NEW FILE newelection.py ---
#!/usr/bin/python
# Retrieve candidate ids from the accounts database and then reenter them
# into the electiondb
import sys
import website
import votingadmin
electionName = 'FESCo 2006'
start = '2006-06-08'
end = '2006-06-20'
seats = '13'
candidates = ('awjb',
'spot',
'rdieter',
'kevin',
'ausil',
'c4chris',
'katzj',
'mjk',
'toshio',
'thl',
'jpo',
'bpepple',
'mschwendt',
'scop',
'tibbs',
'wtogami',
'skvidal')
candList = []
dbh = website.get_dbh()
print "Check that these are the candidates you were expecting"
for cand in candidates:
id = website.get_user_id(dbh, cand)
candidateUserInfo = website.get_user_info(dbh, id)
print "%s -- Id: %s" % (candidateUserInfo['human_name'], id)
candList.append(id)
print "Were those the correct candidates? (y/n)"
letter = sys.stdin.read(1)
if letter != 'y' and letter != 'Y':
sys.exit(1)
election = votingadmin.ElectionAdmin(dbh, electionName)
query = "insert into election (start_date, end_date, common_name, max_seats)" \
" values('%s', '%s', '%s', '%s')" % (start, end, electionName, seats)
election.dbCmd.execute(query)
for candNum in candList:
query = "insert into candidates (id, election_id) values ('%s', '%s')" \
% (candNum, election.electionId)
print query
election.dbCmd.execute(query)
election.dbCmd.execute('COMMIT')
Index: voting.py
===================================================================
RCS file: /cvs/fedora/fedora-vote/voting.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- voting.py 10 Jun 2006 05:24:08 -0000 1.3
+++ voting.py 10 Jun 2006 06:42:45 -0000 1.4
@@ -111,10 +111,10 @@
" where election_id = '%s'" % self.electionId);
candidates = self.dbCmd.fetchall()
if len(candidates) < 1:
- raise VotingError, 'No candidates listed for %s' % \
+ raise VotingError, 'No candidates listed for election %s' % \
self.electionId
for candidate in candidates:
- candInfo = website.get_user_info(candidate[0])
+ candInfo = website.get_user_info(self.dbh, candidate[0])
if not candInfo:
raise VotingError, 'Candidate %s not in the accounts db' % \
candidate[0]
Index: votingdb.sql
===================================================================
RCS file: /cvs/fedora/fedora-vote/votingdb.sql,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- votingdb.sql 10 Jun 2006 02:47:48 -0000 1.2
+++ votingdb.sql 10 Jun 2006 06:42:45 -0000 1.3
@@ -55,4 +55,4 @@
create view tallysheet as
select sum(points) as vote_count, id, candidates.election_id from candidates, votes where candidates.id = candidate_id group by id, candidates.election_id order by candidates.election_id, vote_count desc;
-insert into election (start_date, end_date, common_name, max_seats) values('2006-05-29', '2006-06-05', 'FESCo 2006', '13');
+-- insert into election (start_date, end_date, common_name, max_seats) values('2006-05-29', '2006-06-05', 'FESCo 2006', '13');
More information about the scm-commits
mailing list