a long variety of improvements and tweaks
author<mako@atdot.cc> <>
Fri, 13 Oct 2006 22:06:08 +0000 (18:06 -0400)
committer<mako@atdot.cc> <>
Fri, 13 Oct 2006 22:06:08 +0000 (18:06 -0400)
17 files changed:
app/controllers/election_controller.rb
app/controllers/site_controller.rb
app/models/election.rb
app/models/quick_vote.rb
app/models/voter_notify.rb
app/views/election/_candidate_form.rhtml
app/views/election/_candidate_line_edit.rhtml
app/views/election/_overview_form.rhtml
app/views/election/_voters_form.rhtml
app/views/election/edit_candidates.rhtml
app/views/election/edit_voters.rhtml
app/views/election/new.rhtml
app/views/election/show.rhtml
app/views/user/_edit.rhtml [new file with mode: 0644]
app/views/voter_notify/votestart.rhtml
config/environment.rb
public/stylesheets/hc.css

index 7145d3d20c3ce4198fcb9d5d88bbc1747967e0fe..3a43c8e2dabb7ec613d5943e082032c1ca3a145d 100644 (file)
@@ -52,11 +52,12 @@ class ElectionController < ApplicationController
     @election = Election.find(params[:id])
     
     @election.voters.each do |voter|
     @election = Election.find(params[:id])
     
     @election.voters.each do |voter|
-      email = VoterNotify.create_votestart(voter)
-      render(:text => "<pre>" + email.encoded + "</pre>")
+      email = VoterNotify.deliver_votestart(voter)
+      #render(:text => "<pre>" + email.encoded + "</pre>")
     end
 
     end
 
-    #@election.activate!
+    @election.activate!
+    redirect_to :action => 'show', :id => @election.id
   end
 
   # methods fod display, adding, deleting, and manipulating candidate
   end
 
   # methods fod display, adding, deleting, and manipulating candidate
@@ -213,7 +214,10 @@ class ElectionController < ApplicationController
       @raw_voter_list.email = incoming_voters.email
     end
 
       @raw_voter_list.email = incoming_voters.email
     end
 
-    def email_voter
+    def email_voter(email=nil)
+      if email
+        
+      end
     end
 
 end
     end
 
 end
index daa74f8cb866feaa7050999a026896d93457b79f..47ae2cbd87af5dbde48f59c1fdbb6feb44c92f4d 100644 (file)
@@ -3,10 +3,20 @@ class SiteController < ApplicationController
   model :user, :election
 
   def index
   model :user, :election
 
   def index
+    # if the person claims they are logged in
     if session[:user]
     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
       end
     end
   end
index eaf07276128b3b8b8271646aabc6f936949a9ebb..0907e68a4cfc7e5796ef9920bbfca09a4b0cd0bd 100644 (file)
@@ -8,11 +8,18 @@ class Election < ActiveRecord::Base
   require 'date'
 
   def startdate
   require 'date'
 
   def startdate
-    read_attribute( :startdate ) || DateTime.now
+    read_attribute( :startdate ) || Time.now
   end
 
   def enddate
   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
   end
 
   def destroy
@@ -38,12 +45,21 @@ class Election < ActiveRecord::Base
 
   def activate!
     self.active = 1
 
   def activate!
     self.active = 1
+    self.save!
   end
   
   def quickvote?
     quickvote.to_i == 1
   end
 
   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
   def shortdesc
     shortdesc = description.split(/\n/)[0]
   end
index fba31a8e9678f9e5953c3226486b70d9a949ebfa..1df25afb74d1273bcbc2d4d64c58e718187f2ddf 100644 (file)
@@ -16,7 +16,7 @@ class QuickVote < Election
   
   def initialize(params={})
     super
   
   def initialize(params={})
     super
-    self.enddate =  DateTime.now + 30
+    self.enddate =  Time.now + 30
     self.active = 1
     self.anonymous = 1
     self.quickvote = 1
     self.active = 1
     self.anonymous = 1
     self.quickvote = 1
index 09f7899ba9c774dd7fef4e8e2d0e48fc33b5ded0..d9fded5888faf10a84e5015215fcc501ecb9cf91 100644 (file)
@@ -1,7 +1,7 @@
 class VoterNotify < ActionMailer::Base
 
   def votestart(voter)
 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
     @recipients = voter.email
     @from = MAIL_CONFIG[:from]
     @sent_on = Time.now
index 6e0fb1fe59d79edb92bfb17a3beb6a8505afe8bc..ed14dffe288b9e513b6b46a5969215bf77eecbed 100644 (file)
@@ -1,10 +1,10 @@
 <% %>
 
 <p>New candidate name:<br />
 <% %>
 
 <p>New candidate name:<br />
