Created a user "summary/profile page". Also corected several minor typos on election...
author<jlsharps@mit.edu> <>
Mon, 27 Aug 2007 23:02:32 +0000 (19:02 -0400)
committer<jlsharps@mit.edu> <>
Mon, 27 Aug 2007 23:02:32 +0000 (19:02 -0400)
app/controllers/account_controller.rb
app/controllers/application.rb
app/controllers/election_controller.rb
app/controllers/quickvote_controller.rb
app/views/account/signup.rhtml
app/views/account/summary.rhtml [new file with mode: 0644]
app/views/election/show.rhtml
app/views/layouts/main.rhtml
app/views/quickvote/my_quickvotes.rhtml
app/views/voter_notify/votestart.rhtml

index bb614dec3cc0d93f0aef84d82f0bc4c37c4d0f06..e8adcf0fe809b8a466f38eb7161e5af765060104 100644 (file)
@@ -10,7 +10,9 @@ class AccountController < ApplicationController
   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])
@@ -42,4 +44,14 @@ class AccountController < ApplicationController
     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
+
+
index 23c878feca92f6d252034ffd965f97612bb22dae..9b4803092dfc48e4c3ed6a006204de60ae39323e 100644 (file)
@@ -6,5 +6,4 @@ class ApplicationController < ActionController::Base
   helper :user
   require_dependency "user"
   
-  
 end
index 7040c38c26b7acdb8ee2bc50bacb5a42c16e6909..4ad8bacb354b5cac24a320b994f74427d2809a23 100644 (file)
@@ -67,6 +67,15 @@ class ElectionController < ApplicationController
     @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
index 7ad1722cb59cf69f2021b22021647ef0a26f452f..cd63c2e52f61245f2d6b0b537cfb56b624e4d0b2 100644 (file)
@@ -17,6 +17,8 @@ class QuickvoteController < ApplicationController
       @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
index c0012a73d3cfbaec7fd555693fc949eb96ae55dc..f5228d8b390ff4c06ae79779bbb34ad0ce924c5c 100644 (file)
@@ -1,10 +1,13 @@
 <%= 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>
diff --git a/app/views/account/summary.rhtml b/app/views/account/summary.rhtml
new file mode 100644 (file)
index 0000000..2f24e28
--- /dev/null
@@ -0,0 +1,84 @@
+<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>
index ff06521da1dbb997e55b118babd2aeade7985748..5d22f44352bb6c65e60125447d3a23b53adead5f 100644 (file)
@@ -34,7 +34,7 @@
 <% end %>
 
 <h2>Candidates</h2> 
-
+<% %>
 <% unless @election.candidates.empty? %>
   <%= render :partial => 'candidate_list' %>
   <% unless @election.active %>
@@ -65,7 +65,7 @@
     <% 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>
index 027ef145567213b95a8406ffc5450a8467c44588..0ed60829eaf3bdf3b8967325af4dda583c7baa8a 100644 (file)
            <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")%>
index a920480be21a2515272ecf398f91190fd19f10bb..bb388366be9d140706efc30c657054a3779c5355 100644 (file)
                     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>       
index b844ee23477a9b05e16cbf5db8daf460ae95ebbf..b31f1ba44414984e8747cc6c99495f053a43e215 100644 (file)
@@ -13,10 +13,10 @@ need to use the following token to log in to selectricity.media.mit.edu:
 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:

Benjamin Mako Hill || Want to submit a patch?