Merge from jdong
authorJohn Dong <jdong@mit.edu>
Wed, 29 Aug 2007 21:43:11 +0000 (17:43 -0400)
committerJohn Dong <jdong@mit.edu>
Wed, 29 Aug 2007 21:43:11 +0000 (17:43 -0400)
13 files changed:
.bzrignore
app/models/full_voter.rb
app/models/user.rb
app/views/election/_candidate_line.rhtml
app/views/election/_candidate_line_edit.rhtml
app/views/election/_winner.rhtml
app/views/election/_winner_details.rhtml
app/views/election/edit.rhtml
app/views/election/edit_candidate.rhtml
app/views/election/list.rhtml
app/views/election/new_voters.rhtml
app/views/site/index.rhtml
vendor/plugins/sitealizer/lib/last_update [deleted file]

index 1e24ca1b87d4ae5f09a2ecb818ea9d3fadf41bdc..57a67d22f4ea29e16bc9f66a67611b06fdd8fbd6 100644 (file)
@@ -6,3 +6,4 @@ test.log
 tmp
 public/engine_files
 .DS_Store
+vendor/plugins/sitealizer/lib/last_update
index 980fb5cf3c0fdeef0c043be9aeabe33233f6a874..b82667c3f926f6d82f61e3844010744cc2466fdf 100644 (file)
@@ -9,4 +9,12 @@ class FullVoter < Voter
       self.password = token_generator.token
     end
   end
+  
+  protected
+  def validate
+    # E-mail regex, moderate complexity
+    # Stolen from http://www.regular-expressions.info/email.html
+    errors.add(:email, "is not valid") unless email  =~
+                  /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i
+  end
 end
index 78266ad61d06d3d8586d9c9da5b0e6f1f42f0da6..eca592dee17ef7082a09e21b6db191d38c8341f3 100644 (file)
@@ -6,13 +6,12 @@ class User < ActiveRecord::Base
   attr_accessor :password
   attr_accessor :current_user
   
-  validates_presence_of     :login, :email
+  validates_presence_of     :email
   validates_presence_of     :password,                   :if => :password_required?
   validates_presence_of     :password_confirmation,      :if => :password_required?
   validates_length_of       :password, :within => 4..40, :if => :password_required?
   validates_confirmation_of :password,                   :if => :password_required?
   validates_length_of       :login,    :within => 3..40
-  validates_length_of       :email,    :within => 3..100
   validates_uniqueness_of   :login, :email, :case_sensitive => false
   before_save :encrypt_password
 
@@ -68,4 +67,12 @@ class User < ActiveRecord::Base
     def password_required?
       crypted_password.blank? || !password.blank?
     end
+    def validate
+      # E-mail regex, moderate complexity
+      # Stolen from http://www.regular-expressions.info/email.html
+      errors.add(:email, "is not valid") unless email  =~
+                  /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i
+      errors.add(:login, "should not begin or end with spaces") if login.strip!
+      errors.add(:login, "should contain only letters, numbers, and spaces") unless login =~ /^[A-Za-z0-9 ]*$/
+    end
 end
index 5145b88878e78add5767e0890644ac76b94cbaad..870a2de03d6bb977c9776abd745f7bd66c671d2a 100644 (file)
@@ -1,6 +1,6 @@
 <% -%>
 <div id="cand<%= @current_candidate.id %>">
