@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
- #@election.activate!
+ @election.activate!
+ redirect_to :action => 'show', :id => @election.id
end
# methods fod display, adding, deleting, and manipulating candidate
@raw_voter_list.email = incoming_voters.email
end
- def email_voter
+ def email_voter(email=nil)
+ if email
+
+ end
end
end
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
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
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
def initialize(params={})
super
- self.enddate = DateTime.now + 30
+ self.enddate = Time.now + 30
self.active = 1
self.anonymous = 1
self.quickvote = 1
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
<% %>
<p>New candidate name:<br />
-<%= text_field :candidate, :name %></p>
+<%= text_field :candidate, :name, :size => 60 %></p>
<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>
<% if @current_candidate.picture? %>
<img src="<%= url_for :action => 'candidate_picture',
:id => @current_candidate.id %>"
- align="top" />
+ align="top" width="80px" />
<% end %>
</td>
+ <% if @current_candidate.description.length > 0 %>
<td valign="top">
<em>Description:</em><br />
<%= h(@current_candidate.description) %>
- </td></tr></table>
+ </td>
+ <% else %>
+ <td></td>
+ <% end %>
+ </tr></table>
</blockquote>
</p>
</div>
<%= 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/>
-<%= text_area 'election', 'description' %></p>
+<%= text_area 'election', 'description', :rows => 5, :cols => 60 %></p>
<!--
<p><label for="election_anonymous">Anonymous Vote</label>
-->
<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]-->
<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:
[ 'Now', 1 ],
[ 'Vote Start', 2 ] ] %>
-->
+<%= hidden_field :raw_voter_list, :email, :value => 2 %>
</p>
<%= submit_tag "Add Voters" %>
-<h1><strong><%= @election.name %>:</strong> Edit/Add Candidates</h1>
+<h1>Edit/Add Candidates</h1>
<%= error_messages_for :candidate %>
<% @edit = true %>
-<h1><strong><%= @election.name %>:</strong> Edit Voter Rolls</h1>
+<h1>Edit Voter List</h1>
<%= render :partial => 'voter_list' %>
-<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' %>
<% %>
-<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>Election End Date</strong></p>
+<p><strong>End Date</strong></p>
<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' %>
+ <% unless @election.active %>
<p><%= link_to "Add, remove, or edit candidates.", :action => 'edit_candidates', :id => @election.id %></p>
+ <% end %>
<% 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 %>
<% 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 %>
- <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 %>
-<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 %>
- </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 %>
--- /dev/null
+<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>
<%= @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:
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
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;