<commit_before>class TrayPositionsController < ApplicationController
  before_filter :authenticate_user!
  def create
    tp = TrayPosition.new(params[:tray_position])
    tp.clipboard_type.capitalize! if tp.clipboard_type
    tp.save
    redirect_to :back
  end
  def replace
    respond_to do |format|
      if params[:del]
        format.html do
          current_user.tray_positions.find(params[:del]).each do |tp|
            if !tp.clipboard_type  && (tp.asset.classifications_count || 0) == 0
              tp.asset.content.destroy
            else
              tp.destroy
            end
          end
          flash[:notice] = "Tray has been updated!"
          redirect_to :back
        end
      end
      if params[:tp]
        format.json do
          new_tp = nil
          params[:tp].each_with_index do |id, position|
            if id == "0"
              new_tp = TrayPosition.new(:user_id => current_user.id, :position => position+1)
              if params[:add_type] == 'asset'
                new_tp.asset_id = params[:add_id]
              else
                new_tp.clipboard_id = params[:add_id]<commit_msg>Don't delete an asset when it is dropped from the tray. At the moment we can't check if it is used in any presentations.<commit_after>class TrayPositionsController < ApplicationController
  before_filter :authenticate_user!
  def create
    tp = TrayPosition.new(params[:tray_position])
    tp.clipboard_type.capitalize! if tp.clipboard_type
    tp.save
    redirect_to :back
  end
  def replace
    respond_to do |format|
      if params[:del]
        format.html do
          current_user.tray_positions.find(params[:del]).each do |tp|
#            if !tp.clipboard_type  && (tp.asset.classifications_count || 0) == 0
#              tp.asset.content.destroy
#            else
#              tp.destroy
#            end
            tp.destroy
          end
          flash[:notice] = "Tray has been updated!"
          redirect_to :back
        end
      end
      if params[:tp]
        format.json do
          new_tp = nil
          params[:tp].each_with_index do |id, position|
            if id == "0"
              new_tp = TrayPosition.new(:user_id => current_user.id, :position => position+1)
              if params[:add_type] == 'asset'
                new_tp.asset_id = params[:add_id]
              else
                new_tp.clipboard_id = params[:add_id]
{'fraction_non_alphanumeric': 0.09147609147609148, 'fraction_numerical': 0.0033264033264033266, 'mean_word_length': 1.941320293398533, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6709788', 'n_tokens_mistral': 713, 'n_tokens_neox': 697, 'n_words': 169}