<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,6 @@
 class VotesController &lt; ApplicationController
 
+  # TODO: Feels like a good chunk of this should be in the Vote model...
   def vote
     hiring_stage = HiringStage.find_by_hiring_stage_id( params[:hiring_stage_id] )
     vetting_stage = VettingStage.find_by_id( params[:vetting_stage_id] )
@@ -16,6 +17,9 @@ class VotesController &lt; ApplicationController
       end
     end
     
+    # Tell the hiring stage to check and see whether or not the applicant should be advanced to the next vetting stage
+    hiring_stage.advance_applicant?
+    
     respond_to do |format|
       format.html { redirect_to( hiring_stage.position ) }
       format.xml  { head :ok }</diff>
      <filename>app/controllers/votes_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -12,10 +12,13 @@ class HiringStage &lt; ActiveRecord::Base
 	belongs_to :vetting_stage
 	
 	has_many :votes
-=begin
-	has_many :yea_votes, :class_name =&gt; 'Vote', :conditions =&gt; &quot;vote_value = 1&quot;
-	has_many :nay_votes, :class_name =&gt; 'Vote', :conditions =&gt; &quot;vote_value = 0&quot;
-=end
+	
+	
+	# ------------------------------------------------------------ Class Methods ------------------------------------------------------------ #
+	
+	
+	# ------------------------------------------------------------ Instance Methods ------------------------------------------------------------ #
+	
 
 	def construct_from_basic_elements( applicant, position, vetting_stage )
 	  self.applicant = applicant
@@ -25,16 +28,29 @@ class HiringStage &lt; ActiveRecord::Base
 	  self.save!
   end
   
-
-=begin  
-  def find_vote_count_for_vetting_stage( vetting_stage, type = :all )
-    if ( :all == type )
-      return votes.count( :conditions =&gt; &quot;vetting_stage_id = #{vetting_stage.id}&quot; )
-    elsif ( :yea == type )
-      return yea_votes.count( :conditions =&gt; &quot;vetting_stage_id = #{vetting_stage.id}&quot; )
-    elsif ( :nay == type )
-      return nay_votes.count( :conditions =&gt; &quot;vetting_stage_id = #{vetting_stage.id}&quot; )
+  
+  # An applicant gets advanced if all the votes from all the users at the current vetting stage are 1
+  def advance_applicant?()
+    if voting_percentage_was_reached?()
+      self.position.shift_applicant_to_stage( :next, self.applicant )
     end
   end
-=end
+
+private
+  
+  # Did the number of votes cast at this hiring stage meet or exceed the concensus needed to move this applicant to the next stage?
+  def voting_percentage_was_reached?()
+    return CONSENSUS_PERCENTAGE.to_f &lt;= voting_percentage().to_f
+  end
+  
+  
+  # Calculates the percentage of votes for the applicant ('yea' votes are any that are true, or equal to 1)
+  def voting_percentage()
+    votes = Vote.find_votes_by_hiring_stage( self )
+    vote_array = votes.map { |vote| vote.vote_value == true ? 1 : 0 }
+    sum = vote_array.inject { |sum,x| sum ? sum + x : x }
+    percent = votes.length.to_f / sum.to_f
+    
+    return percent
+  end
 end</diff>
      <filename>app/models/hiring_stage.rb</filename>
    </modified>
    <modified>
      <diff>@@ -84,16 +84,4 @@ class Position &lt; ActiveRecord::Base
       return Vote.find( :all, :conditions =&gt; &quot;applicant_id = #{applicant.id} AND position_id = #{self.id} AND vetting_stage_id = #{vetting_stage.id} AND vote_value = 0&quot; )
     end
   end
-  
-=begin  
-  def find_reviewers( applicant, vetting_stage, voting_state = :all )
-    if ( :all == voting_state )
-      
-    elsif( :voted == voting_state )
-      
-    elsif( :unvoted == voting_state   )
-      
-    end
-  end
-=end
 end</diff>
      <filename>app/models/position.rb</filename>
    </modified>
    <modified>
      <diff>@@ -11,11 +11,17 @@ class Vote &lt; ActiveRecord::Base
   # ------------------------------------------------------------ Class Methods ------------------------------------------------------------ #
   
   
+  # TODO: I think I can just pass in the hiring stage here and infer the vetting stage from it
   def self.find_vote_by_hiring_stage_and_vetting_stage( hiring_stage, vetting_stage )
     return self.find( :first, :conditions =&gt; &quot;hiring_stage_id = #{hiring_stage.id} AND vetting_stage_id = #{vetting_stage.id}&quot; )
   end
   
   
+  def self.find_votes_by_hiring_stage( hiring_stage )
+    return self.find( :all, :conditions =&gt; &quot;applicant_id = #{hiring_stage.applicant.id} AND position_id = #{hiring_stage.position.id} AND vetting_stage_id = #{hiring_stage.vetting_stage.id}&quot; )
+  end
+  
+  
   # ------------------------------------------------------------ Instance Methods ------------------------------------------------------------ #
   
   </diff>
      <filename>app/models/vote.rb</filename>
    </modified>
    <modified>
      <diff>@@ -13,7 +13,7 @@
 					
 				&lt;/td&gt;
 				&lt;td class=&quot;t l&quot; width=&quot;50%&quot;&gt;
-					&lt;%= truncate( sanitize( applicant.contact_info ), 128 ) %&gt; &lt;br /&gt;
+					&lt;%= auto_link( truncate( sanitize( applicant.contact_info ), 128 ) ) %&gt; &lt;br /&gt;
 					&lt;span class=&quot;small&quot;&gt;&lt;%= &quot;Positions: &quot; + applicant.positions.map { |pos| link_to( pos.title, position_path( pos ) ) }.to_sentence if ( applicant.positions.count &gt; 0 ) %&gt;&lt;/span&gt;
 				&lt;/td&gt;
 				&lt;td class=&quot;t c&quot;&gt;</diff>
      <filename>app/views/applicants/index.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -4,7 +4,7 @@
 
 	&lt;table class=&quot;wide&quot;&gt;
 		&lt;tr&gt;
-			&lt;th&gt;&lt;%= rounded_rect_box( &quot;Title&quot; ) %&gt;&lt;/th&gt;&lt;th&gt;&lt;%= rounded_rect_box( &quot;Description&quot; ) %&gt;&lt;/th&gt;&lt;th&gt;&lt;%= rounded_rect_box( &quot;\# Applicants&quot; ) %&gt;&lt;/th&gt;&lt;th&gt;&lt;%= rounded_rect_box( &quot;Reviewers&quot; ) %&gt;&lt;/th&gt;&lt;th&gt;&lt;/th&gt;
+			&lt;th&gt;&lt;%= rounded_rect_box( &quot;Title&quot; ) %&gt;&lt;/th&gt;&lt;th&gt;&lt;%= rounded_rect_box( &quot;Description&quot; ) %&gt;&lt;/th&gt;&lt;th&gt;&lt;%= rounded_rect_box( &quot;Applicants&quot; ) %&gt;&lt;/th&gt;&lt;th&gt;&lt;%= rounded_rect_box( &quot;Reviewers&quot; ) %&gt;&lt;/th&gt;&lt;th&gt;&lt;/th&gt;
 		&lt;/tr&gt;
 
 		&lt;% for position in @positions %&gt;</diff>
      <filename>app/views/positions/index.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -11,7 +11,7 @@
 	&lt;div id=&quot;wide_left&quot;&gt;
 		&lt;h2&gt;&lt;%= image_tag &quot;position.png&quot; %&gt; &lt;%= @position.id %&gt;: &lt;%= @position.title %&gt; &lt;span class=&quot;default_font&quot;&gt;for &lt;%= @position.department.name if @position.department %&gt;.&lt;/span&gt;&lt;/h2&gt;
 		
-		&lt;div class=&quot;small&quot;&gt;Posted by &lt;%= link_to( @position.user.display_name, user_path( @position.user ) ) %&gt;  &lt;span class=&quot;display_date&quot;&gt;&lt;%= @position.updated_at.friendly_date %&gt;&lt;/span&gt;&lt;/div&gt;
+		&lt;div class=&quot;small&quot;&gt;Posted by &lt;%= link_to( @position.user.display_name, user_path( @position.user ) ) %&gt;  &lt;span class=&quot;display_date&quot;&gt;&lt;%= @position.created_at.friendly_date %&gt;&lt;/span&gt;&lt;/div&gt;
 		
 		&lt;%  if @position.is_closed %&gt;
 			&lt;h4 class=&quot;sub_header&quot;&gt;This position is closed.&lt;/h4&gt;</diff>
      <filename>app/views/positions/show.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -4,7 +4,7 @@ SITE_NAME = APPLICATION_NAME
 SITE_TAGLINE = &quot;Are they an applican or an applican't?&quot;
 
 
-# ------------------------------ User Bar ------------------------------ #
+# ------------------------------ Strings: User Bar ------------------------------ #
 
 ADMIN_SETTINGS_LINK = &quot;admin&quot;
 DEPARTMENTS_LINK = &quot;departments&quot;
@@ -18,7 +18,7 @@ STAGES_LINK = &quot;stages&quot;
 USERS_LINK = &quot;users&quot;
 
 
-# ------------------------------ Everywhere Else ------------------------------ #
+# ------------------------------ Strings: Everywhere Else ------------------------------ #
 
 
 ADDED_ON = &quot;Added on&quot;
@@ -38,4 +38,10 @@ POSITIONS_APPLIED_FOR = &quot;Positions Applied For&quot;
 RESUME = &quot;Resume (CV)&quot;
 SEARCH = &quot;Search&quot;
 USERNAME = &quot;Username&quot;
-WELCOME_MESSAGE = &quot;Welcome to Applican. Please log in.&quot;
\ No newline at end of file
+WELCOME_MESSAGE = &quot;&quot;
+
+
+# ------------------------------ Numeric ------------------------------ #
+
+
+CONSENSUS_PERCENTAGE = 1.00
\ No newline at end of file</diff>
      <filename>config/initializers/global_variables.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>0d01969685a355249d502505398c8a10f5dde918</id>
    </parent>
  </parents>
  <author>
    <name>Chris</name>
    <email>chris@ChoOyu.local</email>
  </author>
  <url>http://github.com/senorprogrammer/applican/commit/66b7447aec45321eba490c998b9a33911c0aa61a</url>
  <id>66b7447aec45321eba490c998b9a33911c0aa61a</id>
  <committed-date>2008-07-04T14:44:26-07:00</committed-date>
  <authored-date>2008-07-04T14:44:26-07:00</authored-date>
  <message>Voting an applicant now moves the applicant foward in the vetting stages if the minimum concensus value is reached (defaults to 1.0, ie: unanimous)</message>
  <tree>bb08135707f2032128e041c90334914655b6f066</tree>
  <committer>
    <name>Chris</name>
    <email>chris@ChoOyu.local</email>
  </committer>
</commit>
