<commit_before>module OrdersHelperOverrides
  unless included_modules.include? OrdersHelperOverrides
    def can_trigger_fulfilled_without_acceptance?
      params[:controller] == 'orders' && at_least_a_moderator?
    end

    def can_trigger_finish?
      params[:controller] == 'orders' && at_least_a_moderator?
    end

    def link_to_orders_for(user)
      options = set_options_from_vars.merge({:user => user})
      link_to(user.trolley_user_display_name, options)
    end

    def link_to_state_unless_current(state, count)
      options = set_options_from_vars.merge({:state => state})
      link_to_unless_current(t("orders.index.#{state}") + show_count_for(count), options)
    end

    def orders_state_headline
      html = super
      if @current_basket != @site_basket
        html += ' ' + t('base.inside') + ' ' + @current_basket.name
      end
      html
    end

    # override ### TODO: this isn't overriding the default method
    def add_ons_logged_in_user_list
      link_html = super

      link_html += link_to_unless_current(t('base.your_cart'),
                                          { :user_id => current_user.id, :controller => :trolleys, :action => :show },
                                          { :tabindex => '2', :class => "trolley-button" })

      content_tag('li', link_html)
    end

    def set_options_from_vars
      options = url_for_options_for_orders_index
      options[:state] = @state if @state
      options[:from] = @from if @from
      options[:until] = @until if @until
      options[:user] = @user if @user
      options
    end

    def url_for_options_for_orders_index
      { :urlified_name => @current_basket.urlified_name,
        :controller => 'orders',
        :action => 'index' }
    end

    def meta_data_for(order)
      html = '<div id="order-meta-data">'
      html += '<h3 id="order-id">' + t('orders.helpers.order_number') + " #{order.id}"
      # TODO: move "order in" to I18n
      html += " ("
      if current_user == order.user && params[:controller] == 'trolleys'
        html += council_full_name_from(order.basket.name)
      else
        html += link_basket_orders(order.basket)
      end
      html += ')</h3>'
      if !order.current? && !(order.contact_name.blank? && order.contact_phone.blank?)
        html += '<h4 id="order-info">'
        html += order.contact_name + ' - ' if order.contact_name
        html += order.contact_phone if order.contact_phone
        html += '</h4>'
      end
      html += '</div>'
    end

    def link_basket_orders(basket)
      options = set_options_from_vars.merge({:urlified_name => basket.urlified_name})
      link_to(council_full_name_from(basket.name), options)
    end
    
    def clear_extra_params
      if @user || @from || @until
        options = set_options_from_vars

        to_be_cleared = [:user, :trolley, :from, :until]

        to_be_cleared.each { |key_sym| options.delete(key_sym) }

        clear_link = link_to(t("orders.helpers.clear_params"), options)

        clear_link = ' [ ' + clear_link + ' ]'
        content_tag('span', clear_link, :class => 'clear-params')
      end<commit_msg>Added hook method so that other add-ons can tie into order meta data display.<commit_after>module OrdersHelperOverrides
  unless included_modules.include? OrdersHelperOverrides
    def can_trigger_fulfilled_without_acceptance?
      params[:controller] == 'orders' && at_least_a_moderator?
    end

    def can_trigger_finish?
      params[:controller] == 'orders' && at_least_a_moderator?
    end

    def link_to_orders_for(user)
      options = set_options_from_vars.merge({:user => user})
      link_to(user.trolley_user_display_name, options)
    end

    def link_to_state_unless_current(state, count)
      options = set_options_from_vars.merge({:state => state})
      link_to_unless_current(t("orders.index.#{state}") + show_count_for(count), options)
    end

    def orders_state_headline
      html = super
      if @current_basket != @site_basket
        html += ' ' + t('base.inside') + ' ' + @current_basket.name
      end
      html
    end

    # override ### TODO: this isn't overriding the default method
    def add_ons_logged_in_user_list
      link_html = super

      link_html += link_to_unless_current(t('base.your_cart'),
                                          { :user_id => current_user.id, :controller => :trolleys, :action => :show },
                                          { :tabindex => '2', :class => "trolley-button" })

      content_tag('li', link_html)
    end

    def set_options_from_vars
      options = url_for_options_for_orders_index
      options[:state] = @state if @state
      options[:from] = @from if @from
      options[:until] = @until if @until
      options[:user] = @user if @user
      options
    end

    def url_for_options_for_orders_index
      { :urlified_name => @current_basket.urlified_name,
        :controller => 'orders',
        :action => 'index' }
    end

    # override this if you want to tie-in to meta_data_for's headline
    def meta_data_headline_extentions_for(order)
    end

    def meta_data_for(order)
      html = '<div id="order-meta-data">'
      html += '<h3 id="order-id">' + t('orders.helpers.order_number') + " #{order.id}"
      # TODO: move "order in" to I18n
      html += " ("
      if current_user == order.user && params[:controller] == 'trolleys'
        html += council_full_name_from(order.basket.name)
      else
        html += link_basket_orders(order.basket)
      end
      html += ')'

      html += meta_data_headline_extentions_for(order)

      html += '</h3>'

      if !order.current? && !(order.contact_name.blank? && order.contact_phone.blank?)
        html += '<h4 id="order-info">'
        html += order.contact_name + ' - ' if order.contact_name
        html += order.contact_phone if order.contact_phone
        html += '</h4>'
      end
      html += '</div>'
    end

    def link_basket_orders(basket)
      options = set_options_from_vars.merge({:urlified_name => basket.urlified_name})
      link_to(council_full_name_from(basket.name), options)
    end
    
    def clear_extra_params
      if @user || @from || @until
        options = set_options_from_vars

        to_be_cleared = [:user, :trolley, :from, :until]

        to_be_cleared.each { |key_sym| options.delete(key_sym) }

        clear_link = link_to(t("orders.helpers.clear_params"), options)

        clear_link = ' [ ' + clear_link + ' ]'
        content_tag('span', clear_link, :class => 'clear-params')
      end
{'fraction_non_alphanumeric': 0.12146676852559206, 'fraction_numerical': 0.0021390374331550803, 'mean_word_length': 2.7341699942954936, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4548516', 'n_tokens_mistral': 2125, 'n_tokens_neox': 2074, 'n_words': 410}