<commit_before>class Fae::ApplicationController < ActionController::Base
  include Fae::NavItems
  include Fae::ApplicationControllerConcern

  helper Fae::ViewHelper

  before_filter :authenticate_user!
  before_filter :build_nav
  before_filter :set_option
  before_filter :detect_cancellation


private

  def super_admin_only
    redirect_to fae.root_path, flash: { error: t('fae.unauthorized_error') } unless current_user.super_admin?
  end

  def admin_only
    redirect_to fae.root_path, flash: { error: t('fae.unauthorized_error') } unless current_user.super_admin? || current_user.admin?
  end

  def show_404
    render template: 'fae/pages/error404.html.slim', layout: 'fae/error.html.slim', status: :not_found
  end

  def set_option
    @option = Fae::Option.instance
  end

  def detect_cancellation
    flash.now[:alert] = 'Your changes were not saved.' if params[:cancelled].present? && params[:cancelled]== "true"
  end

  def build_nav
    if current_user
      @fae_nav_items = [
        { text: "Dashboard", path: fae.root_path, class_name: "main_nav-link-dashboard" }
        ]

      @fae_nav_items += nav_items if nav_items.present?

      if current_user.super_admin?
        sublinks = []
        sublinks << { text: 'Users', path: fae.users_path}
        sublinks << { text: 'Root Settings', path: fae.option_path }
        @fae_nav_items << { text: 'Admin', path: '#', class_name: 'main_nav-link-admin main_nav-link-users', sublinks: sublinks }
      elsif current_user.admin?
        @fae_nav_items << { text: 'Users', path: fae.users_path, class_name: 'main_nav-link-users' }
      end
    end
  end
<commit_msg>changed flash message on cancel button and text changes to error rather than alert<commit_after>class Fae::ApplicationController < ActionController::Base
  include Fae::NavItems
  include Fae::ApplicationControllerConcern

  helper Fae::ViewHelper

  before_filter :authenticate_user!
  before_filter :build_nav
  before_filter :set_option
  before_filter :detect_cancellation


private

  def super_admin_only
    redirect_to fae.root_path, flash: { error: t('fae.unauthorized_error') } unless current_user.super_admin?
  end

  def admin_only
    redirect_to fae.root_path, flash: { error: t('fae.unauthorized_error') } unless current_user.super_admin? || current_user.admin?
  end

  def show_404
    render template: 'fae/pages/error404.html.slim', layout: 'fae/error.html.slim', status: :not_found
  end

  def set_option
    @option = Fae::Option.instance
  end

  def detect_cancellation
    flash.now[:error] = 'Your changes were not saved.' if params[:cancelled].present? && params[:cancelled]== "true"
  end

  def build_nav
    if current_user
      @fae_nav_items = [
        { text: "Dashboard", path: fae.root_path, class_name: "main_nav-link-dashboard" }
        ]

      @fae_nav_items += nav_items if nav_items.present?

      if current_user.super_admin?
        sublinks = []
        sublinks << { text: 'Users', path: fae.users_path}
        sublinks << { text: 'Root Settings', path: fae.option_path }
        @fae_nav_items << { text: 'Admin', path: '#', class_name: 'main_nav-link-admin main_nav-link-users', sublinks: sublinks }
      elsif current_user.admin?
        @fae_nav_items << { text: 'Users', path: fae.users_path, class_name: 'main_nav-link-users' }
      end
    end
  end

{'fraction_non_alphanumeric': 0.10922112802148612, 'fraction_numerical': 0.0035810205908683975, 'mean_word_length': 3.7885714285714287, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 3, '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': '3216429', 'n_tokens_mistral': 1136, 'n_tokens_neox': 1111, 'n_words': 247}