From:
<%= link_to "Create QuickVote.", :action => 'create_quickvote' %>
+<%= link_to "Create QuickVote.", :controller => 'quickvote', :action => 'create' %>
Direct voters to:
-<%= url_for :action => 'quickvote', :id => @quickvote.id, :only_path => false %>+
<%= quickvote_url( :votename => @quickvote.name ) %>
This vote will expire on <%= @quickvote.enddate %>
+<%= link_to "Visit in or vote in your QuickVote", quickvote_url( :votename => @quickvote.name ) %>
diff --git a/app/views/voter/_vote.rhtml b/app/views/voter/_vote.rhtml new file mode 100644 index 0000000..e742021 --- /dev/null +++ b/app/views/voter/_vote.rhtml @@ -0,0 +1,37 @@ +<% %> + +<% if @voter.election.quickvote? %> +Description:
+<%= @voter.election.description %>+<% else %> +
Election: <%= @voter.election.name %>
+Voter: <%= @voter.email %>
+Description:
+<%= @voter.election.description %>+<% end %> + +
Candidates:
+Rank each candidate in order of more preferred to least +preferred. (e.g., 123 or 321 or 213, etc.)
+ +<% if @voter.election.quickvote? %> + <%= form_tag quickconfirm_url( :votename => @voter.election.name ) %> +<% else %> + <%= form_tag :action => 'review', :id => @voter.password %> +<% end %> + +<%= text_field :vote, :votestring -%> +<%= submit_tag "Submit!" %> +<%= end_form_tag %> + diff --git a/app/views/voter/full_vote.rhtml b/app/views/voter/full_vote.rhtml new file mode 100644 index 0000000..599308f --- /dev/null +++ b/app/views/voter/full_vote.rhtml @@ -0,0 +1,5 @@ +<% %> + +<%= render_partial 'vote' %> + + diff --git a/app/views/voter/quickvote.rhtml b/app/views/voter/quickvote.rhtml new file mode 100644 index 0000000..3cb2eda --- /dev/null +++ b/app/views/voter/quickvote.rhtml @@ -0,0 +1,2 @@ +<% %> +<%= render_partial 'vote' %> diff --git a/app/views/voter/vote.rhtml b/app/views/voter/vote.rhtml deleted file mode 100644 index 2d30209..0000000 --- a/app/views/voter/vote.rhtml +++ /dev/null @@ -1,35 +0,0 @@ -<% %> - -Election: <%= @voter.election.name %>
- -Voter: <%= @voter.email %>
- -Candidates:
- -If this information is incorrect, please notify the vote -administrator immediatedly!
- -Rank each candidate in order of more preferred to least -preferred. (e.g., 123 or 321 or 213, etc.)
- -<%= form_tag :action => 'review', :id => @voter.password %> -<%= text_field :vote, :votestring -%> -<%= submit_tag "Submit!" %> -<%= end_form_tag %> - - - - - diff --git a/config/routes.rb b/config/routes.rb index ed0625d..af9820f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -13,6 +13,18 @@ ActionController::Routing::Routes.draw do |map| # -- just remember to delete public/index.html. map.connect '', :controller => "site" + map.connect 'quickvote/create', + :controller => 'site', + :action => 'create_quickvote' + + map.quickconfirm 'quickvote/:votename/confirm', + :controller => 'voter', + :action => 'confirm' + + map.quickvote 'quickvote/:votename', + :controller => 'voter', + :action => 'quickvote' + # Allow downloading Web Service WSDL as a file with an extension # instead of a file named 'wsdl' map.connect ':controller/service.wsdl', :action => 'wsdl' diff --git a/db/create.sql b/db/create.sql index bbc054a..a9d430c 100644 --- a/db/create.sql +++ b/db/create.sql @@ -10,7 +10,8 @@ create table elections ( startdate datetime, enddate datetime NOT NULL, active tinyint NOT NULL DEFAULT 0, - user_id int NOT NULL, + user_id int NULL, + quickvote tinyint NOT NULL DEFAULT 0, primary key (id), constraint fk_user_election foreign key (user_id) references users(id) ); @@ -36,14 +37,16 @@ create table candidates ( drop table if exists voters; create table voters ( id int NOT NULL auto_increment, - email varchar(100) NOT NULL, - password varchar(100) NOT NULL, + email varchar(100) NULL, + password varchar(100) NULL, contacted tinyint NOT NULL DEFAULT 0, election_id int NOT NULL, + session_id varchar(32) DEFAULT NULL, constraint fk_election_voter foreign key (election_id) references election(id), primary key (id) ); + # CREATE tokens TABLE ##################################### diff --git a/db/migrate/002_create_full_voters.rb b/db/migrate/002_create_full_voters.rb new file mode 100644 index 0000000..692a81d --- /dev/null +++ b/db/migrate/002_create_full_voters.rb @@ -0,0 +1,11 @@ +class CreateFullVoters < ActiveRecord::Migration + def self.up + create_table :full_voters do |t| + # t.column :name, :string + end + end + + def self.down + drop_table :full_voters + end +end diff --git a/db/migrate/003_create_quick_voters.rb b/db/migrate/003_create_quick_voters.rb new file mode 100644 index 0000000..21bc293 --- /dev/null +++ b/db/migrate/003_create_quick_voters.rb @@ -0,0 +1,11 @@ +class CreateQuickVoters < ActiveRecord::Migration + def self.up + create_table :quick_voters do |t| + # t.column :name, :string + end + end + + def self.down + drop_table :quick_voters + end +end diff --git a/test/fixtures/full_voters.yml b/test/fixtures/full_voters.yml new file mode 100644 index 0000000..8794d28 --- /dev/null +++ b/test/fixtures/full_voters.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +first: + id: 1 +another: + id: 2 diff --git a/test/fixtures/quick_voters.yml b/test/fixtures/quick_voters.yml new file mode 100644 index 0000000..8794d28 --- /dev/null +++ b/test/fixtures/quick_voters.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +first: + id: 1 +another: + id: 2 diff --git a/test/unit/full_voter_test.rb b/test/unit/full_voter_test.rb new file mode 100644 index 0000000..833ca44 --- /dev/null +++ b/test/unit/full_voter_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class FullVoterTest < Test::Unit::TestCase + fixtures :full_voters + + # Replace this with your real tests. + def test_truth + assert true + end +end diff --git a/test/unit/quick_voter_test.rb b/test/unit/quick_voter_test.rb new file mode 100644 index 0000000..d6e0a11 --- /dev/null +++ b/test/unit/quick_voter_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class QuickVoterTest < Test::Unit::TestCase + fixtures :quick_voters + + # Replace this with your real tests. + def test_truth + assert true + end +end