<commit_before># encoding: utf-8

class BasketController < ApplicationController
  include CookieHelper

  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 = %w(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 = Basket.create(params.permit(:shop_name, :shop_url, :shop_fax))

    if @basket.errors.any?
      msgs = errors_to_fake_list(b)
      flash[:error] = "Could not create basket. Messages: #{msgs}"
      return redirect_to root_path
    end

    cookie_set(:action, :share_link)
    cookie_set(:basket, @basket.uid)
    cookie_set(:admin, @basket.uid)

    if PINNING['single_basket_mode']
      redirect_to_basket
    else
      redirect_to share_basket_path(@basket.uid)
    end
  end

  def find
    redirect_to_basket
  end

  def show
    keys = [@basket.cache_key, @order.cache_key, view_context.admin?, @basket.clock_running?]
    return unless stale?(etag: keys.join(' '))

    update_action_from_order

    respond_to do |format|
      format.html
      format.svg  { render qrcode: basket_with_uid_url(@basket.uid), level: :l, unit: 6, offset: 10 }
    end
  end

  def unsubmit
    @basket.update_column(:submitted, nil)
    flash[:info] = 'Basket has been reopened and further orders may be made.'<commit_msg>do not report "not modified" when there are flashes present<commit_after># encoding: utf-8

class BasketController < ApplicationController
  include CookieHelper

  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 = %w(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 = Basket.create(params.permit(:shop_name, :shop_url, :shop_fax))

    if @basket.errors.any?
      msgs = errors_to_fake_list(b)
      flash[:error] = "Could not create basket. Messages: #{msgs}"
      return redirect_to root_path
    end

    cookie_set(:action, :share_link)
    cookie_set(:basket, @basket.uid)
    cookie_set(:admin, @basket.uid)

    if PINNING['single_basket_mode']
      redirect_to_basket
    else
      redirect_to share_basket_path(@basket.uid)
    end
  end

  def find
    redirect_to_basket
  end

  def show
    if flash.empty?
      keys = [@basket.cache_key, @order.cache_key, view_context.admin?, @basket.clock_running?]
      return unless stale?(etag: keys.join(' '))
    end

    update_action_from_order

    respond_to do |format|
      format.html
      format.svg  { render qrcode: basket_with_uid_url(@basket.uid), level: :l, unit: 6, offset: 10 }
    end
  end

  def unsubmit
    @basket.update_column(:submitted, nil)
    flash[:info] = 'Basket has been reopened and further orders may be made.'
{'fraction_non_alphanumeric': 0.10161779575328615, 'fraction_numerical': 0.003033367037411527, 'mean_word_length': 3.7219570405727924, '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': '2120323', 'n_tokens_mistral': 1431, 'n_tokens_neox': 1385, 'n_words': 303}