<commit_before>class Admin::BaseController < ApplicationController
  layout "admin"

  renders_with_error_proc :below_field
  include CacheableFlash
  include Widgets

  before_filter :set_site, :set_locale, :set_timezone
  helper :base, :content, :comments, :users
  helper_method :admin_section_path_for

  authentication_required

  attr_accessor :site

  widget :menu_global,   :partial => 'widgets/admin/menu_global'

  widget :menu_site,     :partial => 'widgets/admin/menu_site',
                         :except  => { :controller => 'admin/sites', :action => [:index, :new] }

  widget :section_tree,  :partial => 'widgets/admin/section_tree',
                         :except  => { :controller => 'admin/sites', :action => [:index, :new] },
                         :only    => { :controller => ['admin/sites', 'admin/sections', 'admin/articles', 'admin/wikipages'] }

  widget :menu_section,  :partial => 'widgets/admin/menu_section',
                         :except => { :controller => ['admin/sections'], :action => [:index, :new] },
                         :only  => { :controller => ['admin/sections', 'admin/articles', 'admin/wikipages', 'admin/categories', 'admin/comments'] }


  # TODO delegate this to the section class? or the controller, even?
  # like Admin::WikipagesController.default_route_helper
  def admin_section_path_for(section)
    case section
      when Wiki     then admin_wikipages_path section.site, section
      when Blog     then admin_articles_path section.site, section
      when Forum    then admin_section_path section.site, section
      when Section  then admin_articles_path section.site, section
      # else                 admin_articles_path section.site, section
    end
  end

  protected

    def require_authentication
      unless current_user and current_user.has_role?(Role.build(:admin, @site))
        return redirect_to_login("You need to be a moderator to view this page.")
      end
      super
    end<commit_msg>fix login required message<commit_after>class Admin::BaseController < ApplicationController
  layout "admin"

  renders_with_error_proc :below_field
  include CacheableFlash
  include Widgets

  before_filter :set_site, :set_locale, :set_timezone
  helper :base, :content, :comments, :users
  helper_method :admin_section_path_for

  authentication_required

  attr_accessor :site

  widget :menu_global,   :partial => 'widgets/admin/menu_global'

  widget :menu_site,     :partial => 'widgets/admin/menu_site',
                         :except  => { :controller => 'admin/sites', :action => [:index, :new] }

  widget :section_tree,  :partial => 'widgets/admin/section_tree',
                         :except  => { :controller => 'admin/sites', :action => [:index, :new] },
                         :only    => { :controller => ['admin/sites', 'admin/sections', 'admin/articles', 'admin/wikipages'] }

  widget :menu_section,  :partial => 'widgets/admin/menu_section',
                         :except => { :controller => ['admin/sections'], :action => [:index, :new] },
                         :only  => { :controller => ['admin/sections', 'admin/articles', 'admin/wikipages', 'admin/categories', 'admin/comments'] }


  # TODO delegate this to the section class? or the controller, even?
  # like Admin::WikipagesController.default_route_helper
  def admin_section_path_for(section)
    case section
      when Wiki     then admin_wikipages_path section.site, section
      when Blog     then admin_articles_path section.site, section
      when Forum    then admin_section_path section.site, section
      when Section  then admin_articles_path section.site, section
      # else                 admin_articles_path section.site, section
    end
  end

  protected

    def require_authentication
      unless current_user and current_user.has_role?(Role.build(:admin, @site))
        return redirect_to_login("You need to be an admin to view this page.")
      end
      super
    end
{'fraction_non_alphanumeric': 0.10881612090680101, 'fraction_numerical': 0.0, 'mean_word_length': 3.0603271983640083, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, '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': '7589582', 'n_tokens_mistral': 1149, 'n_tokens_neox': 1087, 'n_words': 284}