From: John Dong Date: Fri, 31 Aug 2007 13:35:09 +0000 (-0400) Subject: Merge from head X-Git-Url: https://projects.mako.cc/source/selectricity/commitdiff_plain/a6c1e9a2e0cb4243fd48b83af0281eccef408b04?hp=f2db874f06622e5b7422dabc8e17396708277c56 Merge from head --- diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 524d743..c9388f6 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -14,6 +14,7 @@ class AccountController < ApplicationController #these methods provide basic functionality for the user login system #=================================================================== def login + return unless request.post? self.current_user = User.authenticate(params[:login], params[:password]) if logged_in? diff --git a/app/views/layouts/frontpage.rhtml b/app/views/layouts/frontpage.rhtml index 8f14c3a..6531dc4 100644 --- a/app/views/layouts/frontpage.rhtml +++ b/app/views/layouts/frontpage.rhtml @@ -11,6 +11,11 @@
diff --git a/app/views/quickvote/_result_approval.rhtml b/app/views/quickvote/_methodinfo_approval.rhtml similarity index 77% rename from app/views/quickvote/_result_approval.rhtml rename to app/views/quickvote/_methodinfo_approval.rhtml index a7e11ce..979c876 100644 --- a/app/views/quickvote/_result_approval.rhtml +++ b/app/views/quickvote/_methodinfo_approval.rhtml @@ -1,8 +1,5 @@ -

Approval Result

(This algorithm assumes that top two choices are "approved.")

-<%= render :partial => 'result', :object => @election.approval_result %> -

About Approval Voting

@@ -14,5 +11,3 @@ range that voters are allowed to express is extremely constrained: accept or not.

- -<%= render :partial => 'approval_table' %> \ No newline at end of file diff --git a/app/views/quickvote/_result_borda.rhtml b/app/views/quickvote/_methodinfo_borda.rhtml similarity index 84% rename from app/views/quickvote/_result_borda.rhtml rename to app/views/quickvote/_methodinfo_borda.rhtml index f81cbdb..cc3167c 100644 --- a/app/views/quickvote/_result_borda.rhtml +++ b/app/views/quickvote/_methodinfo_borda.rhtml @@ -1,7 +1,3 @@ -

Borda Count Results

- -<%= render :partial => 'result', :object => @election.borda_result %> -

About Borda Count

diff --git a/app/views/quickvote/_result_condorcet.rhtml b/app/views/quickvote/_methodinfo_condorcet.rhtml similarity index 82% rename from app/views/quickvote/_result_condorcet.rhtml rename to app/views/quickvote/_methodinfo_condorcet.rhtml index 77ce658..a02c1d7 100644 --- a/app/views/quickvote/_result_condorcet.rhtml +++ b/app/views/quickvote/_methodinfo_condorcet.rhtml @@ -1,7 +1,3 @@ -

Simple Condorcet Results

- -<%= render :partial => 'result', :object => @election.condorcet_result %> -

About Simple Cordorcet Voting

diff --git a/app/views/quickvote/_result_plurality.rhtml b/app/views/quickvote/_methodinfo_plurality.rhtml similarity index 83% rename from app/views/quickvote/_result_plurality.rhtml rename to app/views/quickvote/_methodinfo_plurality.rhtml index 86a9469..9411611 100644 --- a/app/views/quickvote/_result_plurality.rhtml +++ b/app/views/quickvote/_methodinfo_plurality.rhtml @@ -1,7 +1,3 @@ -

Plurality Results

- -<%= render :partial => 'result', :object => @election.plurality_result %> -

About Plurality Voting

@@ -15,4 +11,5 @@ post," "winner-take-all," "majoritarian" or "simple majority" voting.

+ <%= image_tag(graph_url( :action => 'plurality_pie', :id => @election ) )%> diff --git a/app/views/quickvote/_result_runoff.rhtml b/app/views/quickvote/_methodinfo_runoff.rhtml similarity index 90% rename from app/views/quickvote/_result_runoff.rhtml rename to app/views/quickvote/_methodinfo_runoff.rhtml index f242290..eaba2b1 100644 --- a/app/views/quickvote/_result_runoff.rhtml +++ b/app/views/quickvote/_methodinfo_runoff.rhtml @@ -1,6 +1,3 @@ -
-

Instant Runoff (IRV) Results

-

About Instant Runoff Voting

@@ -16,5 +13,3 @@ preferences (and so on), until one candidate achieves a majority.

by several other names.

- -
\ No newline at end of file diff --git a/app/views/quickvote/_result_ssd.rhtml b/app/views/quickvote/_methodinfo_ssd.rhtml similarity index 83% rename from app/views/quickvote/_result_ssd.rhtml rename to app/views/quickvote/_methodinfo_ssd.rhtml index e181184..e3ff831 100644 --- a/app/views/quickvote/_result_ssd.rhtml +++ b/app/views/quickvote/_methodinfo_ssd.rhtml @@ -1,7 +1,3 @@ -

Schulze Method Results