-  <li><%= @current_candidate.name -%>
+  <li><%=h @current_candidate.name -%>
     <% if @show_details %>
       (<%= link_to_remote "Hide Details",
                          :update => "cand#{@current_candidate.id}",
index 78f8580655b79453930bcdf8638fcb18fed840c3..61a9f6324cde461485f414975bd5f7cfdbd29783 100644 (file)
@@ -1,6 +1,6 @@
 <% -%>
 <div id="cand<%= @current_candidate.id %>">
-<p><strong><%= @current_candidate.name %></strong>
+<p><strong><%=h @current_candidate.name %></strong>
   (<%= link_to_remote "Delete",
                        :complete => "Element.remove('cand#{@current_candidate.id}')",
                        :url => { :action => :delete_candidate,
index 531e0d2bf9d23161d6a299fbf91183493282a6db..0e55aa22e22796c5bebb010f05d69929a17e616e 100644 (file)
@@ -6,7 +6,7 @@
 
   <ul>
   <% for candidate in @winners %>
-    <li><%= @candidates_by_id[candidate].name %></li>
+    <li><%=h @candidates_by_id[candidate].name %></li>
   <% end %>
   </ul>
 
@@ -14,7 +14,7 @@
 
   <% winner = @winners[0] %>
   <p>The winner of the election was:
-     <strong><%= @candidates_by_id[winner].name %></strong>
+     <strong><%=h @candidates_by_id[winner].name %></strong>
   </p>
 
 <% end %>
index 0903952eb6e386b3368d4e29effa911c9504580b..36877ae4c7fd1163bb245d66b3cec4fff756d482 100644 (file)
@@ -6,12 +6,12 @@ preferred to any other candidates is listed here:</p>
 <tr>
 <th></th>
 <% for candidate in @election.candidates.sort %>
-  <th><%= candidate.name %></th>
+  <th><%=h candidate.name %></th>
 <% end %>
 </tr>
 <% for cand1 in @election.candidates.sort %>
   <tr>
-  <th><%= cand1.name %></th>
+  <th><%=h cand1.name %></th>
   <% for cand2 in @election.candidates.sort %>
     <td>
     <% if cand1 == cand2 %>
index 968d1575124c730204089cc2a17e7b5ef094f280..40aaad28d51b510674231ae236a77959967600ed 100644 (file)
@@ -1,4 +1,4 @@
-<h1><strong><%= @election.name %>:</strong> Edit Overview</h1>
+<h1><strong><%=h @election.name %>:</strong> Edit Overview</h1>
 
 <% form_tag(:action => 'update', :id => @election) do %>
   <%= render :partial => 'overview_form' %>
index fe56aa08c37f3d20d8c33f03da7c2cef4442f181..7e1dd65704cd3ef9b33d7d59dd6be8ae36419587 100644 (file)
@@ -1,4 +1,4 @@
-<h1>Editing <%= @candidate.name %></h1>
+<h1>Editing <%=h @candidate.name %></h1>
 
 <%= error_messages_for :candidate %>
 <% form_tag( { :action => :update_candidate, :id => @candidate.id },
index 83be6c6c28671bf728c27ce8e36b628cfa2a1734..321bf4630dad225b88b59ef3630b9b50fa6be5cb 100644 (file)
@@ -5,9 +5,9 @@
 
 <% for election in @elections %>
   <tr>
-    <td valign="top"><h2><%= link_to election.name, :action => 'show', :id => election %></h2>
+    <td valign="top"><h2><%=h link_to election.name, :action => 'show', :id => election %></h2>
         <p><strong>Description:</strong></p>
-       <blockquote><%= election.description %></blockquote>
+       <blockquote><%=h election.description %></blockquote>
        
         <p><strong>Election Information:</strong></p>
        <ul>
index d1f0fab8adafc5f59be7bb0b67c47fb046c943bc..5f064462f3c8ceed2e28b27bd7c8befd14ea7b1d 100644 (file)
@@ -1,5 +1,5 @@
 <% @edit = true %>
-<h1><strong><%= @election.name %>:</strong> Enter List of Voter Email Addresses</h1>
+<h1><strong><%=h @election.name %>:</strong> Enter List of Voter Email Addresses</h1>
 
 <%= render :partial => 'voter_list' %>
 
index 046228ddb3acba669a94934c12cfb96a56cf8c2c..c82840356ced7ce753ab8f1134e431aa7dd4f6d7 100644 (file)
@@ -46,7 +46,7 @@
 
   <ul>
    <li><%= link_to( "Create a QuickVote", :controller => 'quickvote', :action => 'create') %></li>
-   <li><%= link_to( "Recent QuickVotes", :controller => 'quickvote', :action => 'my_quickvotes')%></li>
+   <li><%= link_to( "My Recent QuickVotes", :controller => 'quickvote', :action => 'my_quickvotes')%></li>
   </ul>
 
   <p>Recently created <em>QuickVotes</em> include:</p>
diff --git a/vendor/plugins/sitealizer/lib/last_update b/vendor/plugins/sitealizer/lib/last_update
deleted file mode 100644 (file)
index d393158..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Wed Aug 29 13:54:03 -0400 2007

Benjamin Mako Hill || Want to submit a patch?