-<%= text_field :candidate, :name %></p>
+<%= text_field :candidate, :name, :size => 60 %></p>
  
 <p>Candidate description/platform (optional):<br />
  
 <p>Candidate description/platform (optional):<br />
-<%= text_area :candidate, :description %></p>
+<%= text_area :candidate, :description, :cols => 60, :rows => 5 %></p>
 
 <p>Candidate picture (optional and < 100x100 pixels):<br />
 <%= file_field :candidate, :picture %></p>
 
 <p>Candidate picture (optional and < 100x100 pixels):<br />
 <%= file_field :candidate, :picture %></p>
index ea20a4fd6e6ab718511c535f4f6700371cf510ff..78f8580655b79453930bcdf8638fcb18fed840c3 100644 (file)
       <% if @current_candidate.picture? %>
       <img src="<%= url_for :action => 'candidate_picture',
                             :id => @current_candidate.id %>"
       <% if @current_candidate.picture? %>
       <img src="<%= url_for :action => 'candidate_picture',
                             :id => @current_candidate.id %>"
-           align="top" />
+           align="top" width="80px" />
       <% end %>
       </td>
       <% end %>
       </td>
+      <% if @current_candidate.description.length > 0 %>
       <td valign="top">
         <em>Description:</em><br />
          <%= h(@current_candidate.description) %>
       <td valign="top">
         <em>Description:</em><br />
          <%= h(@current_candidate.description) %>
-    </td></tr></table>
+      </td>
+      <% else %>
+      <td></td>
+      <% end %>
+    </tr></table>
     </blockquote>
 </p>
 </div>
     </blockquote>
 </p>
 </div>
index 899f00b72129407ea5192306703789e7f3461ff9..d5d7b6cde07e4a4d1ee96146d6d0ec41213f0b16 100644 (file)
@@ -1,11 +1,11 @@
 <%= error_messages_for 'election' %>
 
 <!--[form:election]-->
 <%= error_messages_for 'election' %>
 
 <!--[form:election]-->
-<p><label for="election_name">Name</label><br/>
-<%= text_field 'election', 'name'  %></p>
+<p><label for="election_name">Summary</label><br/>
+<%= text_field 'election', 'name', :size => 60 %></p>
 
 <p><label for="election_description">Description</label><br/>
 
 <p><label for="election_description">Description</label><br/>
-<%= text_area 'election', 'description'  %></p>
+<%= text_area 'election', 'description', :rows => 5, :cols => 60 %></p>
 
 <!--
 <p><label for="election_anonymous">Anonymous Vote</label>
 
 <!--
 <p><label for="election_anonymous">Anonymous Vote</label>
@@ -16,7 +16,8 @@
 --> 
 
 <p>Election End Date<br />
 --> 
 
 <p>Election End Date<br />
-<%= datetime_select :election, :enddate %></p>
+<font size="-1"><em>All elections end at 23:59.</em></font><br />
+<%= date_select :election, :enddate %></p>
 
 <!--[eoform:election]-->
 
 
 <!--[eoform:election]-->
 
index 3b01c007c39843cd41eb1fce4d50fb9a96bb15d5..87df4ce71848d064aefe4fec235efe3b3a8bf50d 100644 (file)
@@ -1,7 +1,7 @@
 <p>Please enter a list of new email addresses of voters (one email
 address per line).</p>
 
 <p>Please enter a list of new email addresses of voters (one email
 address per line).</p>
 
-<%= text_area :raw_voter_list, :input_addresses %>
+<%= text_area :raw_voter_list, :input_addresses, :cols => 60, :rows => 8 %>
 
 <!-- 
 <p>Email voters:
 
 <!-- 
 <p>Email voters:
@@ -9,5 +9,6 @@ address per line).</p>
                               [ 'Now', 1 ],
                               [ 'Vote Start', 2 ] ]  %>
 -->
                               [ 'Now', 1 ],
                               [ 'Vote Start', 2 ] ]  %>
 -->
+<%= hidden_field :raw_voter_list, :email, :value => 2 %>
 </p>
 <%= submit_tag "Add Voters" %>
 </p>
 <%= submit_tag "Add Voters" %>
index dbcc3f8bad3b49a550c4c5159195bdf3542c17e8..cc2c16a8a9ebb33225f95609456e9d90f11d2308 100644 (file)
@@ -1,4 +1,4 @@
-<h1><strong><%= @election.name %>:</strong> Edit/Add Candidates</h1>
+<h1>Edit/Add Candidates</h1>
 
 <%= error_messages_for :candidate %>
 
 
 <%= error_messages_for :candidate %>
 
