<commit_before>class RepeatingEventsController < ApplicationController
  def index
    @repeating_events = RepeatingEvent.all
  end

  def show
    @repeating_event = RepeatingEvent.find(params[:id])
  end

  def new
    @repeating_event = RepeatingEvent.new
  end

  def create
    params[:repeating_event][:days] = params[:days]
    if params[:repeating_event][:slot_or_shift] == "time_slot"
      params[:repeating_event][:location_ids] = params[:location_ids]
    else
      params[:repeating_event][:location_ids] = [params[:shift][:location_id]]
    end
    @repeating_event = RepeatingEvent.new(params[:repeating_event])
    wipe = params[:wipe] ? true : false
    if params[:whole_calendar] && !@repeating_event.calendar.default
      @repeating_event.start_date = @repeating_event.calendar.start_date
      @repeating_event.end_date = @repeating_event.calendar.end_date
    end
    warn = @repeating_event.start_time <= Time.now
    begin
      ActiveRecord::Base.transaction do
        @repeating_event.save!
        @failed = @repeating_event.make_future(wipe)
        raise @failed if @failed
      end
      flash[:notice] = "Successfully created repeating event."
      flash[:notice] += "Please note that some events were not created because they started in the past."
      redirect_to @repeating_event
    rescue Exception => e
      @errors = e.message.gsub("Validation failed:", "").split(",")
      @repeating_event = @repeating_event.clone
      render :action => 'new'
    end
    if @errors

    else
    end
  end

  def edit
    @repeating_event = RepeatingEvent.find(params[:id])
    @time_slot = TimeSlot.new
    @shift = Shift.new
  end

  def update
    @repeating_event = RepeatingEvent.find(params[:id])
    if @repeating_event.update_attributes(params[:repeating_event])
      flash[:notice] = "Successfully updated repeating event."
      redirect_to @repeating_event
    else
      render :action => 'edit'
    end
  end

  def destroy
    @repeating_event = RepeatingEvent.find(params[:id])
    RepeatingEvent.destroy_self_and_future(@repeating_event)
    flash[:notice] = "Successfully destroyed repeating event."
    redirect_to repeating_events_url
  end
end<commit_msg>You can edit repeating events now. Yay.<commit_after>class RepeatingEventsController < ApplicationController
  def index
    @repeating_events = RepeatingEvent.all
  end

  def show
    @repeating_event = RepeatingEvent.find(params[:id])
  end

  def new
    @repeating_event = RepeatingEvent.new
  end

  def create
    params[:repeating_event][:days] = params[:days]
    if params[:repeating_event][:slot_or_shift] == "time_slot"
      params[:repeating_event][:location_ids] = params[:location_ids]
    else
      params[:repeating_event][:location_ids] = [params[:shift][:location_id]]
    end
    @repeating_event = RepeatingEvent.new(params[:repeating_event])
    wipe = params[:wipe] ? true : false
    if params[:whole_calendar] && !@repeating_event.calendar.default
      @repeating_event.start_date = @repeating_event.calendar.start_date
      @repeating_event.end_date = @repeating_event.calendar.end_date
    end
    warn = @repeating_event.start_time <= Time.now
    begin
      ActiveRecord::Base.transaction do
        @repeating_event.save!
        @failed = @repeating_event.make_future(wipe)
        raise @failed if @failed
      end
      flash[:notice] = "Successfully created repeating event."
      flash[:notice] += "Please note that some events were not created because they started in the past."
      redirect_to @repeating_event
    rescue Exception => e
      @errors = e.message.gsub("Validation failed:", "").split(",")
      @repeating_event = @repeating_event.clone
      render :action => 'new'
    end
  end

  def edit
    @repeating_event = RepeatingEvent.find(params[:id])
  end

  def update
    @old_repeating_event = RepeatingEvent.find(params[:id])
    params[:repeating_event][:days] = params[:days]
    if params[:repeating_event][:slot_or_shift] == "time_slot"
      params[:repeating_event][:location_ids] = params[:location_ids]
    else
      params[:repeating_event][:location_ids] = [params[:shift][:location_id]]
    end
    @repeating_event = RepeatingEvent.new(params[:repeating_event])
    wipe = params[:wipe] ? true : false
    if params[:whole_calendar] && !@repeating_event.calendar.default
      @repeating_event.start_date = @repeating_event.calendar.start_date
      @repeating_event.end_date = @repeating_event.calendar.end_date
    end
    warn = @repeating_event.start_time <= Time.now
    begin
      ActiveRecord::Base.transaction do
        RepeatingEvent.destroy_self_and_future(@old_repeating_event)
        @repeating_event.save!
        @failed = @repeating_event.make_future(wipe)
        raise @failed if @failed
      end
      flash[:notice] = "Successfully edited repeating event."
      flash[:notice] += "Please note that some events were not created because they started in the past."
      redirect_to @repeating_event
    rescue Exception => e
      @errors = e.message.gsub("Validation failed:", "").split(",")
      @repeating_event = @repeating_event.clone
      render :action => 'edit'
    end
  end

  def destroy
    @repeating_event = RepeatingEvent.find(params[:id])
    ActiveRecord::Base.transaction do
      RepeatingEvent.destroy_self_and_future(@repeating_event)
    end
    flash[:notice] = "Successfully destroyed repeating event."
    redirect_to repeating_events_url
  end
end
{'fraction_non_alphanumeric': 0.10523436075141346, 'fraction_numerical': 0.0, 'mean_word_length': 3.7770034843205575, 'pattern_counts': {'":': 0, '<': 8, '<?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': '6336747', 'n_tokens_mistral': 1756, 'n_tokens_neox': 1735, 'n_words': 343}