]> projects.mako.cc - selectricity/commitdiff
Added the forgot password functionality to the voters of Full Elections. Also, modifi...
author<jlsharps@mit.edu> <>
Fri, 31 Aug 2007 19:20:21 +0000 (15:20 -0400)
committer<jlsharps@mit.edu> <>
Fri, 31 Aug 2007 19:20:21 +0000 (15:20 -0400)
app/controllers/election_controller.rb
app/controllers/voter_controller.rb
app/models/voter_notify.rb
app/views/election/remind_voter.rhtml [new file with mode: 0644]
app/views/voter/forgot_password.rhtml [new file with mode: 0644]
app/views/voter_notify/reminder.rhtml [new file with mode: 0644]
app/views/voter_notify/votestart.rhtml
config/environment.rb
db/schema.rb

index eff920ff0419cdcb826e5b3d22817d13ffe07a5a..1affe0fbd254bc2622eaa4756242963ac7ede00b 100644 (file)
@@ -152,6 +152,14 @@ class ElectionController < ApplicationController
     voter.destroy
   end
   
+  def remind_voter
+    voter_array= FullVoter.find(:all, :conditions => ["email = ?", params[:email]])
+    voter_array.delete_if {|voter| voter.election.active == 0}
+    unless voter_array.empty?
+      VoterNotify.deliver_reminder(voter_array)
+    end
+  end
+  
   ## methods for computing and printing results
   ####################################################################
   def results
index 6693b0fa6baa9090cfa6c72b146a240f3d95024e..fb1bec7a0f69f84b1063b6e936722763d022b8f3 100644 (file)
@@ -32,7 +32,7 @@ class VoterController < ApplicationController
       redirect_to :action => 'index'
     end
   end
-
+  
   private
   def authenticate
     password = params[:id]
index d9fded5888faf10a84e5015215fcc501ecb9cf91..825786a7a33ba01754ce908aaa7ab66d669144a5 100644 (file)
@@ -8,7 +8,12 @@ class VoterNotify < ActionMailer::Base
     @body = { :voter => voter }
   end
 
-  def reminder(voter)
+  def reminder(voter_array)
+    @subject = "Selectricity Election Reminder!"
+    @recipients = voter_array[0].email
+    @from = MAIL_CONFIG[:from]
+    @sent_on = Time.now
+    @body = { :voter_array => voter_array }
   end
 
 end
diff --git a/app/views/election/remind_voter.rhtml b/app/views/election/remind_voter.rhtml
new file mode 100644 (file)
index 0000000..40d7a20
--- /dev/null
@@ -0,0 +1 @@
+The message has been sent, please check your inbox soon.
\ No newline at end of file
diff --git a/app/views/voter/forgot_password.rhtml b/app/views/voter/forgot_password.rhtml
new file mode 100644 (file)
index 0000000..43d1d03
--- /dev/null
@@ -0,0 +1,12 @@
+<h4>Deleted your email? Lost your password?</h4>
+<p>Not to worry, enter the email at which you were supposed to receive your
+password, and we'll hook you up with a set of magic numbers that shall grant
+access to the chambers within. Hoo-rah!</p>
+
+<% form_tag :controller => 'election', :action => 'remind_voter' do %>
+
+  <p><span label for="email">Email</label></span>
+  <%= text_field_tag :email %></p>
+
+  <%= submit_tag "Submit" %>
+<% end -%>
diff --git a/app/views/voter_notify/reminder.rhtml b/app/views/voter_notify/reminder.rhtml
new file mode 100644 (file)
index 0000000..1373bc2
--- /dev/null
@@ -0,0 +1,17 @@
+Voter!
+
+Either you or an election administrator has requested you receive a reminder for an election you've been registered in.
+
+Here are the election(s) for which you are currently registered and your tokens to enter each election:
+<% @voter_array.each do |voter| -%>
+<%= voter.election.name %>: <%= voter.password %>
+<% end -%>
+
+
+If you feel there is a technical error, please contact:
+
+  help@selectricity.org
+  (Selectricity Tech Support)
+
+Thanks and happy voting!
+Selectricity Staff
index 216ddebf15b1df71b0b6a9b3ab838afa6d428a67..f9dbfc6c90c4cc56282be87e545ed97cb4a8da7a 100644 (file)
@@ -1,17 +1,17 @@
 Voter!
 
-This is an automated message sent by selectricity.media.mit.edu.
+This is an automated message sent by Selectricity.
 
 You have been listed as a voter in an upcoming election.
 
 The election title: <%= @voter.election.name %>
 
 To read more about the election, the candidates, and to vote, you will
-need to use the following token to log in to selectricity.media.mit.edu:
+need to use the following token to log in to Selectricity:
   <%= @voter.password %>
 
 Alternatively, you can just click this URL:
-  http://selectricity.media.mit.edu<%= url_for :controller => 'election', :action => 'show', :id => @voter.election %>
+  http://selectricity.org<%= url_for :controller => 'voter' %>
 
 If you have any questions or if you feel you have received this message
 in error, you should contact:
@@ -21,10 +21,9 @@ in error, you should contact:
 
 Alternatively, if you feel there is a technical error, please contact:
 
-  help@selectricity.media.mit.edu
+  help@selectricity.org
   (Selectricity Tech Support)
 
 Thanks and happy voting!
 Selectricity Staff
-  
-  
+
index ccd9ad0990874b6b4bb92d6260caa52a891b9982..3e5f1c6b4408031dbba3bdb81fd3401acbb3de00 100644 (file)
@@ -59,7 +59,7 @@ end
 
 # Include your application configuration below
 
-MAIL_CONFIG = { :from => 'Selectricity <info@selectricity.media.mit.edu>'} 
+MAIL_CONFIG = { :from => 'Selectricity <info@selectricity.org>'} 
 
 require 'uniq_token'
 require 'randarray'
index 6c038deadbd2983e1fb2073265ec989248421809..e7d7d85723b458caf478df16696688be794a469e 100644 (file)
@@ -42,6 +42,14 @@ ActiveRecord::Schema.define() do
     t.column "rank",         :integer
   end
 
+  create_table "sessions", :force => true do |t|
+    t.column "sessid",     :string
+    t.column "data",       :text
+    t.column "updated_at", :datetime
+  end
+
+  add_index "sessions", ["sessid"], :name => "session_index"
+
   create_table "sitealizer", :force => true do |t|
     t.column "path",       :string
     t.column "ip",         :string

Benjamin Mako Hill || Want to submit a patch?