- -<%= render :partial => 'result', :object => @election.ssd_result %> -

About the Schulze Method

diff --git a/app/views/quickvote/_result.rhtml b/app/views/quickvote/_result.rhtml index b643224..e0ead6d 100644 --- a/app/views/quickvote/_result.rhtml +++ b/app/views/quickvote/_result.rhtml @@ -1,9 +1,10 @@ -<% %> +
<% if result.winner? and result.winners.length == 1%> -

The winner is: - <%=h @candidates[result.winner].name.capitalize %>

+

The winner is: + <%=h @candidates[result.winner].name.capitalize %>

<% elsif result.winner? and result.winners.length > 1 %> -

There was a tie. The winners are: <%=h( result.winners.collect {|w| @candidates[w].to_s.capitalize}.join(", ") )%>

+

There was a tie. The winners are: <%=h( result.winners.collect {|w| @candidates[w].to_s.capitalize}.join(", ") )%>

<% else %> -

There is no winner using this method.

+

There is no winner using this method.

<% end %> +
diff --git a/app/views/quickvote/_result_box.rhtml b/app/views/quickvote/_result_box.rhtml new file mode 100644 index 0000000..41d9d17 --- /dev/null +++ b/app/views/quickvote/_result_box.rhtml @@ -0,0 +1,16 @@ +
> +
+ <%= ELECTION_TYPES[method]%> + + <% if @election.election_method == method %> + Selected Method + <% else %> + Alternative Method + <% end %> +
+ +<%= render :partial => 'methodinfo_' + method, + :object => @results[@election.election_method] %> + +
+ diff --git a/app/views/quickvote/_results_sidebar.rhtml b/app/views/quickvote/_results_sidebar.rhtml index 704c052..c60ed3d 100644 --- a/app/views/quickvote/_results_sidebar.rhtml +++ b/app/views/quickvote/_results_sidebar.rhtml @@ -1,2 +1,37 @@ +

Winner

+<%= render :partial => 'result', :object => @results[@election.election_method] %> + +

This election was run using: +<%= ELECTION_TYPES[@election.election_method] %>

+ +

View results with other methods:
+<% type_hash = {}; ELECTION_TYPES.each {|k,v| type_hash[v] = k} %> +<%= select_tag 'election_type_select', options_for_select(type_hash, @election.election_method) %>

+ + + +

Statistics

<%= image_tag( graph_url( :action => 'votes_per_interval', :id => @election ))%> diff --git a/app/views/quickvote/results.rhtml b/app/views/quickvote/results.rhtml index a51ca1d..f4f6f2d 100644 --- a/app/views/quickvote/results.rhtml +++ b/app/views/quickvote/results.rhtml @@ -28,33 +28,25 @@ <%= @election.voters.reject {|v| not v.voted? }.length %> (see below for details) -
- Winner - Computed with - <%= ELECTION_TYPES[@election.election_method] %> -
+<%= render :partial => 'result_box', + :locals => { :method => @election.election_method } %> -
-<%= render :partial => 'result_' + @election.election_method, - :object => @results[@election.election_method] %> -
+<% for result_type in @election.other_methods %> -
- Other Voting Methods - -
+<%= render :partial => 'result_box', + :locals => { :method => result_type } %> -<% for result_type in @election.other_methods %> -
-<%= render :partial => 'result_' + result_type, - :object => @results[result_type] %> -
<% end %>
-

Voters <%= link_to "[Stalk Voters]", :controller => "quickvote", :action => "mapvoters", :id => @election.id %>

+
+ Voter Report + +
+ +

<%= link_to "[Stalk Voters]", :controller => "quickvote", :action => "mapvoters", :id => @election.id %>

diff --git a/app/views/site/_basic_login.rhtml b/app/views/site/_basic_login.rhtml index 9c689fc..12a63dd 100644 --- a/app/views/site/_basic_login.rhtml +++ b/app/views/site/_basic_login.rhtml @@ -1,11 +1,11 @@ <% form_tag :controller => 'account', :action => 'login' do %>

-

<%= text_field "Login", "login", :size => 30 %>

+

<%= text_field_tag 'login' %>

-

<%= password_field "Password", "password", :size => 30 %>

+

<%= password_field_tag 'password' %>

-

<%= submit_tag 'Login' %>

+

<%= submit_tag 'Log in' %>

<% end %>

<%= link_to 'Register for an account', :controller => 'account', :action => 'signup' %>

diff --git a/app/views/site/index.rhtml b/app/views/site/index.rhtml index efbb374..e0e34a2 100644 --- a/app/views/site/index.rhtml +++ b/app/views/site/index.rhtml @@ -27,8 +27,8 @@

You must have an account to start a new vote or to administer an existing vote. You can log in or create a new account below.

