<commit_before># encoding: utf-8

class BasketController < ApplicationController
  include CookieHelper
  include ActionController::Live

  before_filter :find_basket, except: [:new, :create]
  before_filter :ensure_admin, except: [:new, :create, :find, :show, :share, :set_admin, :delivery_arrived, :pdf]
  before_filter :find_order, only: [:show]
  before_filter :reset_replay

  PIZZADE_URL_MODIFIERS = '?knddomain=1&noflash=1'

  def new
    cookie_set(:action, :choose_shop)
    cookie_delete(:basket)
    cookie_delete(:admin)

    if PINNING['single_basket_mode'] && @basket = Basket.find_editable
      return redirect_to_basket
    end

    fields = %(name url fax)
    if all_pinned?(fields)
      copy_pinned_to_params(fields)
      create
    elsif PINNING['shop_url']
      redirect_to PINNING['shop_url'] + PIZZADE_URL_MODIFIERS
    else
      redirect_to pizzade_root_path + PIZZADE_URL_MODIFIERS
    end
  end

  def create
    @basket = b = Basket.create(params.permit(:shop_name, :shop_url, :fax_number))
    if b.errors.any?
      msgs = "\n• " + b.errors.full_messages.join("\n• ")
      render text: "Could not create basket. Messages: #{msgs}"
      # TODO: nicer rendering
    else
      cookie_set(:action, :share_link)
      cookie_set(:basket, b.uid)
      cookie_set(:admin, b.uid)

      if PINNING['single_basket_mode']
        redirect_to_basket
      else
        redirect_to share_basket_path(b.uid)
      end
    end
  end<commit_msg>fix forgotten rename from last commit<commit_after># encoding: utf-8

class BasketController < ApplicationController
  include CookieHelper
  include ActionController::Live

  before_filter :find_basket, except: [:new, :create]
  before_filter :ensure_admin, except: [:new, :create, :find, :show, :share, :set_admin, :delivery_arrived, :pdf]
  before_filter :find_order, only: [:show]
  before_filter :reset_replay

  PIZZADE_URL_MODIFIERS = '?knddomain=1&noflash=1'

  def new
    cookie_set(:action, :choose_shop)
    cookie_delete(:basket)
    cookie_delete(:admin)

    if PINNING['single_basket_mode'] && @basket = Basket.find_editable
      return redirect_to_basket
    end

    fields = %(name url fax)
    if all_pinned?(fields)
      copy_pinned_to_params(fields)
      create
    elsif PINNING['shop_url']
      redirect_to PINNING['shop_url'] + PIZZADE_URL_MODIFIERS
    else
      redirect_to pizzade_root_path + PIZZADE_URL_MODIFIERS
    end
  end

  def create
    @basket = b = Basket.create(params.permit(:shop_name, :shop_url, :shop_fax))
    if b.errors.any?
      msgs = "\n• " + b.errors.full_messages.join("\n• ")
      render text: "Could not create basket. Messages: #{msgs}"
      # TODO: nicer rendering
    else
      cookie_set(:action, :share_link)
      cookie_set(:basket, b.uid)
      cookie_set(:admin, b.uid)

      if PINNING['single_basket_mode']
        redirect_to_basket
      else
        redirect_to share_basket_path(b.uid)
      end
    end
  end
{'fraction_non_alphanumeric': 0.10419485791610285, 'fraction_numerical': 0.0020297699594046007, 'mean_word_length': 3.591614906832298, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '3087306', 'n_tokens_mistral': 1055, 'n_tokens_neox': 1031, 'n_words': 214}