<commit_before>class BhsiApplicationsController < ApplicationController

  before_filter :authenticate_user!, :only => [:create]

  def index
    redirect_to new_bhsi_application_path
  end

  def redirect
    redirect_to new_user_registration_path, :notice => 'To submit your application, please first create an account or log in.'
  end

  def new
    @meta_data = {:page_title => "Bluhm/Helfand Social Innovation Fellowship", :og_image => "http://www.chicagoideas.com/assets/application/affilliate_events_banner.jpg", :og_title => "Bluhm/Helfand Social Innovation Fellowship | Chicago Ideas Week", :og_type => "website", :og_desc => "Chicago Ideas Week (CIW) is about the sharing of ideas, inspiring action and igniting change to positively impact our world. People who come to CIW are artists, engineers, technologists, inventors, scientists, musicians, economists, explorers-and, well...just innately passionate."}
    #if current_user and current_user.bhsi_application.present?
    if current_user and current_user.bhsi_application.present?
      flash[:notice] = 'Thank you, your application has already been recieved.'
      redirect_to root_path
    elsif current_user
      @bhsi_application = current_user.build_bhsi_application
      @bhsi_application.build_bhsi_longtext
    else

      @bhsi_application = BhsiApplication.new
      @bhsi_application.build_bhsi_longtext
    end
  end

  def create
    # Prevent duplicate submissions
    if current_user and current_user.bhsi_application.blank?

      @meta_data = {:page_title => "Bluhm/Helfand Social Innovation Fellowship", :og_image => "http://www.chicagoideas.com/assets/application/affilliate_events_banner.jpg", :og_title => "Bluhm/Helfand Social Innovation Fellowship | Chicago Ideas Week", :og_type => "website", :og_desc => "Chicago Ideas Week (CIW) is about the sharing of ideas, inspiring action and igniting change to positively impact our world. People who come to CIW are artists, engineers, technologists, inventors, scientists, musicians, economists, explorers-and, well...just innately passionate."}
      @bhsi_application = current_user.build_bhsi_application(params[:bhsi_application])

      if @bhsi_application.save
        render 'application/confirmation', :locals => {:title => "BHSI Application Confirmation", :body => "Thank you for applying to the Bluhm/Helfand Social Innovation Fellowship. BHSI semi-finalists will be announced in mid-June.", :url => "http://bit.ly/wdTJfn", :share_text => "I applied to the #BHSI Fellowship at @chicagoideas! RT to all #innovative #socent! Applications close 5/21. Apply today: http://bit.ly/wdTJfn"}

      else
        flash[:notice] = 'Please fill in all required fields!'
        @bhsi_appliction = @bhsi_application
        render :new<commit_msg>Geez, dont use "and", use &&<commit_after>class BhsiApplicationsController < ApplicationController

  before_filter :authenticate_user!, :only => [:create]

  def index
    redirect_to new_bhsi_application_path
  end

  def redirect
    redirect_to new_user_registration_path, :notice => 'To submit your application, please first create an account or log in.'
  end

  def new
    @meta_data = {:page_title => "Bluhm/Helfand Social Innovation Fellowship", :og_image => "http://www.chicagoideas.com/assets/application/affilliate_events_banner.jpg", :og_title => "Bluhm/Helfand Social Innovation Fellowship | Chicago Ideas Week", :og_type => "website", :og_desc => "Chicago Ideas Week (CIW) is about the sharing of ideas, inspiring action and igniting change to positively impact our world. People who come to CIW are artists, engineers, technologists, inventors, scientists, musicians, economists, explorers-and, well...just innately passionate."}
    #if current_user and current_user.bhsi_application.present?
    if current_user && current_user.bhsi_application.present?
      flash[:notice] = 'Thank you, your application has already been recieved.'
      redirect_to root_path
    elsif current_user
      @bhsi_application = current_user.build_bhsi_application
      @bhsi_application.build_bhsi_longtext
    else

      @bhsi_application = BhsiApplication.new
      @bhsi_application.build_bhsi_longtext
    end
  end

  def create
    # Prevent duplicate submissions
    if current_user and current_user.bhsi_application.blank?

      @meta_data = {:page_title => "Bluhm/Helfand Social Innovation Fellowship", :og_image => "http://www.chicagoideas.com/assets/application/affilliate_events_banner.jpg", :og_title => "Bluhm/Helfand Social Innovation Fellowship | Chicago Ideas Week", :og_type => "website", :og_desc => "Chicago Ideas Week (CIW) is about the sharing of ideas, inspiring action and igniting change to positively impact our world. People who come to CIW are artists, engineers, technologists, inventors, scientists, musicians, economists, explorers-and, well...just innately passionate."}
    if current_user && current_user.bhsi_application.blank?
      @bhsi_application = current_user.build_bhsi_application(params[:bhsi_application])

      if @bhsi_application.save
        render 'application/confirmation', :locals => {:title => "BHSI Application Confirmation", :body => "Thank you for applying to the Bluhm/Helfand Social Innovation Fellowship. BHSI semi-finalists will be announced in mid-June.", :url => "http://bit.ly/wdTJfn", :share_text => "I applied to the #BHSI Fellowship at @chicagoideas! RT to all #innovative #socent! Applications close 5/21. Apply today: http://bit.ly/wdTJfn"}

      else
        flash[:notice] = 'Please fill in all required fields!'
        @bhsi_appliction = @bhsi_application
        render :new
{'fraction_non_alphanumeric': 0.09134444838595246, 'fraction_numerical': 0.001064207165661582, 'mean_word_length': 4.627744510978044, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1362103', 'n_tokens_mistral': 1681, 'n_tokens_neox': 1568, 'n_words': 498}