<commit_before>class DesignImportsController < ApplicationController
  
  def new
    @designs = Design.find_all_by_public(true, :order => "created_at DESC")
  end
  
  def create
    @design = Design.new
    @design_to_import = Design.find_by_id_and_account_id(params[:design_id])
    @design.attributes = @design_to_import.attributes
    @design.parent = @design_to_import
    @design.public = false
    @design.account = @account
    @design.save  
    
    for template in @design_to_import.templates
      new_template = template.clone
      new_template.design = @design
      new_template.parsed_code = Liquid::Template.parse(template.code)
      new_template.save
    end
    
    for template_file in @design_to_import.template_files
      new_template_file = template_file.clone
      new_template_file.design = @design
      new_template_file.file = template_file.file
      new_template_file.save
    end
    
  end
  
  def show
  end
  
end<commit_msg>Only allow Hot Ink account #1 users to do importing, for now.<commit_after>class DesignImportsController < ApplicationController
  
  def new
    @designs = Design.find_all_by_public(true, :order => "created_at DESC")
  end
  
  def create
    if current_user.account.id == 1
      @design = Design.new
      @design_to_import = Design.find_by_id_and_account_id(params[:design_id])
      @design.attributes = @design_to_import.attributes
      @design.parent = @design_to_import
      @design.public = false
      @design.account = @account
      @design.save  
    
      for template in @design_to_import.templates
        new_template = template.clone
        new_template.design = @design
        new_template.parsed_code = Liquid::Template.parse(template.code)
        new_template.save
      end
    
      for template_file in @design_to_import.template_files
        new_template_file = template_file.clone
        new_template_file.design = @design
        new_template_file.file = template_file.file
        new_template_file.save
      end

    end
  end
  
  def show
  end
  
end
{'fraction_non_alphanumeric': 0.07240038872691934, 'fraction_numerical': 0.0009718172983479105, 'mean_word_length': 2.974903474903475, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5001889', 'n_tokens_mistral': 637, 'n_tokens_neox': 631, 'n_words': 124}