<commit_before>class ApplicationController < ActionController::Base
  protect_from_forgery

  before_filter :authenticate_user!
  before_filter :parse_date

  clear_helpers


  ActiveScaffold.set_defaults do |config|
    config.ignore_columns.add [:created_at, :updated_at, :lock_version]
    config.create.link.label = :create_link
    config.delete.link.label = :delete_link
    config.show.link.label = :show_link
    config.update.link.label = :update_link
    config.search.link.label = :search_link    
    config.delete.link.confirm = :delete_message       
    #Faz com que a busca seja enviada ao servidor enquanto o usuário digita
    config.search.live = true              
    #config.search.link.cancel = false        
  end
  
  # Defines which controller and action should be shown when the base
  # URL is acessed (root route in routes.rb).
  def root
    redirect_to :controller => 'enrollments', :action => 'index'
  end
  
  private

  #def authenticate
  #  redirect_to login_url unless User.find_by_id(session[:user_id])
  #end

  # This application has custom values for date inputs, having month and year as default for most dates
  # here we nullify invalid dates that comes from the request
  # invalid dates consists in dates with year < 1000
  def parse_date
    if params[:record]
      external_key = "";
      invalid_year = false;
      params[:record].each {|key,value|
        if key.include?("1i")
          invalid_year = value.to_i < 1000
          external_key = key.split("(")[0]
        end

        if invalid_year
          invalid_year = false
          params[:record].delete_if{|key,value|
            key.include?(external_key)
          }

          params[:record][external_key] = nil
        end
      }
    end
  end
end
<commit_msg>Cada tipo de permissao tem o root que tem acesso<commit_after>class ApplicationController < ActionController::Base
  protect_from_forgery

  before_filter :authenticate_user!
  before_filter :parse_date

  clear_helpers


  ActiveScaffold.set_defaults do |config|
    config.ignore_columns.add [:created_at, :updated_at, :lock_version]
    config.create.link.label = :create_link
    config.delete.link.label = :delete_link
    config.show.link.label = :show_link
    config.update.link.label = :update_link
    config.search.link.label = :search_link
    config.delete.link.confirm = :delete_message
    #Faz com que a busca seja enviada ao servidor enquanto o usuário digita
    config.search.live = true
    #config.search.link.cancel = false        
  end

  # Defines which controller and action should be shown when the base
  # URL is acessed (root route in routes.rb).
  def root
    [Enrollment, Professor, ScholarshipDuration, Phase, Course, City, User].each do |model|
      if can? :read, model
        redirect_to(:controller => model.name.underscore.pluralize.downcase, :action => 'index') and return
      end
    end

  end

  private

  #def authenticate
  #  redirect_to login_url unless User.find_by_id(session[:user_id])
  #end

  # This application has custom values for date inputs, having month and year as default for most dates
  # here we nullify invalid dates that comes from the request
  # invalid dates consists in dates with year < 1000
  def parse_date
    if params[:record]
      external_key = "";
      invalid_year = false;
      params[:record].each { |key, value|
        if key.include?("1i")
          invalid_year = value.to_i < 1000
          external_key = key.split("(")[0]
        end

        if invalid_year
          invalid_year = false
          params[:record].delete_if { |key, value|
            key.include?(external_key)
          }

          params[:record][external_key] = nil
        end
      }
    end
  end
end

{'fraction_non_alphanumeric': 0.08043310131477185, 'fraction_numerical': 0.005155968032998196, 'mean_word_length': 2.5240690281562217, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7137644', 'n_tokens_mistral': 1254, 'n_tokens_neox': 1109, 'n_words': 316}