elections/admin.py | 9 ++------- elections/controllers.py | 8 ++++---- elections/templates/about.html | 6 +++--- elections/templates/results.html | 4 ++-- elections/templates/vote.html | 4 ++-- elections/vote.py | 9 ++++++--- 6 files changed, 19 insertions(+), 21 deletions(-)
New commits: commit a5cb0beda831b9069418313b9dd59d54a69135f3 Author: Nigel Jones dev@nigelj.com Date: Mon Oct 6 23:38:15 2008 +1300
And now one can see the results... everything now uses the new schema (I think)
diff --git a/elections/controllers.py b/elections/controllers.py index 8c108b3..5de5a4c 100644 --- a/elections/controllers.py +++ b/elections/controllers.py @@ -81,7 +81,7 @@ class Root(controllers.RootController): election = Elections.query.filter_by(id=eid).all()[0] except ValueError: try: - election = Elections.query.filter_by(shortname=eid).all()[0] + election = Elections.query.filter_by(alias=eid).all()[0] eid = election.id except IndexError: turbogears.flash("This election does not exist, check if you have used the correct URL.") @@ -91,13 +91,13 @@ class Root(controllers.RootController): raise turbogears.redirect("/")
curtime = datetime.utcnow() - if election.public_results == 0 and election.end_date > curtime: + if election.end_date > curtime: turbogears.flash("We are sorry, the results for this election cannot be viewed at this time because the election is still in progress.") raise turbogears.redirect("/") elif election.start_date > curtime: turbogears.flash("We are sorry, the results for this election cannot be viewed at this time because the election has not started.") raise turbogears.redirect("/") - elif election.public_results == 0 and election.embargoed == 1: + elif election.embargoed == 1: turbogears.flash("We are sorry, the results for this election cannot be viewed because they are currently embargoed pending formal announcement.") raise turbogears.redirect("/") votecount = VoteTally.query.filter_by(election_id=eid).order_by(VoteTally.novotes.desc()).all() diff --git a/elections/templates/results.html b/elections/templates/results.html index e21c8d6..d3e4a51 100644 --- a/elections/templates/results.html +++ b/elections/templates/results.html @@ -7,8 +7,8 @@ <title>${appTitle}</title> </head> <body> - <h1>${election.name} Results</h1> - <p>${election.info}</p> + <h1>${election.shortdesc} Results</h1> + <p>${election.description}</p> <p py:if="election.url"><a href="${election.url}">[More Information]</a></p> <table border="1" cellpadding="1"> <tr py:for="candcount in votecount">
commit d5abe5aa798b2ef0ecdf92bf5328f586f2b78af9 Author: Nigel Jones dev@nigelj.com Date: Mon Oct 6 23:33:10 2008 +1300
Votes can now be recorded
diff --git a/elections/templates/vote.html b/elections/templates/vote.html index bfa2822..39c7248 100644 --- a/elections/templates/vote.html +++ b/elections/templates/vote.html @@ -23,8 +23,8 @@ <title>${appTitle} -- Cast Your Vote</title> </head> <body> - <h1>${election.name}</h1> - <p>${election.info}</p> + <h1>${election.shortdesc}</h1> + <p>${election.description}</p> <p py:if="election.url"><a href="${election.url}">[More Information]</a></p> <div> <form action="${tg.url('/vote/' + str(election.id))}" method="post"> diff --git a/elections/vote.py b/elections/vote.py index e03be0e..96ee0d2 100644 --- a/elections/vote.py +++ b/elections/vote.py @@ -23,22 +23,25 @@ # Report Bugs to https://www.fedorahosted.org/elections
-# Admin functions go here (i.e. add/delete elections) +# Voting functions
import turbogears from turbogears import controllers, expose, flash, redirect, config from turbogears import identity from elections import model -from elections.model import * +from elections.model import Elections, LegalVoters, Candidates, Votes, UserVoteCount
import sqlalchemy
from turbogears.database import session
+from datetime import datetime + class Vote(controllers.Controller): def __init__(self, appTitle): self.appTitle = appTitle
+ #TODO: This function will be split off into: default => submit => confirm functions, hopefully it was simplify everything @identity.require(identity.not_anonymous()) @expose(template="elections.templates.vote") def default(self, eid=None, **kw): @@ -47,7 +50,7 @@ class Vote(controllers.Controller): election = Elections.query.filter_by(id=eid).all()[0] except ValueError: try: - election = Elections.query.filter_by(shortname=eid).all()[0] + election = Elections.query.filter_by(alias=eid).all()[0] eid = election.id except IndexError: turbogears.flash("This election does not exist, check if you have used the correct URL.")
commit cb47432cf1c1baeaede3d6da4ae013d592e2f173 Author: Nigel Jones dev@nigelj.com Date: Mon Oct 6 23:24:31 2008 +1300
Make /about/foo work again...
diff --git a/elections/controllers.py b/elections/controllers.py index 4fa1786..8c108b3 100644 --- a/elections/controllers.py +++ b/elections/controllers.py @@ -58,7 +58,7 @@ class Root(controllers.RootController): election = Elections.query.filter_by(id=eid).all()[0] except ValueError: try: - election = Elections.query.filter_by(shortname=eid).all()[0] + election = Elections.query.filter_by(alias=eid).all()[0] eid = election.id except IndexError: turbogears.flash("This election does not exist, check if you have used the correct URL.") diff --git a/elections/templates/about.html b/elections/templates/about.html index 0fdcb2f..00646cc 100644 --- a/elections/templates/about.html +++ b/elections/templates/about.html @@ -7,8 +7,8 @@ <title>${appTitle} -- Election Information</title> </head> <body> - <h1>${election.name}</h1> - <p>${election.info}</p> + <h1>${election.shortdesc}</h1> + <p>${election.description}</p> <p py:if="election.url"><a href="${election.url}">[More Information]</a></p> <table border="1" cellpadding="1"> <tr py:for="candidate in candidates"> @@ -16,7 +16,7 @@ </tr> <!-- !This link is okay, but one should appear if the election has public results --> <tr> - <td><a href="${tg.url('/vote/' + election.shortname)}">Vote Now!</a></td> + <td><a href="${tg.url('/vote/' + election.alias)}">Vote Now!</a></td> </tr> </table> <p>To vote in this election you must be a member of any one of the following groups:</p>
commit 2f8722f919f82be1de07e6a77761df833b83ce6e Author: Nigel Jones dev@nigelj.com Date: Mon Oct 6 23:24:22 2008 +1300
Fix up adding new candidates
diff --git a/elections/admin.py b/elections/admin.py index cede43f..92cbe29 100644 --- a/elections/admin.py +++ b/elections/admin.py @@ -71,14 +71,9 @@ class Admin(controllers.Controller): candidate = entry.split("!") #Python doesn't have a good way of doing case/switch statements if len(candidate) == 1: - Candidates(election_id=kw['id'],name=candidate[0]) + Candidates(election_id=kw['id'],name=candidate[0], status=0, human=1) elif len(candidate) == 2: - Candidates(election_id=kw['id'],name=candidate[0],formalname=candidate[1]) - elif len(candidate) == 3: - if candidate[1] == '': - Candidates(election_id=kw['id'],name=candidate[0],url=candidate[2]) - else: - Candidates(election_id=kw['id'],name=candidate[0],formalname=candidate[1],url=candidate[2]) + Candidates(election_id=kw['id'],name=candidate[0],url=candidate[1], status=0, human=1) else: turbogears.flash("There was an issue!") raise turbogears.redirect("/admin/newc")
elections-devel@lists.stg.fedorahosted.org