<commit_before>class Admin::UsersController < AdminController
  helper_method :sort_column, :sort_direction

  before_filter :authenticate_user!
  before_filter :get_activated_users, :only => [:index]
  before_filter :get_reserved_users, :only => [:reserved]

  load_and_authorize_resource :except => [:create]

  layout "admin"

  def create
    @user = User.new
    @user.assign_attributes(params[:user], as: :admin)

    @user.confirmed_at = DateTime.now

    authorize! :create, @user
    if @user.save
      redirect_to admin_user_path(@user), notice: 'User was successfully created.'
    else
      render :new
    end
  end

  def update
    if params[:user][:password] == ''
      params[:user][:password] = <PASSWORD>
      params[:user][:password_confirmation] = nil
    end
    if @user.assign_attributes(params[:user], as: :admin) and @user.save
      @user.features.del
      params[:user][:features].split(',').each {|f| @user.features << f.strip}
      redirect_to admin_user_path(@user), notice: 'User was successfully updated.'
    else
      render :edit
    end
  end

  def approve
    @user.approved = true

    if @user.save<commit_msg>Addign the features to the user<commit_after>class Admin::UsersController < AdminController
  helper_method :sort_column, :sort_direction

  before_filter :authenticate_user!
  before_filter :get_activated_users, :only => [:index]
  before_filter :get_reserved_users, :only => [:reserved]

  load_and_authorize_resource :except => [:create]

  layout "admin"


  def create
    @user = User.new
    @user.assign_attributes(params[:user], as: :admin)

    @user.confirmed_at = DateTime.now

    authorize! :create, @user
    if @user.save
      redirect_to admin_user_path(@user), notice: 'User was successfully created.'
    else
      render :new
    end
  end

  def edit
    @user_features = Ability::FEATURES
  end

  def update
    if params[:user][:password] == ''
      params[:user][:password] = <PASSWORD>
      params[:user][:password_confirmation] = nil
    end
    if @user.assign_attributes(params[:user], as: :admin) and @user.save
      @user.features = params[:user][:features].andand.keys
      redirect_to admin_user_path(@user), notice: 'User was successfully updated.'
    else
      render :edit
    end
  end

  def approve
    @user.approved = true

    if @user.save
{'fraction_non_alphanumeric': 0.11839863713798977, 'fraction_numerical': 0.0, 'mean_word_length': 3.642292490118577, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '6978361', 'n_tokens_mistral': 755, 'n_tokens_neox': 721, 'n_words': 176}