<commit_before>class RealmsController < ApplicationController
  before_filter :require_user
  before_filter :load_realms, :only =>[:index, :show]

  def top_section
    :administer
  end

  def index
    clear_breadcrumbs
    save_breadcrumb(realms_path)
  end

  def new
    require_privilege(Privilege::CREATE, Realm)
    @realm = FrontendRealm.new
    load_backend_realms
  end

  def edit
    require_privilege(Privilege::MODIFY, Realm)
    @realm = FrontendRealm.find(params[:id])
    load_backend_realms
  end

  def update
    require_privilege(Privilege::MODIFY, Realm)
    @realm = FrontendRealm.find(params[:id])

    if params[:commit] == "Reset"
      redirect_to edit_realm_url(@realm) and return
    end

    if @realm.update_attributes(params[:frontend_realm])
      flash[:notice] = 'Realm updated successfully!'
      redirect_to realms_url and return
    end

    load_backend_realms
    render :action => 'edit'
  end

  def create
    require_privilege(Privilege::CREATE, Realm)
    @realm = FrontendRealm.new(params[:frontend_realm])
    if @realm.save
      flash[:notice] = "Realm was added."
      redirect_to realms_path and return
    end

    load_backend_realms
    render :new
  end

  def destroy
    require_privilege(Privilege::MODIFY, Realm)
    if FrontendRealm.destroy(params[:id])
      flash[:notice] = "Realm was deleted!"
    else
      flash[:error] = "Realm was not deleted!"
    end
    redirect_to realms_path
  end

  def multi_destroy
    deleted = []
    not_deleted = []
    if params[:realm_selected].blank?
      flash[:error] = 'You must select at least one realm to delete.'
    else
      FrontendRealm.find(params[:realm_selected]).each do |realm|
        require_privilege(Privilege::MODIFY, Realm)
        if realm.destroy
          deleted << realm.name<commit_msg>redirect to realm show after create<commit_after>class RealmsController < ApplicationController
  before_filter :require_user
  before_filter :load_realms, :only =>[:index, :show]

  def top_section
    :administer
  end

  def index
    clear_breadcrumbs
    save_breadcrumb(realms_path)
  end

  def new
    require_privilege(Privilege::CREATE, Realm)
    @realm = FrontendRealm.new
    load_backend_realms
  end

  def edit
    require_privilege(Privilege::MODIFY, Realm)
    @realm = FrontendRealm.find(params[:id])
    load_backend_realms
  end

  def update
    require_privilege(Privilege::MODIFY, Realm)
    @realm = FrontendRealm.find(params[:id])

    if params[:commit] == "Reset"
      redirect_to edit_realm_url(@realm) and return
    end

    if @realm.update_attributes(params[:frontend_realm])
      flash[:notice] = 'Realm updated successfully!'
      redirect_to realms_url and return
    end

    load_backend_realms
    render :action => 'edit'
  end

  def create
    require_privilege(Privilege::CREATE, Realm)
    @realm = FrontendRealm.new(params[:frontend_realm])
    if @realm.save
      flash[:notice] = "Realm was added."
      redirect_to realm_path(@realm)
    else
      load_backend_realms
      render :new
    end
  end

  def destroy
    require_privilege(Privilege::MODIFY, Realm)
    if FrontendRealm.destroy(params[:id])
      flash[:notice] = "Realm was deleted!"
    else
      flash[:error] = "Realm was not deleted!"
    end
    redirect_to realms_path
  end

  def multi_destroy
    deleted = []
    not_deleted = []
    if params[:realm_selected].blank?
      flash[:error] = 'You must select at least one realm to delete.'
    else
      FrontendRealm.find(params[:realm_selected]).each do |realm|
        require_privilege(Privilege::MODIFY, Realm)
        if realm.destroy
          deleted << realm.name
{'fraction_non_alphanumeric': 0.09068627450980392, 'fraction_numerical': 0.0, 'mean_word_length': 3.3518957345971563, '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': '1873397', 'n_tokens_mistral': 1219, 'n_tokens_neox': 1203, 'n_words': 267}