def index
redirect_to(:action => 'signup') unless logged_in? || User.count > 0
end
-
+
+ #these methods provide basic functionality for the user login system
+ #===================================================================
def login
return unless request.post?
self.current_user = User.authenticate(params[:login], params[:password])
flash[:notice] = "You have been logged out."
redirect_back_or_default(:controller => '/site', :action => 'index')
end
+ #======================================================================
+
+ #The following methods are for slectricity specific uses
+ def summary
+ @user = User.find(params[:id])
+ end
+
+
end
+
+
helper :user
require_dependency "user"
-
end
@election.activate!
redirect_to :action => 'show', :id => @election.id
end
+
+ def change_notices
+ election = Election.find(params[:id])
+ if election.notices == 0
+ election.notices = 1
+ else
+ election.notices = 0
+ end
+ end
# methods fod display, adding, deleting, and manipulating candidate
# information for elections
@quickvote.description=@quickvote.description
#record who created the quickvote so that person can monitor it easily
@quickvote.quickuser = session.session_id
+ #Give registered users additional QuickVote functionality
+ @quickvote.user_id = session[:user][:id] if session[:user]
# try to save, if it fails, show the page again (the flash should
# still be intact
if @quickvote.save
<%= error_messages_for :user %>
<% form_for :user do |f| -%>
+
<p><label for="login">Login</label><br/>
<%= f.text_field :login %></p>
<p><label for="email">Email</label><br/>
-<%= f.text_field :email %></p>
+<%= f.text_field :email %><br />
+People participating in elections you're administrating will contact you
+at this address.</p>
<p><label for="password">Password</label><br/>
<%= f.password_field :password %></p>
--- /dev/null
+<h2>This is your user summary profile, <%=h @user.login.capitalize %></h2>
+
+<p>
+E-mail: <%=h @user.email %><br />
+Member since: <%=h @user.created_at.strftime("%x") %>
+</p>
+
+<p>Your Elections:
+ <table class="voterbox">
+ <tr>
+ <% Election.content_columns.each do |column| -%>
+ <% next if column.name.eql?("viewable") || column.name.eql?("quickuser")\
+ || column.name.eql?("active") %>
+ <th><%= column.human_name %></th>
+ <% end -%>
+ </tr>
+
+ <% @user.elections.select {|e| e.instance_of?(Election)}.each do |election| %>
+ <tr>
+ <td>
+ <% if election.active == 1 -%>
+ <%= link_to "#{election.name}", :controller => 'election',
+ :action => 'show', :id => election %>
+ <% else -%>
+ <%=h election.name %>
+ <% end -%>
+ </td>
+ <td><%=h election.description %></td>
+ <td>
+ <% if election.anonymous == 0 -%>
+ No
+ <% else -%>
+ Yes
+ <% end -%>
+ </td>
+ <td><%=h election.startdate.strftime("%x") %></td>
+ <td><%=h election.enddate.strftime("%x") %></td>
+ <td>
+ <% if election.notices == 0 -%>
+ No
+ <% else -%>
+ Yes
+ <% end -%>
+ </td>
+ <td><%=h election.election_method %></td>
+ </tr>
+ <% end -%>
+ </table>
+</p>
+
+<p>
+Your Quickvotes:
+<table class="voterbox">
+ <tr>
+ <% ["Name", "Description", "Start Date", "End Date", "Notices"].each do |column| %>
+ <th><%= column %></th>
+ <% end -%>
+ </tr>
+
+ <% @user.elections.select {|e| e.instance_of?(QuickVote)}.each do |quickvote|
+ %>
+ <tr>
+ <td>
+ <% if quickvote.active == 1 %>
+ <%= link_to "#{quickvote.name}",
+ quickaction_url( :ident => quickvote.name,
+ :action => 'results' ) %>
+ <% else %>
+ <%=h quickvote.name %>
+ <% end %>
+ </td>
+ <td><%=h quickvote.description %></td>
+ <td><%=h quickvote.startdate.strftime("%x") %></td>
+ <td><%=h quickvote.enddate.strftime("%x") %></td>
+ <td>
+ <% if quickvote.notices == 0 -%>
+ No
+ <% else -%>
+ Yes
+ <% end -%>
+ </td>
+ </tr>
+<% end %>
+</table>
<% end %>
<h2>Candidates</h2>
-
+<% %>
<% unless @election.candidates.empty? %>
<%= render :partial => 'candidate_list' %>
<% unless @election.active %>
<% end %>
</ul>
<% else %>
- <p>Please check eveything carefully on this page before starting this
+ <p>Please check everything 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>
<div id="links">
<% if session[:user] %>
Welcome <strong><%= User.find(session[:user]).login.capitalize %></strong>
- <%= link_to("Logout", :controller => "account", :action => "logout") %> |
+ <%= link_to("Profile", :controller => "account",
+ :action => "summary", :id => session[:user][:id] )%>
+ <%= link_to("Logout", :controller => "account",
+ :action => "logout") %> |
<% else %>
<%= link_to("Login", :controller => "account", :action => "login")
%>/<%= link_to("Sign up", :controller => "account", :action => "signup")%>
quickaction_url( :ident => quickvote.name,
:action => 'results' ) %>
<% else %>
- <%= quickvote.name %>
+ <%=h quickvote.name %>
<% end %>
</td>
- <td><%= quickvote.startdate.strftime("%x") %></td>
- <td><%= quickvote.enddate.strftime("%x") %></td>
- <td><%= quickvote.description %></td>
+ <td><%=h quickvote.startdate.strftime("%x") %></td>
+ <td><%=h quickvote.enddate.strftime("%x") %></td>
+ <td><%=h quickvote.description %></td>
</tr>
<% end %>
</table>
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
+If you have any questions or if you feel you have received this message
in error, you should contact:
- <%= @voter.election.user.name %> <<%= @voter.election.user.email %>>
+ <%= @voter.election.user.login %> <<%= @voter.election.user.email %>>
(The initiator of this election)
Alternatively, if you feel there is a technical error, please contact: