This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | post '/applicants/new' do | |
| updated_params = modify_date_params(params) | |
| @applicant = Applicant.create(updated_params[:applicant]) | |
| redirect "/applicants/#{@applicant.id}" | |
| end | |
| post '/applicants/:id' do | |
| applicant = Applicant.find_by_id(params[:id]) | |
| updated_params = modify_date_params(params) | |
| applicant.update(updated_params) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class Applicant | |
| include Observable | |
| def update(attributes = {}) | |
| self.update(attributes) | |
| if self.save | |
| notify_observers | |
| end | |
| end | |
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def error?(field) | |
| if flash[:errors_list] | |
| flash[:errors_list].include?(field) | |
| else | |
| false | |
| end | |
| end | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <% if flash[:notice] %> | |
| <p class="notice"><%= flash[:notice] %></p> | |
| <% end %> | |
| <% if flash[:error] %> | |
| <% flash[:error].each do |e| %> | |
| <p class="error message"><%= e + "." %></p> | |
| <% end %> | |
| <% end %> | |
| <div class="form-column"> | |
| <label for="applicant[name]">Name*</label> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | post '/applicants/new' do | |
| updated_params = convert_datetime_params(params) | |
| @applicant = Applicant.create(updated_params[:applicant]) | |
| if @applicant.save | |
| flash[:notice] = "Successfully added new applicant." | |
| redirect "/applicants/#{@applicant.id}" | |
| else | |
| flash[:error] = @applicant.errors.full_messages | |
| flash[:errors_list] = @applicant.errors.messages | |
| redirect "/applicants/new" | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | require './app/models/date_validator' | |
| class Applicant < ActiveRecord::Base | |
| include ActiveModel::Validations | |
| validates_with DateValidator | |
| validates :name, presence: true | |
| validates :email, uniqueness: true, allow_nil: true | |
| validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i, :allow_nil => true | |
| self.per_page = 10 | |
| after_validation :update_state | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class DateValidator < ActiveModel::Validator | |
| def validate(record) | |
| future_date_validation(record) | |
| date_sequence_validation(record) | |
| end | |
| private | |
| def future_date_validation(record) | |
| [:applied_on, :initial_reply_on, :completed_ttt_on, :reviewed_on, :resubmitted_ttt_on, :decision_made_on].each do |field| | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | module StateHelpers | |
| # Current States | |
| def get_applicants_by_state(current_state) | |
| Applicant.where(:state => "#{current_state}").order("#{current_state} ASC") | |
| end | |
| # Time Lapse Helpers | |
| def received_initial_reply | |
| Applicant.all.select { |a| a.initial_reply_on != nil } | |
| end | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class Applicant < ActiveRecord::Base | |
| validates :name, presence: true | |
| validates :email, uniqueness: true, allow_nil: true | |
| validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i, :on => :create, :allow_nil => true | |
| self.per_page = 10 | |
| after_validation :update_state | |
| private | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class Applicant < ActiveRecord::Base | |
| validates :name, presence: true | |
| validates :email, uniqueness: true, allow_nil: true | |
| validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i, :on => :create, :allow_nil => true | |
| self.per_page = 10 | |
| after_validation :update_state | |
| state_machine :initial => "applied_on" do | |
| event :reply do |