From: New candidate name:" + email.encoded + "
")
+ email = VoterNotify.deliver_votestart(voter)
+ #render(:text => "" + email.encoded + "
")
end
- #@election.activate!
+ @election.activate!
+ redirect_to :action => 'show', :id => @election.id
end
# methods fod display, adding, deleting, and manipulating candidate
@@ -213,7 +214,10 @@ class ElectionController < ApplicationController
@raw_voter_list.email = incoming_voters.email
end
- def email_voter
+ def email_voter(email=nil)
+ if email
+
+ end
end
end
diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb
index daa74f8..47ae2cb 100644
--- a/app/controllers/site_controller.rb
+++ b/app/controllers/site_controller.rb
@@ -3,10 +3,20 @@ class SiteController < ApplicationController
model :user, :election
def index
+ # if the person claims they are logged in
if session[:user]
- session[:user] = User.find(session[:user].id)
- @current_elections = session[:user].elections.sort do |a,b|
- b.enddate <=> a.enddate
+
+ # check to see that we actually have record of them
+ if User.find_all(["id = ?", session[:user].id]).length == 1
+ # if we have record of them, grab the list of their elections
+ session[:user] = User.find(session[:user].id)
+ @current_elections = session[:user].elections.sort do |a,b|
+ b.enddate <=> a.enddate
+ end
+ else
+ # if we have no record of them, set the session id back to
+ # nothing and start again
+ session[:user] = nil
end
end
end
diff --git a/app/models/election.rb b/app/models/election.rb
index eaf0727..0907e68 100644
--- a/app/models/election.rb
+++ b/app/models/election.rb
@@ -8,11 +8,18 @@ class Election < ActiveRecord::Base
require 'date'
def startdate
- read_attribute( :startdate ) || DateTime.now
+ read_attribute( :startdate ) || Time.now
end
def enddate
- read_attribute( :enddate ) || DateTime.now + 14
+ date = read_attribute( :enddate ) || Time.now + 14
+ date - 1.second
+ end
+
+ def enddate=(date)
+ date += 1.day
+ date = Time.gm(*date)
+ super(date)
end
def destroy
@@ -38,12 +45,21 @@ class Election < ActiveRecord::Base
def activate!
self.active = 1
+ self.save!
end
def quickvote?
quickvote.to_i == 1
end
+ def active?
+ active == 1
+ end
+
+ def done?
+ active == 2
+ end
+
def shortdesc
shortdesc = description.split(/\n/)[0]
end
diff --git a/app/models/quick_vote.rb b/app/models/quick_vote.rb
index fba31a8..1df25af 100644
--- a/app/models/quick_vote.rb
+++ b/app/models/quick_vote.rb
@@ -16,7 +16,7 @@ class QuickVote < Election
def initialize(params={})
super
- self.enddate = DateTime.now + 30
+ self.enddate = Time.now + 30
self.active = 1
self.anonymous = 1
self.quickvote = 1
diff --git a/app/models/voter_notify.rb b/app/models/voter_notify.rb
index 09f7899..d9fded5 100644
--- a/app/models/voter_notify.rb
+++ b/app/models/voter_notify.rb
@@ -1,7 +1,7 @@
class VoterNotify < ActionMailer::Base
def votestart(voter)
- @subject = "[%s] Election In Progress!" % voter.election.name
+ @subject = "[%s] Election Begun!" % voter.election.name
@recipients = voter.email
@from = MAIL_CONFIG[:from]
@sent_on = Time.now
diff --git a/app/views/election/_candidate_form.rhtml b/app/views/election/_candidate_form.rhtml
index 6e0fb1f..ed14dff 100644
--- a/app/views/election/_candidate_form.rhtml
+++ b/app/views/election/_candidate_form.rhtml
@@ -1,10 +1,10 @@
<% %>
-<%= text_field :candidate, :name %>
Candidate description/platform (optional):
-<%= text_area :candidate, :description %>
Candidate picture (optional and < 100x100 pixels):
<%= file_field :candidate, :picture %>
-<%= text_field 'election', 'name' %>
+<%= text_field 'election', 'name', :size => 60 %>
-<%= text_area 'election', 'description' %>
Election End Date
-<%= datetime_select :election, :enddate %>
Please enter a list of new email addresses of voters (one email address per line).
-<%= text_area :raw_voter_list, :input_addresses %> +<%= text_area :raw_voter_list, :input_addresses, :cols => 60, :rows => 8 %> +<%= hidden_field :raw_voter_list, :email, :value => 2 %> <%= submit_tag "Add Voters" %> diff --git a/app/views/election/edit_candidates.rhtml b/app/views/election/edit_candidates.rhtml index dbcc3f8..cc2c16a 100644 --- a/app/views/election/edit_candidates.rhtml +++ b/app/views/election/edit_candidates.rhtml @@ -1,4 +1,4 @@ -Summary
+ ++<%= h(@election.name) %> +-
Description
<%= h(@election.description) %>-
Election End Date
+End Date
<%= @election.enddate %>-
<%= link_to "Edit election overview.", :action => 'edit', :id => @election.id %>
+<% unless @election.active %> +<%= link_to "Edit overview.", :action => 'edit', :id => @election.id %>
+<% end %><%= link_to "Add, remove, or edit candidates.", :action => 'edit_candidates', :id => @election.id %>
+ <% end %> <% else %> -There are currently no candidates registered for this election. - <%= link_to "Add some!", :action => 'edit_candidates', :id => @election.id %>
+There are currently no candidates registered. <%= link_to "Add some!", :action => 'edit_candidates', :id => @election.id unless @election.active %>
<% end %> @@ -32,36 +49,37 @@ <% unless @election.voters.empty? %> <%= render :partial => 'voter_list' %> - <%= link_to "Add or remove voters.", :action => 'edit_voters', :id => @election.id %> + <%= link_to "Add or remove voters.", :action => 'edit_voters', :id => @election.id unless @election.active %> <% else %> -There are currently no voters registered for this election. - <%= link_to "Add some!", :action => 'edit_voters', :id => @election.id %>
+There are currently no voters registered. <%= link_to "Add some!", :action => 'edit_voters', :id => @election.id unless @election.active %>
<% end %> -Your election cannot be started for the following reasons:
-Your vote cannot be started for the following reasons:
+Please check eveything carefully on this page before starting this + vote. Once you begin the vote, you will not be able to add or + change candidates, modify the voting lists, or change the end + time.
+ +When you begin the vote, the following will happen:
+ +Please check eveything carefully on this page before starting this -election. Once you begin the election, you will not be able to -add or change candidates, modify the voting lists, or change the -election end time.
- -When you begin the election, the following will happen:
- -