<commit_before>class ApplicationController < ActionController::Base
  include FeatureHelper

  helper MojHelper
  force_ssl if Rails.configuration.try(:start_secure_session)

  protect_from_forgery with: :exception
  before_action :ensure_user

private

  def user_for_paper_trail
    logged_in? ? current_user.id : nil
  end

  def info_for_paper_trail
    { ip_address: request.remote_ip, user_agent: request.user_agent }
  end

  def can_add_person_here?
    false
  end
  helper_method :can_add_person_here?

  def current_user
    @current_user ||= Login.current_user(session)
  rescue ActiveRecord::RecordNotFound
    session.destroy
  end
  helper_method :current_user

  def logged_in?
    current_user.present?
  end
  helper_method :logged_in?

  def super_admin?
    logged_in? && current_user.super_admin?
  end
  helper_method :super_admin?

  def ensure_user
    return true if logged_in?
    session[:desired_path] = request.fullpath
    redirect_to new_sessions_path
  end

  def login_person(person)
    login_service = Login.new(session, person)
    login_service.login

    path = session.delete(:desired_path) || '/'
    if path == '/' && login_service.edit_profile?
      path = edit_person_path(person, prompt: :profile)
    end
    redirect_to path
  end

  def set_hint_group
    if session[:last_group_visited]
      @hint_group = Group.find(session[:last_group_visited])
    end
  end

  def i18n_flash(type, *partial_key, **options)
    full_key = [
      :controllers, controller_name, *partial_key
    ].join('.')
    flash[type] = I18n.t(full_key, options)
  end

  def notice(*partial_key, **options)
    i18n_flash :notice, partial_key, options
  end

  def error(*partial_key, **options)
    i18n_flash :error, partial_key, options
  end
end<commit_msg>Include namespace when localising notices<commit_after>class ApplicationController < ActionController::Base
  include FeatureHelper

  helper MojHelper
  force_ssl if Rails.configuration.try(:start_secure_session)

  protect_from_forgery with: :exception
  before_action :ensure_user

private

  def user_for_paper_trail
    logged_in? ? current_user.id : nil
  end

  def info_for_paper_trail
    { ip_address: request.remote_ip, user_agent: request.user_agent }
  end

  def can_add_person_here?
    false
  end
  helper_method :can_add_person_here?

  def current_user
    @current_user ||= Login.current_user(session)
  rescue ActiveRecord::RecordNotFound
    session.destroy
  end
  helper_method :current_user

  def logged_in?
    current_user.present?
  end
  helper_method :logged_in?

  def super_admin?
    logged_in? && current_user.super_admin?
  end
  helper_method :super_admin?

  def ensure_user
    return true if logged_in?
    session[:desired_path] = request.fullpath
    redirect_to new_sessions_path
  end

  def login_person(person)
    login_service = Login.new(session, person)
    login_service.login

    path = session.delete(:desired_path) || '/'
    if path == '/' && login_service.edit_profile?
      path = edit_person_path(person, prompt: :profile)
    end
    redirect_to path
  end

  def set_hint_group
    if session[:last_group_visited]
      @hint_group = Group.find(session[:last_group_visited])
    end
  end

  def i18n_flash(type, *partial_key, **options)
    full_key = [
      :controllers, controller_path, *partial_key
    ].join('.')
    flash[type] = I18n.t(full_key, options)
  end

  def notice(*partial_key, **options)
    i18n_flash :notice, partial_key, options
  end

  def error(*partial_key, **options)
    i18n_flash :error, partial_key, options
  end
end
{'fraction_non_alphanumeric': 0.08166666666666667, 'fraction_numerical': 0.0044444444444444444, 'mean_word_length': 3.9806362378976488, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4613938', 'n_tokens_mistral': 1219, 'n_tokens_neox': 1185, 'n_words': 255}