<commit_before>module Spree
  class RecurringOrdersController < Spree::StoreController

    def create
      original_order = Spree::Order.find(recurring_order_params[:original_order_id])
      if original_order.recurring_order.nil?
        @recurring_order = Spree::RecurringOrder.new
        @recurring_order.orders << original_order

        if @recurring_order.save
          redirect_to(spree.recurring_order_url(@recurring_order.id))
        else
          flash[:notice] = "Hmmm... There was a problem creating your regular order. Please get in touch at <EMAIL> and we are going to sort it out for you."
          redirect_to(order_url(original_order.number))
        end
      else
        flash[:notice] = "Hmmm... It seems like this order already has a regular order associated with it. Please get in touch at <EMAIL> if you have any doubts about it"
        redirect_to(order_url(original_order.number))
      end
    end

    def show
      @recurring_order = Spree::RecurringOrder.find(params[:id])
    end

    private

    def recurring_order_params
      params[:recurring_order].permit(:original_order_id)
    end

  end
end
<commit_msg>added update action to recurring_order controller<commit_after>module Spree
  class RecurringOrdersController < Spree::StoreController

    def create
      original_order = Spree::Order.find(recurring_order_params[:original_order_id])
      if original_order.recurring_order.nil?
        @recurring_order = Spree::RecurringOrder.new
        @recurring_order.orders << original_order

        if @recurring_order.save
          redirect_to(spree.recurring_order_url(@recurring_order.id))
        else
          flash[:notice] = "Hmmm... There was a problem creating your regular order. Please get in touch at <EMAIL> and we are going to sort it out for you."
          redirect_to(order_url(original_order.number))
        end
      else
        flash[:notice] = "Hmmm... It seems like this order already has a regular order associated with it. Please get in touch at <EMAIL> if you have any doubts about it"
        redirect_to(order_url(original_order.number))
      end
    end

    def update
      @recurring_order = Spree::RecurringOrder.find(params[:id])
      @recurring_order.update_attributes(update_params)
      render :nothing => true, :status => 200, :content_type => 'text/html'
    end

    def show
      @recurring_order = Spree::RecurringOrder.find(params[:id])
    end

    private

    def recurring_order_params
      params[:recurring_order].permit(:original_order_id)
    end

    def update_params
      params[:recurring_order].permit(:active)
    end

  end
end

{'fraction_non_alphanumeric': 0.07983352251229663, 'fraction_numerical': 0.0011350737797956867, 'mean_word_length': 3.190174326465927, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 10, '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': '1081147', 'n_tokens_mistral': 803, 'n_tokens_neox': 777, 'n_words': 204}