index 36de3eb3f9e6d6168cebbe543a4e19050d405f00..429a9077fe15ce98483a69743602eee75e403ced 100644 (file)
@@ -1,5 +1,5 @@
 <% @edit = true %>
 <% @edit = true %>
-<h1><strong><%= @election.name %>:</strong> Edit Voter Rolls</h1>
+<h1>Edit Voter List</h1>
 
 <%= render :partial => 'voter_list' %>
 
 
 <%= render :partial => 'voter_list' %>
 
index 5e6fa1f286ad96d9743b5aad1b1aa81a0e1d7a5d..fc390a059ed596a6ad8466b86aa11bfb3b0ff486 100644 (file)
@@ -1,6 +1,6 @@
-<h1>Create A New Election</h1>
+<h1>Create A New Vote</h1>
 
 
-<h2>Step 1: Describe The Election</h2>
+<h2>Vote Overview</h2>
 
 <%= form_tag :action => 'create_election' %>
   <%= render :partial => 'overview_form' %>
 
 <%= form_tag :action => 'create_election' %>
   <%= render :partial => 'overview_form' %>
index 90c93eacad2082a19f0a50280667f31eb4e54083..0051861e3475c418d9480a08cf7f0cc5208f9461 100644 (file)
@@ -1,30 +1,47 @@
 <% %>
 <% %>
-<h1>Information On <%= @election.name %></h1>
+<h1>Vote Information</h1>
+
+<% if @election.active? %>
+  <div id="status">Vote is in currently in progress. Return to
+        this page for results on <%= @election.enddate %>.</div>
+<% elsif @election.done? %>
+  <div id="status">Election is finished. <%= link_to "View results",
+  :action => 'results', :id => @election.id %>.</div>
+<% end %>
+
+<h2>Overview</h2> 
+
+<p><strong>Summary</strong></p>
+
+<blockquote>
+<%= h(@election.name) %>
+</blockquote>
 
 
-<h2>Election Overview</h2> 
 <p><strong>Description</strong></p>
 
 <blockquote>
 <%= h(@election.description) %>
 </blockquote>
 
 <p><strong>Description</strong></p>
 
 <blockquote>
 <%= h(@election.description) %>
 </blockquote>
 
-<p><strong>Election End Date</strong></p>
+<p><strong>End Date</strong></p>
 
 <blockquote>
 <%= @election.enddate %>
 </blockquote>
 
 
 <blockquote>
 <%= @election.enddate %>
 </blockquote>
 
-<p><%= link_to "Edit election overview.", :action => 'edit', :id => @election.id %></p>
+<% unless @election.active %>
+<p><%= link_to "Edit overview.", :action => 'edit', :id => @election.id %></p>
+<% end %>
 
 <h2>Candidates</h2> 
 
 <% unless @election.candidates.empty? %>
   <%= render :partial => 'candidate_list' %>
 
 <h2>Candidates</h2> 
 
 <% unless @election.candidates.empty? %>
   <%= render :partial => 'candidate_list' %>
+  <% unless @election.active %>
   <p><%= link_to "Add, remove, or edit candidates.", :action => 'edit_candidates', :id => @election.id %></p>
   <p><%= link_to "Add, remove, or edit candidates.", :action => 'edit_candidates', :id => @election.id %></p>
+  <% end %>
 <% else %>
 <% else %>
-  <p><em>There are currently no candidates registered for this election.
-  <%= link_to "Add some!", :action => 'edit_candidates', :id => @election.id %></em></p>
+  <p><em>There are currently no candidates registered.  <%= link_to "Add some!", :action => 'edit_candidates', :id => @election.id unless @election.active %></em></p>
 
 <% end %>
 
 
 <% end %>
 
 
 <% unless @election.voters.empty? %>
   <%= render :partial => 'voter_list' %>
 
 <% unless @election.voters.empty? %>
   <%= render :partial => 'voter_list' %>
-  <%= link_to "Add or remove voters.", :action => 'edit_voters', :id => @election.id %></em></p>
+  <%= link_to "Add or remove voters.", :action => 'edit_voters', :id => @election.id unless @election.active %></em></p>
 <% else %>
 <% else %>
-  <p><em>There are currently no voters registered for this election.
-  <%= link_to "Add some!", :action => 'edit_voters', :id => @election.id %></em></p>
+  <p><em>There are currently no voters registered.  <%= link_to "Add some!", :action => 'edit_voters', :id => @election.id unless @election.active %></em></p>
 <% end %>
 
 <% end %>
 
