elections/vote.py
by Nigel Jones
elections/vote.py | 1 +
1 file changed, 1 insertion(+)
New commits:
commit ed49b75773809da7026a24845100a00f3719de20
Author: Nigel Jones <nigelj(a)fedoraproject.org>
Date: Sat Nov 28 10:25:16 2009 +1000
Missing import (oops!)
diff --git a/elections/vote.py b/elections/vote.py
index ebd4bc3..81083bc 100644
--- a/elections/vote.py
+++ b/elections/vote.py
@@ -36,6 +36,7 @@ import sqlalchemy
from turbogears.database import session
from datetime import datetime
+import re
class Vote(controllers.Controller):
def __init__(self, fas, appTitle):
14 years, 5 months
elections/release.py
by Nigel Jones
elections/release.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 2bb16ccaecbebe8db3f98e8ac1bafe5cdf24bcb1
Author: Nigel Jones <nigelj(a)fedoraproject.org>
Date: Sat Nov 28 08:24:25 2009 +1000
Bump to 0.2.0 for production
diff --git a/elections/release.py b/elections/release.py
index 9e68a7f..79a8b53 100644
--- a/elections/release.py
+++ b/elections/release.py
@@ -24,7 +24,7 @@
# Release information about elections
-version = "0.1.9"
+version = "0.2.0"
description = "Elections Application for Fedora Project"
# long_description = "More description about your plan"
14 years, 5 months
3 commits - elections/admin.py elections.sql
by Nigel Jones
elections.sql | 11 +++++++----
elections/admin.py | 2 +-
2 files changed, 8 insertions(+), 5 deletions(-)
New commits:
commit 40ee719fbf3da0ac056eab4b2dfc8303f8404691
Merge: 6e17390... a2db00d...
Author: Nigel Jones <nigelj(a)fedoraproject.org>
Date: Sat Nov 28 08:21:26 2009 +1000
Merge branch 'master' of ssh://fedorahosted.org/git/elections
commit 6e17390790747975502d3d15d06498a3cc534db8
Author: Nigel Jones <nigelj(a)fedoraproject.org>
Date: Fri Nov 27 18:33:18 2009 +1000
Fix missing comma
diff --git a/elections/admin.py b/elections/admin.py
index 2f7f7d1..a9fd772 100644
--- a/elections/admin.py
+++ b/elections/admin.py
@@ -65,7 +65,7 @@ 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=usefasvotes_per_user=1)
+ 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("/")
else:
return dict()
commit e46114351faa5fe36c612f548831a9fd7fb9fbe6
Author: Nigel Jones <nigelj(a)fedoraproject.org>
Date: Fri Nov 27 17:44:17 2009 +1000
Minor update again to bring it in line with whats actually required.
diff --git a/elections.sql b/elections.sql
index 1b9a900..2f0636c 100644
--- a/elections.sql
+++ b/elections.sql
@@ -17,12 +17,14 @@ CREATE TABLE elections (
-- was info
description text NOT NULL,
url text NOT NULL,
- start_date timestamp NOT NULL,
- end_date timestamp NOT NULL,
+ start_date timestamp without time zone NOT NULL,
+ end_date timestamp without time zone NOT NULL,
-- was max_seats
seats_elected integer NOT NULL,
votes_per_user integer NOT NULL,
- embargoed integer default 0 not null,
+ embargoed integer default 0 NOT NULL,
+ usefas integer default 0 NOT NULL,
+ allow_nominations integer default 0 NOT NULL,
unique (shortdesc),
primary key (id)
);
@@ -32,6 +34,7 @@ CREATE TABLE candidates (
election_id integer NOT NULL,
name text NOT NULL,
url text,
+ formalname text,
human integer,
status integer,
foreign key (election_id) references elections (id),
@@ -50,7 +53,7 @@ CREATE TABLE legalvoters (
CREATE TABLE votes (
id serial,
voter text NOT NULL,
- "timestamp" timestamp without time zone NOT NULL,
+ timestamp timestamp without time zone NOT NULL,
candidate_id integer NOT NULL,
weight integer NOT NULL,
election_id integer NOT NULL,
14 years, 5 months
elections/templates
by Toshio くらとみ
elections/templates/master.html | 4 ++++
1 file changed, 4 insertions(+)
New commits:
commit a2db00dc08b455d29eb3b1c1afc670c8987ce291
Author: Toshio Kuratomi <toshio(a)fedoraproject.org>
Date: Fri Nov 27 14:17:44 2009 -0800
Fix erroneous removal of tg_flash from the master template.
diff --git a/elections/templates/master.html b/elections/templates/master.html
index 42fdc45..33f5ce1 100644
--- a/elections/templates/master.html
+++ b/elections/templates/master.html
@@ -33,6 +33,10 @@
<ul class="toolbar" id="#main-toolbar">
<logintoolitem href="${tg.url('/')}" />
</ul>
+ <div py:if="tg_flash" class="flash">
+ ${tg_flash}
+ </div>
+
<div py:replace="select('*|text()')" />
</div>
<p>
14 years, 5 months
elections.sql
by Nigel Jones
elections.sql | 77 +++++++++++++++++++++++++++++++++++++++++-----------------
usefas | 51 +++++++-------------------------------
2 files changed, 65 insertions(+), 63 deletions(-)
New commits:
commit c3beb687935a4c1301a444ace6e7ab3bbca87db6
Author: Nigel Jones <nigelj(a)fedoraproject.org>
Date: Fri Nov 27 17:36:32 2009 +1000
Changes/updates to SQL schema
diff --git a/elections.sql b/elections.sql
index 7f1a6c9..1b9a900 100644
--- a/elections.sql
+++ b/elections.sql
@@ -1,82 +1,78 @@
-drop table if exists votes;
-drop table if exists candidates;
-drop table if exists legalvoters;
-drop table if exists elections;
-drop view if exists votecount;
-drop view if exists fvotecount;
-drop view if exists uservotes;
+drop view electionvotes;
+drop view fvotecount;
+drop view votecount;
+drop view uservotes;
+
+drop table votes;
+drop table legalvoters;
+drop table candidates;
+drop table elections;
CREATE TABLE elections (
-id integer NOT NULL auto_increment,
--- Old 'shortname'
-alias varchar(50) NOT NULL,
--- Numerical value, specifying what stage the election is in
-status tinyint NOT NULL,
--- Numerical value, specifying what voting method is used
-method tinyint NOT NULL,
+ id serial NOT NULL,
+-- was shortname
+ shortdesc text NOT NULL,
+-- was name
+ alias text NOT NULL,
+-- was info
+ description text NOT NULL,
+ url text NOT NULL,
+ start_date timestamp NOT NULL,
+ end_date timestamp NOT NULL,
+-- was max_seats
+ seats_elected integer NOT NULL,
+ votes_per_user integer NOT NULL,
+ embargoed integer default 0 not null,
+ unique (shortdesc),
+ primary key (id)
+);
-shortdesc text NOT NULL,
-description text NOT NULL,
+CREATE TABLE candidates (
+ id serial,
+ election_id integer NOT NULL,
+ name text NOT NULL,
+ url text,
+ human integer,
+ status integer,
+ foreign key (election_id) references elections (id),
+ unique (id),
+ primary key (id, election_id)
+);
-url text,
-start_date timestamp DEFAULT 0 NOT NULL,
-end_date timestamp DEFAULT 0 NOT NULL,
--- Number of seats elected
-seats_elected integer NOT NULL,
--- Number of voters (filled post election)
+CREATE TABLE legalvoters (
+ 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,
+ "timestamp" timestamp without time zone NOT NULL,
+ candidate_id integer NOT NULL,
+ weight integer NOT NULL,
+ election_id integer NOT NULL,
+ foreign key (candidate_id) references candidates(id),
+ foreign key (election_id) references elections(id),
+ primary key (id)
+);
--- Does this election support nominations?
--- allow_nominations boolean NOT NULL,
--- If so, when do they have to be in by?
--- nomination_end timestamp DEFAULT 0,
--- Do we use FAS for candidate names?
--- usefas boolean NOT NULL,
-UNIQUE (alias),
-PRIMARY KEY (id)
-) ENGINE=InnoDB;
-CREATE TABLE legalvoters (
-id integer NOT NULL auto_increment,
-election_id integer NOT NULL,
-type integer NOT NULL,
-group_name text NOT NULL,
-FOREIGN KEY (election_id) references elections (id),
-INDEX (election_id, type),
-PRIMARY KEY (id)
-) ENGINE=InnoDB;
+CREATE VIEW electionvotes AS
+ SELECT votes.election_id, count(votes.election_id) AS novotes FROM votes GROUP BY votes.election_id;
-CREATE TABLE candidates (
-id integer NOT NULL auto_increment,
-election_id integer NOT NULL,
--- Numerical value, specifying candidates' "status"
-status tinyint NOT NULL,
-name text NOT NULL,
-url text,
-blurb text,
-nominated_by text,
-FOREIGN KEY (election_id) references elections (id),
-PRIMARY KEY (id, election_id)
-) ENGINE=InnoDB;
-CREATE TABLE votes (
-id integer NOT NULL auto_increment,
-voter text NOT NULL,
-candidate_id integer NOT NULL,
-weight integer NOT NULL,
-election_id integer NOT NULL,
--- unique(voter_id, candidate_id, election_id),
-FOREIGN KEY (candidate_id) references candidates (id),
-FOREIGN KEY (election_id) references elections (id),
-PRIMARY KEY (id)
-) ENGINE=InnoDB;
-#CREATE TABLE questions (
-#
-#) ENGINE=InnoDB;
-create view votecount as select candidate_id, election_id, sum(weight) as novotes from votes group by candidate_id, election_id order by novotes desc;
+CREATE VIEW votecount AS
+ SELECT votes.candidate_id, votes.election_id, sum(votes.weight) AS novotes FROM votes GROUP BY votes.candidate_id, votes.election_id ORDER BY sum(votes.weight) DESC;
+
+
+CREATE VIEW fvotecount AS
+ SELECT c.id, c.name, v.election_id, v.novotes FROM votecount v, candidates c WHERE (c.id = v.candidate_id) ORDER BY v.novotes DESC;
-create view fvotecount as select c.id, c.name, v.election_id, v.novotes from votecount v, candidates c where c.id = v.candidate_id order by novotes desc;
-create view uservotes as select election_id, voter, count(voter) as novotes from votes group by election_id, voter;
+CREATE VIEW uservotes AS
+ SELECT votes.election_id, votes.voter, count(votes.voter) AS novotes FROM votes GROUP BY votes.election_id, votes.voter;
14 years, 5 months
elections/admin.py elections/controllers.py elections/templates
by Nigel Jones
elections/admin.py | 8 +-------
elections/controllers.py | 6 +++---
elections/templates/about.html | 6 ------
elections/templates/admnewe.html | 2 +-
4 files changed, 5 insertions(+), 17 deletions(-)
New commits:
commit 89dbb9eb0ce108971010a1f52cc475bf474695ca
Author: Nigel Jones <nigjones(a)njones.bne.redhat.com>
Date: Thu Nov 26 21:45:19 2009 +1000
Random fix ups to make the current code work as the old did.
Summary:
* Template Logic mess-ups (oops)
* DB inconsistencies (now works with new layout, migration steps ready to perform)
* Correction to toshio's CSRF/python-fedora patch
diff --git a/elections/admin.py b/elections/admin.py
index 6c4d428..2f7f7d1 100644
--- a/elections/admin.py
+++ b/elections/admin.py
@@ -59,19 +59,13 @@ class Admin(controllers.Controller):
def newe(self, **kw):
if "submit" in kw:
setembargo=1
- setnominations=1
- nominationend=0
usefas=1
if "embargoed" not in kw:
setembargo=0
- if "allownominations" not in kw:
- setnominations=0
- if "nominationend" in kw:
- nominationend=kw['nominationend']
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'], allow_nominations=setnominations, nomination_end=nominationend,usefas=usefas)
+ 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=usefasvotes_per_user=1)
raise turbogears.redirect("/")
else:
return dict()
diff --git a/elections/controllers.py b/elections/controllers.py
index 9365fce..be91cf5 100644
--- a/elections/controllers.py
+++ b/elections/controllers.py
@@ -29,8 +29,8 @@ from turbogears.database import session
from cherrypy import request, response
from fedora.client.fas2 import AccountSystem
-import fedora.tg.controllers.login as fc_login
-import fedora.tg.controllers.logout as fc_logout
+from fedora.tg.controllers import login as fc_login
+from fedora.tg.controllers import logout as fc_logout
from elections import model
from elections.model import *
from elections.admin import Admin
@@ -49,7 +49,7 @@ class Root(controllers.RootController):
password = config.get('fas.password', 'admin')
fas = AccountSystem(baseURL, username=username, password=password)
- api = Api(fas, appTitle)
+ admin = Admin(fas, appTitle)
vote = Vote(fas, appTitle)
diff --git a/elections/templates/about.html b/elections/templates/about.html
index 44655ef..2b8158e 100644
--- a/elections/templates/about.html
+++ b/elections/templates/about.html
@@ -16,15 +16,9 @@
</tr>
<py:choose test="curtime > election.end_date"><py:when test="0">
<py:choose test="election.start_date > curtime"><py:when test="0">
- <py:choose test="election.allow_nominations"><py:when test="1">
- <tr>
- <td><a href="${tg.url('/nominate/' + election.alias)}">Nominate Someone!</a></td>
- </tr>
- </py:when><py:when test="1">
<tr>
<td><a href="${tg.url('/vote/' + election.alias)}">Vote Now!</a></td>
</tr>
- </py:when></py:choose>
</py:when></py:choose>
</py:when><py:when test="1">
<tr>
diff --git a/elections/templates/admnewe.html b/elections/templates/admnewe.html
index eabaabc..b0a676d 100644
--- a/elections/templates/admnewe.html
+++ b/elections/templates/admnewe.html
@@ -7,7 +7,7 @@
<title>Welcome to TurboGears</title>
</head>
<body>
- <form action="${tg.url('/api/newe')}" method="post">
+ <form action="${tg.url('/admin/newe')}" method="post">
<table>
<tr><td>Election Name:</td><td><input type="text" name="shortdesc" /></td></tr>
<tr><td>Alias:</td><td><input type="text" name="alias" /></td></tr>
14 years, 5 months