<commit_before>class SetupController < ApplicationController
  before_filter :check_config, :only => 'index'
  layout 'accounts'

  def index
    return if not request.post?

    this_blog.blog_name = params[:setting][:blog_name]
    this_blog.base_url = blog_base_url

    @user = User.new(:login => 'admin', :email => params[:setting][:email])
    @user.password = <PASSWORD>
    @user.name = @user.login

    unless this_blog.valid? and @user.valid?
      redirect_to :action => 'index'
      return
    end

    return unless this_blog.save

    session[:tmppass] = @user.password

    return unless @user.save

    self.current_user = @user
    session[:user_id] = @user.id

    # FIXME: Crappy hack : by default, the auto generated post is user_id less and it makes Typo crash
    if User.count == 1
      art = Article.find(:first)
      art.user_id = @user.id
      art.save
    end
    redirect_to :action => 'confirm'
  end

  private
  def generate_password
    chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
    newpass = ""
    1.upto(7) { |i| newpass << chars[rand(chars.size-1)] }
    return newpass
  end

  def check_config
    return unless this_blog.configured?
    redirect_to :controller => 'articles', :action => 'index'
  end
end<commit_msg>changing setup_controller for habtm semantics change<commit_after>class SetupController < ApplicationController
  before_filter :check_config, :only => 'index'
  layout 'accounts'

  def index
    return if not request.post?

    this_blog.blog_name = params[:setting][:blog_name]
    this_blog.base_url = blog_base_url

    @user = User.new(:login => 'admin', :email => params[:setting][:email])
    @user.password = <PASSWORD>
    @user.name = @user.login

    unless this_blog.valid? and @user.valid?
      redirect_to :action => 'index'
      return
    end

    return unless this_blog.save

    session[:tmppass] = <PASSWORD>

    return unless @user.save

    self.current_user = @user
    session[:user_id] = @user.id

    # FIXME: Crappy hack : by default, the auto generated post is user_id less and it makes Typo crash
    if User.count == 1
      art = Article.find(:first)
      art.user = @user
      art.save
    end
    redirect_to :action => 'confirm'
  end

  private
  def generate_password
    chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
    newpass = ""
    1.upto(7) { |i| newpass << chars[rand(chars.size-1)] }
    return newpass
  end

  def check_config
    return unless this_blog.configured?
    redirect_to :controller => 'articles', :action => 'index'
  end
end
{'fraction_non_alphanumeric': 0.12814556716995743, 'fraction_numerical': 0.004645760743321719, 'mean_word_length': 3.050156739811912, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 20, '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': '3379853', 'n_tokens_mistral': 875, 'n_tokens_neox': 838, 'n_words': 216}