fedora-vote fedora-vote.conf, NONE, 1.1 castvote.cgi, 1.13, 1.14 newelection.py, 1.9, 1.10 vote.cgi, 1.11, 1.12 voting.py, 1.12, 1.13 votingadmin.py, 1.8, 1.9
Toshio くらとみ (toshio)
fedora-extras-commits at redhat.com
Mon Apr 21 02:08:01 UTC 2008
- Previous message (by thread): fedora-vote castvote.cgi, 1.12, 1.13 newelection.py, 1.8, 1.9 vote.cgi, 1.10, 1.11 voting.py, 1.11, 1.12 votingadmin.py, 1.7, 1.8
- Next message (by thread): fedora-vote README, 1.3, 1.4 castvote.cgi, 1.14, 1.15 vote.cgi, 1.12, 1.13
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: toshio
Update of /cvs/fedora/fedora-vote
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv25789
Modified Files:
castvote.cgi newelection.py vote.cgi voting.py votingadmin.py
Added Files:
fedora-vote.conf
Log Message:
Make changes to pull most config options from a config file. (poll vs election
has not been integrated into this yet.)
--- NEW FILE fedora-vote.conf ---
[global]
fas_username = ''
fas_password = ''
fas_url = 'https://admin.fedoraproject.org/accounts/'
election_name = 'Fedora Localization Steering Committee April 2008'
# Type is either poll or election
# This doesn't work yet. We need to examine the code to know how these two
# will differ.
#election_type = 'poll'
Index: castvote.cgi
===================================================================
RCS file: /cvs/fedora/fedora-vote/castvote.cgi,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- castvote.cgi 20 Apr 2008 23:58:49 -0000 1.13
+++ castvote.cgi 21 Apr 2008 02:07:28 -0000 1.14
@@ -1,10 +1,12 @@
#!/usr/bin/python
# castvote.cgi
-# Author: Tom "spot" Callaway
-# Toshio Kuratomi
-# Date: 23 June 2006
+# Authors: Tom "spot" Callaway
+# Toshio Kuratomi
+# Ricky Zhou
+# Date: 20 April 2008
# Copyright: Tom Callaway
-# License: License granted to Red Hat, Inc under the terms
+# License: GPLv2
+# 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
@@ -26,8 +28,6 @@
from fedora.accounts.fas2 import AccountSystem
-electionName = 'Fedora Documentation Steering Committee December 2007'
-
def make_thank_you(electionName, receipt):
content = '''
<p>
@@ -37,24 +37,18 @@
''' % (electionName, receipt)
return content
-if __name__ == '__main__':
+def make_body(electionName, fas_url, fas_username, fas_password):
form = cgi.FieldStorage()
- dbh = website.get_dbh()
username = os.environ['REMOTE_USER']
- # TODO: fill in fas_username/fas_password
- fas_username = ''
- fas_password = ''
-
- fas = AccountSystem('http://admin.fedoraproject.org/accounts/', fas_username, fas_password)
+ fas = AccountSystem(fas_url, fas_username, fas_password)
content = ''
pageTitle = 'Vote for %s Submitted' % electionName
- website.print_header(pageTitle, username)
try:
- election = votingadmin.ElectionAdmin(dbh=dbh, fas=fas, commonName=electionName)
+ election = votingadmin.ElectionAdmin(fas=fas, commonName=electionName)
except (voting.VotingError, pgdb.Error), e:
website.send_email(voting.sendAs, voting.sendErrorsTo, 'Voting Error',
'''The Fedora Voting Application failed to retrieve information
@@ -111,7 +105,30 @@
' the problem. Please try to vote again later. </p>'
else:
content = make_thank_you(electionName, receipt)
+ return pageTitle, content
+
+if __name__ == '__main__':
+ content = ''
+ try:
+ config = voting.get_config()
+ except:
+ content = 'Voting app is not configured.'
+
+ electionName = config.get('election_name', None)
+ fas_username = config.get('fas_username', None)
+ fas_password = config.get('fas_password', None)
+ fas_url = config.get('fas_url', None)
+ if not (electionName and fas_username and fas_password and fas_url):
+ content = 'One of the mandatory election variables was not configured'
+
+ if not content:
+ # Load content from the database
+ pageTitle, content = make_body(electionName, fas_url,
+ fas_username, fas_password)
+ else:
+ pageTitle = 'Fedora Voting App -- Error Page')
+
+ website.print_header(pageTitle, username)
print content
website.print_footer(pageTitle, 'http://www.fedoraproject.org')
- dbh.close()
Index: newelection.py
===================================================================
RCS file: /cvs/fedora/fedora-vote/newelection.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- newelection.py 20 Apr 2008 23:58:50 -0000 1.9
+++ newelection.py 21 Apr 2008 02:07:28 -0000 1.10
@@ -15,27 +15,39 @@
dbHost = 'db2.fedora.phx.redhat.com'
dbUser = 'electionsuser'
-electionName = 'Fedora Documentation Steering Committee December 2007'
-start = '2007-12-14 00:00:00'
-end = '2007-12-24 23:59:59'
+electionName = 'Fedora Localization Steering Committee - April 08'
+start = '2008-04-14 00:00:00'
+end = '2008-04-20 23:59:59'
#start = '2006-09-29 00:00:00'
#end = '2006-10-05 23:59:59'
-seats = '5'
+seats = '7'
-votingGroups = ('cvsdocs',)
+votingGroups = ('cvsl10n',)
candidates = (
- # Bart Couvreur
+ # example:
+ # Ankit Patel (ankit)
+ 'ankit',
+ # Bart Couvreur (couf)
'couf',
- # Jared Smith
- 'jsmith',
- # John Babich
- 'jmbabich',
- # Marc Wiriadisastra
- 'mwiriadi',
- # Vladimir Kosovac
- 'vnk'
+ # Diego Búrigo Zacarão (diegobz)
+ 'diegobz',
+ # Dimitris Glezos (glezos)
+ 'glezos',
+ # Fabian Affolter (fabian_a)
+ 'fab',
+ # Igor Pires Soares (igorps)
+ 'igor',
+ # Marek Mahut (mmahut)
+ 'mmahut',
+ # Noriko Mizumoto (noriko)
+ 'noriko',
+ # Piotr DrÄ
g (raven)
+ 'raven',
+ # Ville-Pekka Vainio (vpv)
+ 'vpv',
)
+
groupList = []
candList = []
Index: vote.cgi
===================================================================
RCS file: /cvs/fedora/fedora-vote/vote.cgi,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- vote.cgi 20 Apr 2008 23:58:51 -0000 1.11
+++ vote.cgi 21 Apr 2008 02:07:28 -0000 1.12
@@ -1,5 +1,8 @@
#!/usr/bin/python
-
+# License: GPLv2
+# Authors: Toshio Kuratomi
+# Ricky Zhou
+# Copyright: 29 April 2008
import cgi
import sys
import os
@@ -11,7 +14,7 @@
import voting
-electionName = 'Fedora Documentation Steering Committee December 2007'
+electionName = 'Fedora Localization Steering Committee April 2008'
def make_ballot(candidates, ballotName, openSeats):
'''Return a string representing an html ballot.'''
@@ -84,24 +87,18 @@
''')
return ''.join(content)
-if __name__ == '__main__':
+def make_body(electionName, fas_url, fas_username, fas_password):
form = cgi.FieldStorage()
- dbh = website.get_dbh()
username = os.environ['REMOTE_USER']
- # TODO: fill in fas_username/fas_password
- fas_username = ''
- fas_password = ''
-
- fas = AccountSystem('https://admin.fedoraproject.org/accounts/', fas_username, fas_password)
+ fas = AccountSystem(fas_url, fas_username, fas_password)
content = ''
pageTitle = 'Ballot for %s Election' % electionName
- website.print_header(pageTitle, username)
try:
- election = voting.Election(dbh=dbh, fas=fas, commonName=electionName)
+ election = voting.Election(fas=fas, commonName=electionName)
authorized = election.authorize_user(username)
occurs = election.occurring()
alreadyCast = election.already_cast_vote(username)
@@ -130,7 +127,30 @@
' You can only vote once.</p>'
else:
content = make_ballot(candidates, electionName, openSeats)
-
+
+ return pageTitle, content
+
+if __name__ == '__main__':
+ content = ''
+ try:
+ config = voting.get_config()
+ except:
+ content = 'Voting app is not configured.'
+
+ electionName = config.get('election_name', None)
+ fas_username = config.get('fas_username', None)
+ fas_password = config.get('fas_password', None)
+ fas_url = config.get('fas_url', None)
+ if not (electionName and fas_username and fas_password and fas_url):
+ content = 'One of the mandatory election variables was not configured'
+
+ if not content:
+ # Load content from the database
+ pageTitle, content = make_body(electionName, fas_url,
+ fas_username, fas_password)
+ else:
+ pageTitle = 'Fedora Voting App -- Error Page')
+
+ website.print_header(pageTitle, username)
print content
website.print_footer(pageTitle)
- dbh.close()
Index: voting.py
===================================================================
RCS file: /cvs/fedora/fedora-vote/voting.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- voting.py 20 Apr 2008 23:58:51 -0000 1.12
+++ voting.py 21 Apr 2008 02:07:28 -0000 1.13
@@ -1,8 +1,8 @@
# File: voting.py
# Author: Toshio Kuratomi <toshio at tiki-lounge.com>
-# Date: 23 May 2006
+# Date: 20 April 2008
# Copyright: Toshio Kuratomi
-# License: GPL
+# License: GPLv2
# Additional license granted to Red Hat, Inc under the terms
# specified in the Fedora Project Individual Contributor License
# Agreement.
@@ -13,6 +13,7 @@
import time
import pgdb
import website
+import ConfigParser
sendAs = 'voting@%s' % website.domain
sendErrorsTo = 'voting@%s' % website.domain
@@ -20,13 +21,21 @@
class VotingError(Exception):
pass
+def get_config(files=None):
+ files = files or ('/etc/fedora-vote.conf',)
+ config = ConfigParser.ConfigParser()
+ success = config.read(files)
+ if success:
+ return config
+ else:
+ raise VotingError, 'No config file found'
+
class Election(object):
electionDB = 'elections'
- def __init__(self, dbh, fas, commonName):
+ def __init__(self, fas, commonName):
'''Initialize the election with the database backend.'''
self.commonName = commonName
- self.dbh = dbh
self.fas = fas
self.db = website.get_dbh(self.electionDB)
self.dbCmd = self.db.cursor()
Index: votingadmin.py
===================================================================
RCS file: /cvs/fedora/fedora-vote/votingadmin.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- votingadmin.py 20 Apr 2008 23:58:51 -0000 1.8
+++ votingadmin.py 21 Apr 2008 02:07:28 -0000 1.9
@@ -1,8 +1,9 @@
# File: votingadmin.py
# Author: Toshio Kuratomi <toshio at tiki-lounge.com>
-# Date: 29 May 2006
+# Date: 20 April 2008
# Copyright: Toshio Kuratomi
-# License: GPL
+# Ricky Zhou
+# License: GPLv2
# Additional license granted to Red Hat, Inc under the terms
# specified in the Fedora Project Individual Contributor License
# Agreement.
@@ -16,8 +17,8 @@
from fedora.accounts.fas2 import AccountSystem
class ElectionAdmin(Election):
- def __init__(self, dbh, fas, commonName):
- Election.__init__(self, dbh, fas, commonName)
+ def __init__(self, fas, commonName):
+ Election.__init__(self, fas, commonName)
# If we need to customize the read-write interface (different user and
# password or some such, do it here.)
- Previous message (by thread): fedora-vote castvote.cgi, 1.12, 1.13 newelection.py, 1.8, 1.9 vote.cgi, 1.10, 1.11 voting.py, 1.11, 1.12 votingadmin.py, 1.7, 1.8
- Next message (by thread): fedora-vote README, 1.3, 1.4 castvote.cgi, 1.14, 1.15 vote.cgi, 1.12, 1.13
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the fedora-extras-commits
mailing list