-<h2>Start Election</h2>
-
-<% if @election.start_blockers.length > 0 %>
-  <p>Your election cannot be started for the following reasons:</p>
-  <ul>
-  <% for reason in @election.start_blockers %>
-  <li><%= reason %></li>
+<% unless @election.active %>
+  <h2>Start Election</h2>
+
+  <% if @election.start_blockers.length > 0 %>
+    <p>Your vote cannot be started for the following reasons:</p>
+    <ul>
+    <% for reason in @election.start_blockers %>
+    <li><%= reason %></li>
+    <% end %>
+    </ul>
+  <% else %>
+    <p>Please check eveything carefully on this page before starting this
+    vote. Once you begin the vote, you will <em>not</em> be able to add or
+    change candidates, modify the voting lists, or change the end
+    time.</p>
+
+    <p>When you begin the vote, the following will happen:</p>
+
+    <ul>
+    <li>The vote will be "frozen" so that further edits to the
+        candidate list and voting list cannot occur.</li>
+    <li>All voters will be emailed notifying them that the vote has
+        begun and of their unique login token.</li>
+    </ul>
+
+    <%= button_to 'Start Election!', :action => 'start_election', :id => @election.id %>
   <% end %>
   <% end %>
-  </ul>
-<% else %>
-<p>Please check eveything carefully on this page before starting this
-election. Once you begin the election, you will <em>not</em> be able to
-add or change candidates, modify the voting lists, or change the
-election end time.</p>
-
-<p>When you begin the election, the following will happen:</p>
-
-<ul>
-  <li>The election will be "frozen" so that further edits to the
-      candidate list and voting list cannot occur.</li>
-  <li>All voters will be emailed notifying them that the election has
-      begun and of their unique login token.</li>
-</ul>
-
-<%= button_to 'Start Election!', :action => 'start_election', :id => @election.id %>
 
 <% end %>
 
 <% end %>
diff --git a/app/views/user/_edit.rhtml b/app/views/user/_edit.rhtml
new file mode 100644 (file)
index 0000000..80fbac1
--- /dev/null
@@ -0,0 +1,9 @@
+<div class="user_edit">
+  <table>
+    <%= form_input changeable(user, "login"), "Login ID", "login", :size => 30 %><br/>
+    <%= form_input changeable(user, "email"), "Email", "email" %>
+    <% if submit %>
+      <%= form_input :submit_button, (user.new_record? ? 'Signup' : 'Change Settings'), :class => 'two_columns' %>
+    <% end %>
+  </table>
+</div>
index c2918da3c11ad5fcdd2839761971bd4f06d60ef9..ead6a431b0c9d9b58fb84b690b80da198a319fe4 100644 (file)
@@ -11,6 +11,7 @@ need to use the following token to log in to hyperchad.media.mit.edu:
   <%= @voter.password %>
 
 Alternatively, you can just click this URL:
   <%= @voter.password %>
 
 Alternatively, you can just click this URL:
+  <%= url_for :controller => 'election', :action => 'show', :id => @voter.election.id %>
 
 If you have any questions or if you feel you have recieved this message
 in error, you should contact:
 
 If you have any questions or if you feel you have recieved this message
 in error, you should contact:
index 69addb138a4b17d41a283e4415c1ff2607061814..6edda72a170c04f10d6fbd262bb4386bd3921bf3 100644 (file)
@@ -78,8 +78,11 @@ end
 module LoginEngine
   config :salt, "voothingboat"
   config :email_from, MAIL_CONFIG[:from]
 module LoginEngine
   config :salt, "voothingboat"
   config :email_from, MAIL_CONFIG[:from]
-end
-
+  config :admin_email, MAIL_CONFIG[:from]
+  config :app_name, 'HyperChad'
+  config :changeable_fields, []
+  config :use_email_notification, true
+  config :confirm_account, false
 Engines.start :login
 
 # action mailer configuration
 Engines.start :login
 
 # action mailer configuration
index 0a9f362d53e45cef2d9371c8bf8316f6feac14cb..62c3a364b70795c6421b67806426a0a047860a80 100644 (file)
@@ -89,7 +89,17 @@ a:active { color: #FFFFFF; text-decoration: none; background: #0259C4; }
                        margin-top: 10px;
                        margin-left: 50px;
                        padding: 5px 5px 5px 15px;
                        margin-top: 10px;
                        margin-left: 50px;
                        padding: 5px 5px 5px 15px;
-                       width: 85%; }
+                       width: 400px; }
+
+#status {
+  width: 400px;
+  border: 1px solid #0000FF;
+  border-width: 1px;
+  padding: 7px;
+  padding-bottom: 12px;
+  margin-bottom: 20px;
+  background-color: #f0f0f0;
+}
 
 #footer { text-align: center;
           font-size: 12px;
 
 #footer { text-align: center;
           font-size: 12px;

Benjamin Mako Hill || Want to submit a patch?