<commit_before># encoding: UTF-8
class WorkLogsController < ApplicationController
  before_filter :load_log, :only => [ :edit, :update, :destroy ]
  before_filter :load_task_and_build_log, :only => [ :new, :create ]

  helper_method :can_delete_log?

  def new
  end

  def create
    setup_log_from_params

    if @log.save
      update_task_for_log(@log, params[:task])

      flash['notice'] = _("Log entry created...")
      redirect_from_last
    else
      flash["notice"] = _("Error creating log entry")
      render :new
    end
  end

  def edit
  end

  def update
    setup_log_from_params

    if @log.save
      update_task_for_log(@log, params[:task])

      flash['notice'] = _("Log entry saved...")
      redirect_from_last
    else
      flash["notice"] = _("Error saving log entry")
      render :edit
    end
  end

  def destroy
    if can_delete_log?(@log)
      @log.destroy
      flash[:notice] = _("Log entry deleted...")
    else
      flash[:notice] = _("You don't have access to that log...")
    end

    redirect_from_last
  end

  def update_work_log
    unless current_user.can_approve_work_logs?
      render :nothing => true
      return false
    end
    log = WorkLog.accessed_by(current_user).find(params[:id])
    log.status= params[:work_log][:status]

    render :text => log.save.to_s
  end

  private<commit_msg>When creating a new work log, the user gets redirected to the tasks page<commit_after># encoding: UTF-8
class WorkLogsController < ApplicationController
  before_filter :load_log, :only => [ :edit, :update, :destroy ]
  before_filter :load_task_and_build_log, :only => [ :new, :create ]

  helper_method :can_delete_log?

  def new
  end

  def create
    setup_log_from_params

    if @log.save
      update_task_for_log(@log, params[:task])

      flash['notice'] = _("Log entry created...")
      redirect_to '/tasks/list'
    else
      flash["notice"] = _("Error creating log entry")
      render :new
    end
  end

  def edit
  end

  def update
    setup_log_from_params

    if @log.save
      update_task_for_log(@log, params[:task])

      flash['notice'] = _("Log entry saved...")
      redirect_to '/tasks/list'
    else
      flash["notice"] = _("Error saving log entry")
      render :edit
    end
  end

  def destroy
    if can_delete_log?(@log)
      @log.destroy
      flash[:notice] = _("Log entry deleted...")
    else
      flash[:notice] = _("You don't have access to that log...")
    end

    redirect_to '/tasks/list'
  end

  def update_work_log
    unless current_user.can_approve_work_logs?
      render :nothing => true
      return false
    end
    log = WorkLog.accessed_by(current_user).find(params[:id])
    log.status= params[:work_log][:status]

    render :text => log.save.to_s
  end

  private
{'fraction_non_alphanumeric': 0.11234745154343144, 'fraction_numerical': 0.0007178750897343862, 'mean_word_length': 2.854771784232365, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '1199377', 'n_tokens_mistral': 925, 'n_tokens_neox': 890, 'n_words': 233}