- - <%= render_partial 'basic_login' %> + + <%= render :partial => 'basic_login' %> <% end %> diff --git a/config/environment.rb b/config/environment.rb index fcabdd8..ccd9ad0 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -28,7 +28,7 @@ Rails::Initializer.run do |config| # Use the database for sessions instead of the file system # (create the session table with 'rake db:sessions:create') - # config.action_controller.session_store = :active_record_store + config.action_controller.session_store = :active_record_store # Use SQL instead of Active Record's schema dumper when creating the test database. # This is necessary if your schema can't be completely dumped by the schema dumper, @@ -66,10 +66,10 @@ require 'randarray' require 'gruff-0.2.8/lib/gruff' require 'sparklines' require 'rubyvote' -ELECTION_TYPES = {'ssd' => "Schulze Sequential Dropping", - 'plurality' => "Plurality/First Past the Post", - 'approval' => "Approval (Top Two)", - 'condorcet' => "Simple Condorcet", +ELECTION_TYPES = {'ssd' => "Schulze Method", + 'plurality' => "Plurality", + 'approval' => "Approval", + 'condorcet' => "Condorcet", 'borda' => "Borda Count"} class String diff --git a/db/create.sql b/db/create.sql index 7d5f405..c28dd36 100644 --- a/db/create.sql +++ b/db/create.sql @@ -101,6 +101,19 @@ create table rankings ( primary key (id) ); +# CREATE sessions TABLE +###################################### + +drop table if exists sessions; +create table sessions ( + id int(11) NOT NULL auto_increment, + sessid varchar(255), + data text, + updated_at datetime DEFAULT NULL, + primary key (id), + index session_index (sessid) +); + # CREATE users TABLE ##################################### #DROP TABLE IF EXISTS `users`; diff --git a/db/schema.rb b/db/schema.rb index 590425d..6c038de 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -74,10 +74,11 @@ ActiveRecord::Schema.define() do create_table "voters", :force => true do |t| t.column "email", :string, :limit => 100 t.column "password", :string, :limit => 100 - t.column "contacted", :integer, :limit => 4, :default => 0, :null => false - t.column "election_id", :integer, :null => false + t.column "contacted", :integer, :limit => 4, :default => 0, :null => false + t.column "election_id", :integer, :null => false t.column "session_id", :string, :limit => 32 t.column "ipaddress", :string, :limit => 32 + t.column "type", :string, :limit => 100, :default => "", :null => false end add_index "voters", ["election_id"], :name => "fk_election_voter" diff --git a/public/images/title_front.png b/public/images/title_front.png index acf328f..d249a69 100644 Binary files a/public/images/title_front.png and b/public/images/title_front.png differ diff --git a/public/images/title_main.png b/public/images/title_main.png index f3dd02d..1fe60dd 100644 Binary files a/public/images/title_main.png and b/public/images/title_main.png differ diff --git a/public/stylesheets/common.css b/public/stylesheets/common.css index 01cd7c0..a050444 100644 --- a/public/stylesheets/common.css +++ b/public/stylesheets/common.css @@ -29,7 +29,7 @@ table, caption, tbody, tfoot, thead, tr, th, td { } body { - font-size: 11px; + font-size: 0.9em; font-family: Trebuchet, Verdana, Arial, Helvetica, sans-serif; } @@ -76,7 +76,7 @@ h2, h3 { #footer { font-size: 11px; - font-family: Verdana, Arial, Helvetica, sans-serif; + font-family: "Trebuchet MS", Trebuchet, Verdana, Arial, sans-serif; margin-top: 40px; text-align: center; } @@ -104,7 +104,4 @@ h2, h3 { background: #FFFBB3; border: 1px black solid; text-align: center; - font-weight: bold; - padding: 5px 5px 5px 15px; - width: 250px; -} + font-weight: bold diff --git a/public/stylesheets/front.css b/public/stylesheets/front.css index 5c2d1ca..4c973b1 100644 --- a/public/stylesheets/front.css +++ b/public/stylesheets/front.css @@ -18,7 +18,7 @@ table, caption, tbody, tfoot, thead, tr, th, td { padding: 0; border: 0; font-size: 100%; - font-family: inherit; + font-family: "Trebuchet MS", Verdana, Arial, sans-serif; vertical-align: baseline; } @@ -33,7 +33,7 @@ a { } #body { - font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif; + font-family: "Trebuchet MS", Verdana, Arial, sans-serif; color: white; font-size: 12px; text-align: left; @@ -58,6 +58,21 @@ a { padding-top: 189px; height: 0px; margin-top: 10px; + margin-left: 231px; +} + +#top-bar { + + position: relative; + float: right; + width: 231px; + text-align: center; +} + +#top-bar a { + color: black; + font-size: 11px; + text-decoration: none; } @@ -91,6 +106,7 @@ h3 { margin-bottom: 1em; } + #voters { padding-top: 50px; height: 559px; diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css index 3608063..13626a1 100644 --- a/public/stylesheets/main.css +++ b/public/stylesheets/main.css @@ -160,7 +160,7 @@ h5 { } .normal-header { - margin: 0 -20px 1em -20px; + margin: 1.3em -20px 1.3em -20px; height: 32px; background-color: #e5e5e5; }
IP/Host