<commit_before># Add, delete, and edit Person information. Also merge.
class Admin::PeopleController < Admin::AdminController
  before_filter :require_current_person
  # Funky permissions filtering here to allow officials and promoters download Excel file
  skip_filter :require_administrator, :only => :index
  before_filter :require_administrator_or_promoter_or_official, :only => :index
  before_filter :remember_event
  layout 'admin/application', :except => [:card, :cards]

  include ApplicationHelper
  include ActionView::Helpers::TextHelper
  
  # Search for People by name. This is a 'like' search on the concatenated 
  # first and last name, and aliases. E.g.,:
  # 'son' finds:
  #  * <NAME>
  #  * <NAME> 
  #  * <NAME>
  #  * <NAME>
  #  * <NAME> (with an '<NAME>' alias)
  # Store previous search in session and cookie as 'person_name'.
  # Limit results to RacingAssociation.current.search_results_limit
  # === Params
  # * name
  # === Assigns
  # * person: Array of People
  def index
    if params['format'] == 'ppl' || params['format'] == 'xls'
      return export
    end
    
    @people = []
    @name = params[:term] || params[:name] || session[:person_name] || cookies[:person_name] || ''
    @name.strip!
    session['person_name'] = @name
    cookies[:person_name] = { :value => @name, :expires => Time.zone.now + 36000 }
    if @name.blank?
      @people = []
    else
      @people = Person.find_all_by_name_like(@name, RacingAssociation.current.search_results_limit)
      @people = @people + Person.find_by_number(@name)
      @people = @people.stable_sort_by(:first_name).stable_sort_by(:last_name)
    end
    if @people.size == RacingAssociation.current.search_results_limit
      flash[:notice] = "First #{RacingAssociation.current.search_results_limit} people"
    end

    @current_year = current_date.year
  end

  # == Params
  # * excel_layout: "scoring_sheet" for fewer columns -- intended for scoring race results. "endicia" for card stickers.
  # * include: "print_cards"
  # * format: "ppl" for FinishLynx scoring
  def export
    date = current_date
    if params['excel_layout'] == 'scoring_sheet'
      file_name = 'scoring_sheet.xls'
    elsif params['include'] == 'print_cards'
      file_name = 'print_cards.xls'
    elsif params['format'] == 'ppl'
      file_name = 'lynx.ppl'
    else
      file_name = "people_#{date.year}_#{date.month}_#{date.day}.#{params['format']}"
    end
    headers['Content-Disposition'] = "filename=\"#{file_name}\""

    @people = Person.find_all_for_export(date, params['include'])
    
    respond_to do |format|
      format.html
      format.ppl
      format.xls {
        if params['excel_layout'] == 'scoring_sheet'
          render :template => 'admin/people/scoring_sheet' 
        elsif params['excel_layout'] == 'endicia'
          render :template => 'admin/people/endicia' 
        end
      }
    end
  end
  
  def new
    @year = current_date.year
    @person = Person.new
    @race_numbers = []
    @years = (2005..(RacingAssociation.current.next_year)).to_a.reverse
    render :edit
  end<commit_msg>Use simpler render syntax<commit_after># Add, delete, and edit Person information. Also merge.
class Admin::PeopleController < Admin::AdminController
  before_filter :require_current_person
  # Funky permissions filtering here to allow officials and promoters download Excel file
  skip_filter :require_administrator, :only => :index
  before_filter :require_administrator_or_promoter_or_official, :only => :index
  before_filter :remember_event
  layout 'admin/application', :except => [:card, :cards]

  include ApplicationHelper
  include ActionView::Helpers::TextHelper
  
  # Search for People by name. This is a 'like' search on the concatenated 
  # first and last name, and aliases. E.g.,:
  # 'son' finds:
  #  * <NAME>
  #  * <NAME> 
  #  * <NAME>
  #  * <NAME>
  #  * <NAME> (with an '<NAME>' alias)
  # Store previous search in session and cookie as 'person_name'.
  # Limit results to RacingAssociation.current.search_results_limit
  # === Params
  # * name
  # === Assigns
  # * person: Array of People
  def index
    if params['format'] == 'ppl' || params['format'] == 'xls'
      return export
    end
    
    @people = []
    @name = params[:term] || params[:name] || session[:person_name] || cookies[:person_name] || ''
    @name.strip!
    session['person_name'] = @name
    cookies[:person_name] = { :value => @name, :expires => Time.zone.now + 36000 }
    if @name.blank?
      @people = []
    else
      @people = Person.find_all_by_name_like(@name, RacingAssociation.current.search_results_limit)
      @people = @people + Person.find_by_number(@name)
      @people = @people.stable_sort_by(:first_name).stable_sort_by(:last_name)
    end
    if @people.size == RacingAssociation.current.search_results_limit
      flash[:notice] = "First #{RacingAssociation.current.search_results_limit} people"
    end

    @current_year = current_date.year
  end

  # == Params
  # * excel_layout: "scoring_sheet" for fewer columns -- intended for scoring race results. "endicia" for card stickers.
  # * include: "print_cards"
  # * format: "ppl" for FinishLynx scoring
  def export
    date = current_date
    if params['excel_layout'] == 'scoring_sheet'
      file_name = 'scoring_sheet.xls'
    elsif params['include'] == 'print_cards'
      file_name = 'print_cards.xls'
    elsif params['format'] == 'ppl'
      file_name = 'lynx.ppl'
    else
      file_name = "people_#{date.year}_#{date.month}_#{date.day}.#{params['format']}"
    end
    headers['Content-Disposition'] = "filename=\"#{file_name}\""

    @people = Person.find_all_for_export(date, params['include'])
    
    respond_to do |format|
      format.html
      format.ppl
      format.xls {
        if params['excel_layout'] == 'scoring_sheet'
          render 'admin/people/scoring_sheet' 
        elsif params['excel_layout'] == 'endicia'
          render 'admin/people/endicia' 
        end
      }
    end
  end
  
  def new
    @year = current_date.year
    @person = Person.new
    @race_numbers = []
    @years = (2005..(RacingAssociation.current.next_year)).to_a.reverse
    render :edit
  end
{'fraction_non_alphanumeric': 0.12904269081500647, 'fraction_numerical': 0.0029107373868046574, 'mean_word_length': 3.4115549215406564, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6975206', 'n_tokens_mistral': 2018, 'n_tokens_neox': 1965, 'n_words': 456}