[Fedora Elections] #26: First submit should be preview
by fedora-badges
#26: First submit should be preview
-------------------------+--------------------------------------------------
Reporter: mmcgrath | Owner: nigelj
Type: enhancement | Status: new
Priority: major | Milestone:
Component: General | Version: 0.1.5
Keywords: |
-------------------------+--------------------------------------------------
Minor thing but I think it might help, when you vote. The first screen to
submit to should really say "preview" instead of submit since you're not
submitting the vote until the final screen.
--
Ticket URL: <https://fedorahosted.org/elections/ticket/26>
Fedora Elections <https://fedorahosted.org/elections/>
Fedora Elections
11 years, 11 months
[Fedora Elections] #28: Improvements for the Voting App: Allow voting multiple times
by fedora-badges
#28: Improvements for the Voting App: Allow voting multiple times
-------------------------+--------------------------------------------------
Reporter: ixs | Owner: nigelj
Type: enhancement | Status: new
Priority: major | Milestone:
Component: General | Version: 0.1.5
Keywords: |
-------------------------+--------------------------------------------------
Please allow voting multiple times with each later vote canceling the
previous votes. This easily allows to correct a mistake during the voting
procedure or accounts for changed opinion.
There has just been a bit of discussion on IRC where people accidentially
voted incorrectly and would have liked such a feature.
kthxbai
--
Ticket URL: <https://fedorahosted.org/elections/ticket/28>
Fedora Elections <https://fedorahosted.org/elections/>
Fedora Elections
11 years, 11 months
5 commits - elections/admin.py elections/controllers.py elections/model.py elections.sql elections/templates
by tremble
elections.sql | 9 ++++
elections/admin.py | 19 ++++++++--
elections/controllers.py | 28 ++++++++++++--
elections/model.py | 5 ++
elections/templates/admedit.html | 10 +++++
elections/templates/admin.html | 5 +-
elections/templates/admnewc.html | 2 -
elections/templates/admnewe.html | 2 -
elections/templates/index.html | 74 ++++++++++++++++++++++++++++++++++++---
9 files changed, 139 insertions(+), 15 deletions(-)
New commits:
commit 8e7b28c5144257be084ce0bb579b54dedf0c5561
Author: Mark Chappell <tremble(a)tremble.org.uk>
Date: Mon May 17 15:29:42 2010 +0000
Replace the heading in newc and newe to be more descriptive than 'Welcome to Turbogears'
diff --git a/elections/templates/admnewc.html b/elections/templates/admnewc.html
index 44a0253..a1393f6 100644
--- a/elections/templates/admnewc.html
+++ b/elections/templates/admnewc.html
@@ -4,7 +4,7 @@
xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="master.html" />
<head>
- <title>Welcome to TurboGears</title>
+ <title>Fedora Elections -- Administration -- New Candidates</title>
</head>
<body>
<form action="${tg.url('/admin/newc')}" method="post">
diff --git a/elections/templates/admnewe.html b/elections/templates/admnewe.html
index b0a676d..2fe3b1e 100644
--- a/elections/templates/admnewe.html
+++ b/elections/templates/admnewe.html
@@ -4,7 +4,7 @@
xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="master.html" />
<head>
- <title>Welcome to TurboGears</title>
+ <title>Fedora Elections -- Administration -- New Election</title>
</head>
<body>
<form action="${tg.url('/admin/newe')}" method="post">
commit c6507862880cd0605875f0bdde8956530f21e915
Author: Mark Chappell <tremble(a)tremble.org.uk>
Date: Mon May 17 15:28:08 2010 +0000
When editing election reference them by id.
Admins can cope with this looking a little ugly
diff --git a/elections/templates/admin.html b/elections/templates/admin.html
index 37c6f0e..1bff42e 100644
--- a/elections/templates/admin.html
+++ b/elections/templates/admin.html
@@ -23,14 +23,15 @@
<td>${election.start_date}</td>
<td>${election.end_date}</td>
<td>
- <a href="${tg.url('/admin/edit/' + str(election.alias))}">More Information</a>
+ <a href="${tg.url('/admin/edit/' + str(election.id))}">More Information</a>
<py:if test="election.embargoed">
|
- <a href="${tg.url('/admin/edit/' + str(election.alias) + '?removeembargo=1')}">Remove Embargo</a>
+ <a href="${tg.url('/admin/edit/' + str(election.id) + '?removeembargo=1')}">Remove Embargo</a>
</py:if>
</td>
</tr>
</table>
+ <p><a href="${tg.url('/admin/newe/')}">Create a new election</a></p>
</body>
</html>
commit 22d0dc5c2e8ba52ba2c8c6594fe5c6cb1f5e2a2a
Author: Mark Chappell <tremble(a)tremble.org.uk>
Date: Mon May 17 15:27:10 2010 +0000
Add in code to have per election 'admins'
diff --git a/elections/admin.py b/elections/admin.py
index ff32728..5424830 100644
--- a/elections/admin.py
+++ b/elections/admin.py
@@ -30,7 +30,7 @@ from turbogears import controllers, expose, flash, redirect, config
from turbogears import identity
from fedora.client import AuthError, AppError
from elections import model
-from elections.model import Elections, ElectionsTable, Candidates, LegalVoters
+from elections.model import Elections, ElectionsTable, Candidates, LegalVoters, ElectionAdmins
from datetime import datetime
@@ -99,11 +99,20 @@ class Admin(controllers.Controller):
entry.strip()
if len(entry) :
LegalVoters(election_id=kw['id'], group_name=entry)
+ for entry in kw['newadmins'].split("|"):
+ entry.strip()
+ if len(entry) :
+ LegalVoters(election_id=kw['id'], group_name=entry)
for key, value in kw.items():
if key.startswith('remove_'):
group = key[len('remove_'):]
for lv in LegalVoters.query.filter_by(election_id=kw['id'],group_name=group) :
session.delete(lv)
+ for key, value in kw.items():
+ if key.startswith('removeadmin_'):
+ group = key[len('removeadmin_'):]
+ for admin in ElectionAdmins.query.filter_by(election_id=kw['id'],group_name=group) :
+ session.delete(admin)
for entry in kw['newcandidates'].split("|"):
candidate = entry.split("!")
#Python doesn't have a good way of doing case/switch statements
@@ -164,11 +173,17 @@ class Admin(controllers.Controller):
candidates = Candidates.query.filter_by(election_id=election.id).all()
votergroups = LegalVoters.query.filter_by(election_id=election.id).all()
+ admingroups = ElectionAdmins.query.filter_by(election_id=election.id).all()
groupnamemap = {}
+ for g in admingroups:
+ try:
+ groupnamemap[g.group_name] = g.group_name + " (" + self.fas.group_by_name(g.group_name)['display_name'] +")"
+ except (AppError, AuthError, KeyError) :
+ groupnamemap[g.group_name] = g.group_name
for g in votergroups:
try:
groupnamemap[g.group_name] = g.group_name + " (" + self.fas.group_by_name(g.group_name)['display_name'] +")"
except (AppError, AuthError, KeyError) :
groupnamemap[g.group_name] = g.group_name
- return dict(e=election, candidates=candidates, groups=votergroups, groupnamemap=groupnamemap)
+ return dict(e=election, candidates=candidates, admingroups=admingroups, groups=votergroups, groupnamemap=groupnamemap)
diff --git a/elections/templates/admedit.html b/elections/templates/admedit.html
index ea008a3..db0801a 100644
--- a/elections/templates/admedit.html
+++ b/elections/templates/admedit.html
@@ -40,6 +40,16 @@
<tr><td></td><td><input type="submit" name="submit" value="Submit"/></td></tr>
<tr>
+ <th colspan="2"> Admin Groups </th>
+ </tr>
+ <tr py:for="g in admingroups">
+ <td> ${groupnamemap[g.group_name]} </td>
+ <td>Remove group: <input type="checkbox" name="removeadmin_${g.group_name}" /> </td>
+ </tr>
+ <tr><td>New Groups:<br/>( entries seperated by | )</td><td><input type="text" name="newadmins" value="" /> </td></tr>
+ <tr><td></td><td><input type="submit" name="submit" value="Submit"/></td></tr>
+
+ <tr>
<th colspan="2"> Candidates </th>
</tr>
<tr py:for="c in candidates">
commit cd829b0246abec1747bb7aa85af25278c2d6846a
Author: Mark Chappell <tremble(a)tremble.org.uk>
Date: Mon May 10 19:42:01 2010 +0000
initial code for election 'admins', so far this only allows the bypassing of an embargo
diff --git a/elections.sql b/elections.sql
index 2f0636c..481e500 100644
--- a/elections.sql
+++ b/elections.sql
@@ -25,6 +25,7 @@ CREATE TABLE elections (
embargoed integer default 0 NOT NULL,
usefas integer default 0 NOT NULL,
allow_nominations integer default 0 NOT NULL,
+ nominations_until timestamp without time zone,
unique (shortdesc),
primary key (id)
);
@@ -50,6 +51,14 @@ CREATE TABLE legalvoters (
primary key (id)
);
+CREATE TABLE electionadmins (
+ id serial,
+ election_id integer not null,
+ group_name text not null,
+ foreign key (election_id) references elections (id),
+ primary key (id)
+);
+
CREATE TABLE votes (
id serial,
voter text NOT NULL,
diff --git a/elections/controllers.py b/elections/controllers.py
index bc98015..754a6da 100644
--- a/elections/controllers.py
+++ b/elections/controllers.py
@@ -141,8 +141,17 @@ class Root(controllers.RootController):
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.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("/")
+ if identity.in_group('elections') :
+ pass
+ else :
+ match = 0
+ admingroups = ElectionAdmins.query.filter_by(election_id=eid).all()
+ for group in admingroups:
+ if identity.in_group(group.group_name):
+ match = 1
+ if match == 0:
+ turbogears.flash("Meep, 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()
return dict(votecount=votecount, usernamemap=usernamemap, election=election, appTitle=self.appTitle)
diff --git a/elections/model.py b/elections/model.py
index c93cd43..4a024ea 100644
--- a/elections/model.py
+++ b/elections/model.py
@@ -28,6 +28,7 @@ ElectionsTable = Table('elections', metadata, autoload=True)
VotesTable = Table('votes', metadata, autoload=True)
CandidatesTable = Table('candidates', metadata, autoload=True)
LegalVotersTable = Table('legalvoters', metadata, autoload=True)
+ElectionAdminsTable = Table('electionadmins', metadata, autoload=True)
# View in the DB. Needs to have the column keys defined
VoteTallyTable = Table('fvotecount', metadata,
@@ -59,6 +60,9 @@ class Candidates(SABase):
class LegalVoters(SABase):
pass
+class ElectionAdmins(SABase):
+ pass
+
class VoteTally(SABase):
pass
@@ -80,5 +84,6 @@ mapper(Candidates, CandidatesTable, properties = {
'tally': relation(VoteTally, backref='candidate')
})
mapper(LegalVoters, LegalVotersTable)
+mapper(ElectionAdmins, ElectionAdminsTable)
mapper(VoteTally, VoteTallyTable)
mapper(UserVoteCount, UserVoteCountTable)
commit 03b1b7617576c5b9c9df32d4615c5e624f82402d
Author: Mark Chappell <tremble(a)tremble.org.uk>
Date: Mon May 10 19:11:35 2010 +0000
Split the main elections lists into 3, Past, Present, Future
diff --git a/elections/controllers.py b/elections/controllers.py
index e969067..bc98015 100644
--- a/elections/controllers.py
+++ b/elections/controllers.py
@@ -55,8 +55,19 @@ class Root(controllers.RootController):
@expose(template="elections.templates.index")
def index(self):
- electlist = Elections.query.order_by(ElectionsTable.c.start_date).filter('id>0').all()
- return dict(elections=electlist, curtime=datetime.utcnow(), appTitle=self.appTitle)
+ elections = Elections.query.order_by(ElectionsTable.c.start_date).filter('id>0').all()
+ past = []
+ current = []
+ future = []
+ now = datetime.utcnow()
+ for e in elections:
+ if e.start_date > now :
+ future.append(e)
+ elif e.end_date < now :
+ past.append(e)
+ else :
+ current.append(e)
+ return dict(past=past, current=current, future=future, curtime=datetime.utcnow(), appTitle=self.appTitle)
@expose(template="elections.templates.about")
def about(self,eid=None):
diff --git a/elections/templates/index.html b/elections/templates/index.html
index 12dfdbb..09176d5 100644
--- a/elections/templates/index.html
+++ b/elections/templates/index.html
@@ -7,15 +7,44 @@
<title>Fedora Elections</title>
</head>
<body>
+
+ <py:if test="len(current)">
+ <h2>Current Elections</h2>
<table>
<tr>
<th></th>
<th>Start Date (UTC)</th>
<th>End Date (UTC)</th>
<th></th>
+ </tr>
+ <tr py:for="election in current">
+ <td>${election.shortdesc}</td>
+ <td>${election.start_date}</td>
+ <td>${election.end_date}</td>
+ <td>
+ <py:choose test="1">
+ <py:when test="election.alias == ''">
+ <a href="${tg.url('/about/' + str(election.id))}">More Information</a>
+ </py:when>
+ <py:otherwise>
+ <a href="${tg.url('/about/' + str(election.alias))}">More Information</a>
+ </py:otherwise>
+ </py:choose>
+ </td>
+ </tr>
+ </table>
+ </py:if>
+
+ <py:if test="len(future)">
+ <h2>Elections Coming soon...</h2>
+ <table>
+ <tr>
+ <th></th>
+ <th>Start Date (UTC)</th>
+ <th>End Date (UTC)</th>
<th></th>
</tr>
- <tr py:for="election in elections">
+ <tr py:for="election in future">
<td>${election.shortdesc}</td>
<td>${election.start_date}</td>
<td>${election.end_date}</td>
@@ -29,19 +58,54 @@
</py:otherwise>
</py:choose>
</td>
+ </tr>
+ </table>
+ </py:if>
+
+ <py:if test="len(past)">
+ <h2>Past Elections</h2>
+ <table>
+ <tr>
+ <th></th>
+ <th>Start Date (UTC)</th>
+ <th>End Date (UTC)</th>
+ <th></th>
+ <th></th>
+ </tr>
+ <tr py:for="election in past">
+ <td>${election.shortdesc}</td>
+ <td>${election.start_date}</td>
+ <td>${election.end_date}</td>
<td>
- <py:if test="curtime > election.end_date">
<py:choose test="1">
<py:when test="election.alias == ''">
- <a href="${tg.url('/results/' + str(election.id))}">Results</a>
+ <a href="${tg.url('/about/' + str(election.id))}">More Information</a>
</py:when>
<py:otherwise>
- <a href="${tg.url('/results/' + str(election.alias))}">Results</a>
+ <a href="${tg.url('/about/' + str(election.alias))}">More Information</a>
</py:otherwise>
</py:choose>
- </py:if>
+ </td>
+ <td>
+ <py:choose test="1">
+ <py:when test="0 == election.embargoed">
+ <py:choose test="1">
+ <py:when test="election.alias == ''">
+ <a href="${tg.url('/results/' + str(election.id))}">Results</a>
+ </py:when>
+ <py:otherwise>
+ <a href="${tg.url('/results/' + str(election.alias))}">Results</a>
+ </py:otherwise>
+ </py:choose>
+ </py:when>
+ <py:otherwise>
+ Election Results under Embargo
+ </py:otherwise>
+ </py:choose>
</td>
</tr>
</table>
+ </py:if>
+
</body>
</html>
14 years
3 commits - elections/admin.py elections/templates
by tremble
elections/admin.py | 17 +++++++++++++++--
elections/templates/admedit.html | 15 +++++++++++++++
elections/templates/vote.html | 7 +++++--
3 files changed, 35 insertions(+), 4 deletions(-)
New commits:
commit b175fd0e54560f2163a6dfc76d5e1c3224211a5f
Author: Mark Chappell <tremble(a)tremble.org.uk>
Date: Wed May 5 16:59:53 2010 +0000
Add candidates through the Election Edit page
diff --git a/elections/admin.py b/elections/admin.py
index dcb742f..ff32728 100644
--- a/elections/admin.py
+++ b/elections/admin.py
@@ -104,6 +104,17 @@ class Admin(controllers.Controller):
group = key[len('remove_'):]
for lv in LegalVoters.query.filter_by(election_id=kw['id'],group_name=group) :
session.delete(lv)
+ for entry in kw['newcandidates'].split("|"):
+ candidate = entry.split("!")
+ #Python doesn't have a good way of doing case/switch statements
+ if len(candidate) == 1:
+ if len(candidate[0]) :
+ Candidates(election_id=kw['id'],name=candidate[0], status=0, human=1)
+ elif len(candidate) == 2:
+ if len(candidate[0]) :
+ Candidates(election_id=kw['id'],name=candidate[0],url=candidate[1], status=0, human=1)
+ else:
+ turbogears.flash("There was an issue!")
setembargo=1
usefas=1
nominations=1
diff --git a/elections/templates/admedit.html b/elections/templates/admedit.html
index 2052a1e..ea008a3 100644
--- a/elections/templates/admedit.html
+++ b/elections/templates/admedit.html
@@ -26,6 +26,7 @@
<tr><td>Use FAS?</td><td><input type="checkbox" name="usefas" py:attrs="{'checked':''} if e.usefas else {}" /> </td></tr>
<tr><td>Embargoed?</td><td><input type="checkbox" name="embargoed" py:attrs="{'checked':''} if e.embargoed else {}" /> </td></tr>
<tr><td></td><td><input type="submit" name="submit" value="Submit"/></td></tr>
+
<tr>
<th colspan="2"> Allowed Groups </th>
</tr>
@@ -37,6 +38,20 @@
</tr>
<tr><td>New Groups:<br/>( entries seperated by | )</td><td><input type="text" name="newgroups" value="" /> </td></tr>
<tr><td></td><td><input type="submit" name="submit" value="Submit"/></td></tr>
+
+ <tr>
+ <th colspan="2"> Candidates </th>
+ </tr>
+ <tr py:for="c in candidates">
+ <td>
+ ${c.name}
+ </td>
+ <td>
+ ${c.url}
+ </td>
+ </tr>
+ <tr><td>New Candidates:<br/>( Formated as [URL optional]: Name1!URL1|Name2!URL2 )</td><td><input type="text" name="newcandidates" value="" /> </td></tr>
+ <tr><td></td><td><input type="submit" name="submit" value="Submit"/></td></tr>
</table>
</form>
</body>
commit 27c29720fc4e211062ea4e1e4ec6582590a3ef2a
Author: Mark Chappell <tremble(a)tremble.org.uk>
Date: Wed May 5 16:58:01 2010 +0000
https://fedorahosted.org/elections/ticket/26
diff --git a/elections/templates/vote.html b/elections/templates/vote.html
index 8ee3ee8..7887c69 100644
--- a/elections/templates/vote.html
+++ b/elections/templates/vote.html
@@ -20,7 +20,7 @@
xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="master.html" />
<head>
- <title>${appTitle} -- Cast Your Vote</title>
+ <title>${appTitle} -- Cast Your Vote -- ${election.shortdesc}</title>
</head>
<body>
<h1>${election.shortdesc}</h1>
@@ -42,7 +42,10 @@
</tr>
<tr>
<td><input py:if="nextaction=='confirm'" type="button" value="Go Back" onClick="history.go(-1)" /></td>
- <td><input type="submit" name="${nextaction}" value="Submit" /></td>
+ <td>
+ <input py:if="nextaction!='confirm'" type="submit" name="${nextaction}" value="Preview" />
+ <input py:if="nextaction=='confirm'" type="submit" name="${nextaction}" value="Submit" />
+ </td>
</tr>
</table>
</form>
commit a3c5380ca0dadc4545756cf06217f52c6c12ac39
Author: Mark Chappell <tremble(a)tremble.org.uk>
Date: Wed May 5 16:17:15 2010 +0000
Redirect to the edit page when you create an election
diff --git a/elections/admin.py b/elections/admin.py
index 403fefb..dcb742f 100644
--- a/elections/admin.py
+++ b/elections/admin.py
@@ -67,8 +67,10 @@ class Admin(controllers.Controller):
if "usefas" not in kw:
usefas=0
- Elections(alias=kw['alias'], status=0, method=0, shortdesc=kw['shortdesc'], description=kw['info'], url=kw['url'], start_date=kw['startdate'], end_date=kw['enddate'], embargoed=setembargo, seats_elected=kw['seats'],usefas=usefas,votes_per_user=1)
- raise turbogears.redirect("/")
+ election = Elections(alias=kw['alias'], status=0, method=0, shortdesc=kw['shortdesc'], description=kw['info'], url=kw['url'], start_date=kw['startdate'], end_date=kw['enddate'], embargoed=setembargo, seats_elected=kw['seats'],usefas=usefas,votes_per_user=1)
+ turbogears.flash("New Election Created")
+ session.save(election)
+ raise turbogears.redirect("/admin/edit/"+str(election.alias))
else:
return dict()
14 years
7 commits - elections/admin.py elections/controllers.py elections/templates
by tremble
elections/admin.py | 91 ++++++++++++++++++++++++++++++++-------
elections/controllers.py | 20 +++++---
elections/templates/about.html | 28 +++++++++---
elections/templates/admedit.html | 45 +++++++++++++------
elections/templates/admin.html | 36 +++++++++++++++
elections/templates/index.html | 26 +++++++++--
elections/templates/verify.html | 6 +-
7 files changed, 203 insertions(+), 49 deletions(-)
New commits:
commit a14d85ffd99cbd24de92a99bc9f60e7cb86f5ee4
Author: tremble <tremble(a)publictest1.fedoraproject.org>
Date: Thu Apr 29 08:39:25 2010 +0000
More coping with missing aliases
diff --git a/elections/templates/about.html b/elections/templates/about.html
index 2b8158e..4994709 100644
--- a/elections/templates/about.html
+++ b/elections/templates/about.html
@@ -4,7 +4,7 @@
xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="master.html" />
<head>
- <title>${appTitle} -- Election Information</title>
+ <title>Fedora Elections -- Election Information</title>
</head>
<body>
<h1>${election.shortdesc}</h1>
@@ -17,18 +17,34 @@
<py:choose test="curtime > election.end_date"><py:when test="0">
<py:choose test="election.start_date > curtime"><py:when test="0">
<tr>
- <td><a href="${tg.url('/vote/' + election.alias)}">Vote Now!</a></td>
+ <td>
+ <py:choose test="1">
+ <py:when test="election.alias == ''">
+ <a href="${tg.url('/vote/' + str(election.id))}">Vote Now!</a>
+ </py:when>
+ <py:otherwise>
+ <a href="${tg.url('/vote/' + str(election.alias))}">Vote Now!</a>
+ </py:otherwise>
+ </py:choose>
+ </td>
</tr>
</py:when></py:choose>
</py:when><py:when test="1">
- <tr>
- <td><a href="${tg.url('/results/' + election.alias)}">Show Results!</a></td>
- </tr>
+ <tr>
+ <py:choose test="1">
+ <py:when test="election.alias == ''">
+ <a href="${tg.url('/results/' + str(election.id))}">Show Results!</a>
+ </py:when>
+ <py:otherwise>
+ <a href="${tg.url('/results/' + str(election.alias))}">Show Results!</a>
+ </py:otherwise>
+ </py:choose>
+ </tr>
</py:when></py:choose>
</table>
<p>To vote in this election you must be a member of any one of the following groups:</p>
<ul>
- <li py:for="g in votergroups"><py:choose test="g.group_name == 'anyany'"><py:when test="0"><py:choose test="g.group_name == 'anycla'"><py:when test="0">${g.group_name}</py:when><py:when test="1">Any non-CLA Group</py:when></py:choose></py:when><py:when test="1">Any Group</py:when></py:choose></li>
+ <li py:for="g in votergroups"><py:choose test="g.group_name == 'anyany'"><py:when test="0"><py:choose test="g.group_name == 'anycla'"><py:when test="0">${groupnamemap[g.group_name]}</py:when><py:when test="1">Any non-CLA Group</py:when></py:choose></py:when><py:when test="1">Any Group</py:when></py:choose></li>
</ul>
</body>
</html>
diff --git a/elections/templates/index.html b/elections/templates/index.html
index 4bb4706..12dfdbb 100644
--- a/elections/templates/index.html
+++ b/elections/templates/index.html
@@ -29,7 +29,18 @@
</py:otherwise>
</py:choose>
</td>
- <td><a py:if="curtime > election.end_date" href="${tg.url('/results/' + str(election.alias))}">Results</a></td>
+ <td>
+ <py:if test="curtime > election.end_date">
+ <py:choose test="1">
+ <py:when test="election.alias == ''">
+ <a href="${tg.url('/results/' + str(election.id))}">Results</a>
+ </py:when>
+ <py:otherwise>
+ <a href="${tg.url('/results/' + str(election.alias))}">Results</a>
+ </py:otherwise>
+ </py:choose>
+ </py:if>
+ </td>
</tr>
</table>
</body>
diff --git a/elections/templates/verify.html b/elections/templates/verify.html
index 6b65995..0dbea59 100644
--- a/elections/templates/verify.html
+++ b/elections/templates/verify.html
@@ -4,18 +4,18 @@
xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="master.html" />
<head>
- <title>${appTitle}</title>
+ <title>Fedora Elections -- Vote Verification -- ${election.shortdesc}</title>
</head>
<body>
<h1>Vote Verification Page</h1>
<p>Please check the below content to ensure that all of your cast votes are marked as 'valid', if you notice any elections showing that you have an invalid vote cast please contact the election administration team by creating a ticket at the <a href="https://fedorahosted.org/fedora-infrastructure/">Fedora Infrastructure ticket system</a> and select the 'Elections' component with your FAS username and the election that is marked as invalid.</p>
<h2 py:if="validvotes">Valid Votes</h2>
<ul py:if="validvotes">
- <li py:for="vote in validvotes"><a href="${tg.url('/about/' + validvotes[vote].election.alias)}">${validvotes[vote].election.shortdesc}</a></li>
+ <li py:for="vote in validvotes"><a href="${tg.url('/about/' + validvotes[vote].election.id)}">${validvotes[vote].election.shortdesc}</a></li>
</ul>
<h2 py:if="invalidvotes">Invalid Votes</h2>
<ul py:if="invalidvotes">
- <li py:for="vote in invalidvotes"><a href="${tg.url('/about/' + invalidvotes[vote].election.alias)}">${invalidvotes[vote].election.shortdesc}</a></li>
+ <li py:for="vote in invalidvotes"><a href="${tg.url('/about/' + invalidvotes[vote].election.id)}">${invalidvotes[vote].election.shortdesc}</a></li>
</ul>
</body>
commit 20fcb5c4f22b9e29a2106ef4ddebcb92a7ddf71f
Author: tremble <tremble(a)publictest1.fedoraproject.org>
Date: Thu Apr 29 08:16:41 2010 +0000
Cope slightly better with a lack of alias when displaying lists of elections
diff --git a/elections/admin.py b/elections/admin.py
index 560d488..403fefb 100644
--- a/elections/admin.py
+++ b/elections/admin.py
@@ -131,12 +131,22 @@ class Admin(controllers.Controller):
raise turbogears.redirect("/admin/edit/"+kw['id'])
try:
- election = Elections.query.filter_by(id=int(eid)).all()[0]
+ eid = int(eid)
+ election = Elections.query.filter_by(id=eid).all()[0]
except ValueError:
- election = Elections.query.filter_by(alias=eid).all()[0]
+ try:
+ 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.")
+ raise turbogears.redirect("/admin/")
+ except (IndexError, TypeError):
+ turbogears.flash("This election does not exist, check if you have used the correct URL.")
+ raise turbogears.redirect("/admin/")
if "removeembargo" in kw:
election.embargoed=0
+ turbogears.flash("Embargo on election results removed")
raise turbogears.redirect("/admin/")
candidates = Candidates.query.filter_by(election_id=election.id).all()
diff --git a/elections/controllers.py b/elections/controllers.py
index 6817015..e969067 100644
--- a/elections/controllers.py
+++ b/elections/controllers.py
@@ -70,7 +70,7 @@ class Root(controllers.RootController):
except IndexError:
turbogears.flash("This election does not exist, check if you have used the correct URL.")
raise turbogears.redirect("/")
- except IndexError:
+ except (IndexError, TypeError):
turbogears.flash("This election does not exist, check if you have used the correct URL.")
raise turbogears.redirect("/")
@@ -108,7 +108,7 @@ class Root(controllers.RootController):
except IndexError:
turbogears.flash("This election does not exist, check if you have used the correct URL.")
raise turbogears.redirect("/")
- except IndexError:
+ except (IndexError, TypeError):
turbogears.flash("This election does not exist, check if you have used the correct URL.")
raise turbogears.redirect("/")
diff --git a/elections/templates/index.html b/elections/templates/index.html
index 73d2e09..4bb4706 100644
--- a/elections/templates/index.html
+++ b/elections/templates/index.html
@@ -4,7 +4,7 @@
xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="master.html" />
<head>
- <title>${appTitle}</title>
+ <title>Fedora Elections</title>
</head>
<body>
<table>
@@ -19,7 +19,16 @@
<td>${election.shortdesc}</td>
<td>${election.start_date}</td>
<td>${election.end_date}</td>
- <td><a href="${tg.url('/about/' + str(election.alias))}">More Information</a></td>
+ <td>
+ <py:choose test="1">
+ <py:when test="election.alias == ''">
+ <a href="${tg.url('/about/' + str(election.id))}">More Information</a>
+ </py:when>
+ <py:otherwise>
+ <a href="${tg.url('/about/' + str(election.alias))}">More Information</a>
+ </py:otherwise>
+ </py:choose>
+ </td>
<td><a py:if="curtime > election.end_date" href="${tg.url('/results/' + str(election.alias))}">Results</a></td>
</tr>
</table>
commit c76029ac36fbdfeab8dd5f899d7c851dde42df17
Author: tremble <tremble(a)publictest1.fedoraproject.org>
Date: Wed Apr 28 17:18:59 2010 +0000
Final first hash of editing an election
diff --git a/elections/admin.py b/elections/admin.py
index fa24c2e..560d488 100644
--- a/elections/admin.py
+++ b/elections/admin.py
@@ -28,6 +28,7 @@
import turbogears
from turbogears import controllers, expose, flash, redirect, config
from turbogears import identity
+from fedora.client import AuthError, AppError
from elections import model
from elections.model import Elections, ElectionsTable, Candidates, LegalVoters
@@ -90,11 +91,61 @@ class Admin(controllers.Controller):
@identity.require(identity.in_group("elections"))
@expose(template="elections.templates.admedit")
- def edit(self,eid=None):
+ def edit(self, eid=None, **kw):
+ if "submit" in kw:
+ for entry in kw['newgroups'].split("|"):
+ entry.strip()
+ if len(entry) :
+ LegalVoters(election_id=kw['id'], group_name=entry)
+ for key, value in kw.items():
+ if key.startswith('remove_'):
+ group = key[len('remove_'):]
+ for lv in LegalVoters.query.filter_by(election_id=kw['id'],group_name=group) :
+ session.delete(lv)
+ setembargo=1
+ usefas=1
+ nominations=1
+ if "embargoed" not in kw:
+ setembargo=0
+ if "usefas" not in kw:
+ usefas=0
+ if "allownominations" not in kw:
+ nominations=0
+ try:
+ election = Elections.query.filter_by(id=int(eid)).all()[0]
+ except ValueError:
+ election = Elections.query.filter_by(alias=eid).all()[0]
+ election.alias=kw['alias']
+ election.status=0
+ election.method=0
+ election.shortdesc=kw['shortdesc']
+ election.description=kw['info']
+ election.url=kw['url']
+ election.start_date=kw['startdate']
+ election.end_date=kw['enddate']
+ election.embargoed=setembargo
+ election.seats_elected=kw['seats']
+ election.usefas=usefas
+ election.votes_per_user=kw['votes']
+ election.allow_nominations=nominations
+ raise turbogears.redirect("/admin/edit/"+kw['id'])
+
try:
election = Elections.query.filter_by(id=int(eid)).all()[0]
except ValueError:
election = Elections.query.filter_by(alias=eid).all()[0]
+
+ if "removeembargo" in kw:
+ election.embargoed=0
+ raise turbogears.redirect("/admin/")
+
candidates = Candidates.query.filter_by(election_id=election.id).all()
votergroups = LegalVoters.query.filter_by(election_id=election.id).all()
- return dict(e=election, candidates=candidates, groups=votergroups)
+ groupnamemap = {}
+ for g in votergroups:
+ try:
+ groupnamemap[g.group_name] = g.group_name + " (" + self.fas.group_by_name(g.group_name)['display_name'] +")"
+ except (AppError, AuthError, KeyError) :
+ groupnamemap[g.group_name] = g.group_name
+
+ return dict(e=election, candidates=candidates, groups=votergroups, groupnamemap=groupnamemap)
diff --git a/elections/templates/admedit.html b/elections/templates/admedit.html
index 71de65c..2052a1e 100644
--- a/elections/templates/admedit.html
+++ b/elections/templates/admedit.html
@@ -4,23 +4,40 @@
xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="master.html" />
<head>
- <title>Welcome to TurboGears</title>
+ <title>Fedora Elections -- Administration -- Election Details</title>
</head>
<body>
+ <form action="${tg.url('/admin/edit/' + str(e.alias))}" method="post">
<table>
- <tr><td>Election Name:</td><td><input type="text" name="name" value="${e.name}" /></td></tr>
- <tr><td>Short Name:</td><td><input type="text" name="shortname" value="${e.shortname}" /></td></tr>
- <tr><td>Election Info:</td><td><textarea name="info" rows="5" cols="40">${e.info}</textarea></td></tr>
+ <tr>
+ <th colspan="2"> Election Details - ${e.shortdesc} </th>
+ </tr>
+ <tr><td>Election ID:</td><td>${e.id}<input type="hidden" name="id" value="${e.id}" /></td></tr>
+ <tr><td>Election Name:</td><td><input type="text" name="shortdesc" value="${e.shortdesc}" /></td></tr>
+ <tr><td>Alias:</td><td><input type="text" name="alias" value="${e.alias}" /></td></tr>
+ <tr><td>URL:</td><td><input type="text" name="url" value="${e.url}" /></td></tr>
+ <tr><td>Election Info:</td><td><textarea name="info" rows="5" cols="40">${e.description}</textarea></td></tr>
+ <tr><td>Start Date:</td><td><input type="text" name="startdate" value="${e.start_date}" /></td></tr>
+ <tr><td>End Date:</td><td><input type="text" name="enddate" value="${e.end_date}" /></td></tr>
+ <tr><td>Seats Elected:</td><td><input type="text" name="seats" value="${e.seats_elected}" /></td></tr>
+ <tr><td>Votes Per User:</td><td><input type="text" name="votes" value="${e.votes_per_user}" /></td></tr>
+ <tr><td>Allow Nominations?</td><td><input type="checkbox" name="allownominations" py:attrs="{'checked':''} if e.allow_nominations else {}" /> </td></tr>
+ <tr><td>Until When?</td><td><input type="text" name="nominationend" value="" /> </td></tr>
+ <tr><td>Use FAS?</td><td><input type="checkbox" name="usefas" py:attrs="{'checked':''} if e.usefas else {}" /> </td></tr>
+ <tr><td>Embargoed?</td><td><input type="checkbox" name="embargoed" py:attrs="{'checked':''} if e.embargoed else {}" /> </td></tr>
+ <tr><td></td><td><input type="submit" name="submit" value="Submit"/></td></tr>
+ <tr>
+ <th colspan="2"> Allowed Groups </th>
+ </tr>
+ <tr py:for="g in groups">
+ <td>
+ <py:choose test="g.group_name == 'anyany'"><py:when test="0"><py:choose test="g.group_name == 'anycla'"><py:when test="0">${groupnamemap[g.group_name]}</py:when><py:when test="1">Any non-CLA Group</py:when></py:choose></py:when><py:when test="1">Any Group</py:when></py:choose>
+ </td>
+ <td>Remove group: <input type="checkbox" name="remove_${g.group_name}" /> </td>
+ </tr>
+ <tr><td>New Groups:<br/>( entries seperated by | )</td><td><input type="text" name="newgroups" value="" /> </td></tr>
+ <tr><td></td><td><input type="submit" name="submit" value="Submit"/></td></tr>
</table>
- <pre>
-Election ID: ${e.id}
-Election Name: ${e.name}
-Election ShortName: ${e.shortname}
-Election Info: ${e.info}
-URL: ${e.url}
-Start Date: ${e.start_date}
-End Date: ${e.end_date}
-max_seats ${e.max_seats}
- </pre>
+ </form>
</body>
</html>
diff --git a/elections/templates/admin.html b/elections/templates/admin.html
index de5a649..37c6f0e 100644
--- a/elections/templates/admin.html
+++ b/elections/templates/admin.html
@@ -26,7 +26,7 @@
<a href="${tg.url('/admin/edit/' + str(election.alias))}">More Information</a>
<py:if test="election.embargoed">
|
- <a href="${tg.url('/admin/edit/' + str(election.alias))}">Remove Embargo</a>
+ <a href="${tg.url('/admin/edit/' + str(election.alias) + '?removeembargo=1')}">Remove Embargo</a>
</py:if>
</td>
</tr>
commit e0676958fb291f5c5f6e01732e68563a6e91852b
Author: tremble <tremble(a)publictest1.fedoraproject.org>
Date: Wed Apr 28 17:16:47 2010 +0000
Add the magic to look up FAS Group names
diff --git a/elections/controllers.py b/elections/controllers.py
index b64a0fe..6817015 100644
--- a/elections/controllers.py
+++ b/elections/controllers.py
@@ -28,7 +28,7 @@ from turbogears import identity
from turbogears.database import session
from cherrypy import request, response
-from fedora.client import AuthError
+from fedora.client import AuthError, AppError
from fedora.client.fas2 import AccountSystem
from fedora.tg.controllers import login as fc_login
from fedora.tg.controllers import logout as fc_logout
@@ -77,6 +77,7 @@ class Root(controllers.RootController):
votergroups = LegalVoters.query.filter_by(election_id=eid).all()
candidates = Candidates.query.filter_by(election_id=eid).order_by(Candidates.name).all()
usernamemap = {}
+ groupnamemap = {}
if election.usefas:
for c in candidates:
@@ -85,10 +86,15 @@ class Root(controllers.RootController):
except (KeyError, AuthError):
# User has their name set to private or user doesn't exist
usernamemap[c.id] = c.name
+ for g in votergroups:
+ try:
+ groupnamemap[g.group_name] = g.group_name + " (" + self.fas.group_by_name(g.group_name)['display_name'] +")"
+ except (AppError, AuthError, KeyError) :
+ groupnamemap[g.group_name] = g.group_name
curtime = datetime.utcnow()
- return dict(eid=eid, candidates=candidates, usernamemap=usernamemap, election=election, curtime=curtime, votergroups=votergroups, appTitle=self.appTitle)
+ return dict(eid=eid, candidates=candidates, usernamemap=usernamemap, election=election, curtime=curtime, votergroups=votergroups, appTitle=self.appTitle, groupnamemap=groupnamemap)
@expose(template="elections.templates.results")
def results(self,eid=None):
commit 13ebc0f0f47342d038a1c8165b3bc0c2ad8e5720
Author: tremble <tremble(a)publictest1.fedoraproject.org>
Date: Wed Apr 28 12:15:55 2010 +0000
Controller for early bash at an admin homepage
diff --git a/elections/admin.py b/elections/admin.py
index a9fd772..fa24c2e 100644
--- a/elections/admin.py
+++ b/elections/admin.py
@@ -48,11 +48,12 @@ class Admin(controllers.Controller):
elections = [{'id': e.id, 'alias': e.alias, 'shortdesc': e.shortdesc, 'start_date': e.start_date, 'end_date': e.end_date, 'legal_voters': [{'groupname': lv.group_name} for lv in LegalVoters.query.filter_by(election_id=e.id)]} for e in electlist]
return dict(elections=elections, servertime=datetime.utcnow(), appTitle=self.appTitle)
- #@expose(template='elections.templates.adminlist')
+ @expose(template='elections.templates.admin')
@identity.require(identity.in_group("elections"))
- @expose()
def index(self, **kw):
- return "Hi"
+ electlist = Elections.query.order_by(ElectionsTable.c.start_date).filter('id>0').all()
+ elections = [{'id': e.id, 'alias': e.alias, 'shortdesc': e.shortdesc, 'start_date': e.start_date, 'end_date': e.end_date, 'legal_voters': [{'groupname': lv.group_name} for lv in LegalVoters.query.filter_by(election_id=e.id)], 'embargoed' : e.embargoed} for e in electlist]
+ return dict(elections=elections)
@identity.require(identity.in_group("elections"))
@expose(template="elections.templates.admnewe")
@@ -87,16 +88,13 @@ class Admin(controllers.Controller):
else:
return dict()
- #@expose(template="elections.templates.admedit")
- #def edit(self,eid=None):
- # try:
- # election = Elections.query.filter_by(id=int(eid)).all()[0]
- # except ValueError:
- # election = Elections.query.filter_by(shortname=eid).all()[0]
- # election = Elections.query.filter_by(id=int(eid)).all()[0]
- # candidates = Candidates.query.filter_by(election_id=eid).all()
- # return dict(e=election, candidates=candidates)
-
- #@expose()
- #def save(self, **kw):
- # return "Hi"
+ @identity.require(identity.in_group("elections"))
+ @expose(template="elections.templates.admedit")
+ def edit(self,eid=None):
+ try:
+ election = Elections.query.filter_by(id=int(eid)).all()[0]
+ except ValueError:
+ election = Elections.query.filter_by(alias=eid).all()[0]
+ candidates = Candidates.query.filter_by(election_id=election.id).all()
+ votergroups = LegalVoters.query.filter_by(election_id=election.id).all()
+ return dict(e=election, candidates=candidates, groups=votergroups)
commit e263943a71cc3e681dbf93899de12adcc0eb122e
Author: tremble <tremble(a)publictest1.fedoraproject.org>
Date: Wed Apr 28 12:15:23 2010 +0000
Also catch AuthErrors, generally caused by not being able to fully log into FAS
diff --git a/elections/controllers.py b/elections/controllers.py
index 2c0fd0e..b64a0fe 100644
--- a/elections/controllers.py
+++ b/elections/controllers.py
@@ -28,6 +28,7 @@ from turbogears import identity
from turbogears.database import session
from cherrypy import request, response
+from fedora.client import AuthError
from fedora.client.fas2 import AccountSystem
from fedora.tg.controllers import login as fc_login
from fedora.tg.controllers import logout as fc_logout
@@ -52,7 +53,6 @@ class Root(controllers.RootController):
admin = Admin(fas, appTitle)
vote = Vote(fas, appTitle)
-
@expose(template="elections.templates.index")
def index(self):
electlist = Elections.query.order_by(ElectionsTable.c.start_date).filter('id>0').all()
@@ -82,8 +82,8 @@ class Root(controllers.RootController):
for c in candidates:
try:
usernamemap[c.id] = self.fas.person_by_username(c.name)['human_name']
- except KeyError:
- # User has their name set to private
+ except (KeyError, AuthError):
+ # User has their name set to private or user doesn't exist
usernamemap[c.id] = c.name
curtime = datetime.utcnow()
@@ -112,7 +112,7 @@ class Root(controllers.RootController):
for c in election.candidates:
try:
usernamemap[c.id] = self.fas.person_by_username(c.name)['human_name']
- except KeyError:
+ except (AuthError, KeyError) :
# User has their name set to private
usernamemap[c.id] = c.name
commit 98d5eac9661f8cd516a1d9af36861cbc55c3f985
Author: tremble <tremble(a)publictest1.fedoraproject.org>
Date: Wed Apr 28 12:14:17 2010 +0000
Early bashes at an admin homepage
diff --git a/elections/templates/admin.html b/elections/templates/admin.html
new file mode 100644
index 0000000..de5a649
--- /dev/null
+++ b/elections/templates/admin.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:py="http://genshi.edgewall.org/"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <xi:include href="master.html" />
+ <head>
+ <title>Fedora Elections -- Administration</title>
+ </head>
+ <body>
+ <table>
+ <tr>
+ <th>ID</th>
+ <th>Name</th>
+ <th>Alias</th>
+ <th>Start Date</th>
+ <th>End Date</th>
+ <th></th>
+ </tr>
+ <tr py:for="election in elections">
+ <td>${election.id}</td>
+ <td>${election.shortdesc}</td>
+ <td>${election.alias}</td>
+ <td>${election.start_date}</td>
+ <td>${election.end_date}</td>
+ <td>
+ <a href="${tg.url('/admin/edit/' + str(election.alias))}">More Information</a>
+ <py:if test="election.embargoed">
+ |
+ <a href="${tg.url('/admin/edit/' + str(election.alias))}">Remove Embargo</a>
+ </py:if>
+ </td>
+ </tr>
+ </table>
+
+ </body>
+</html>
14 years