<commit_before>class TasksController < ApplicationController
  before_filter :load_task, :except => [:new, :create]
  before_filter :load_task_list, :only => [:new, :create]
  before_filter :set_page_title
  
  rescue_from CanCan::AccessDenied do |exception|
    handle_cancan_error(exception)
  end

  def show
    respond_to do |f|
      f.any(:html, :m)
      f.js {
        @show_part = params[:part]
        render :template => 'tasks/reload'
      }
      f.xml  { render :xml     => @task.to_xml }
      f.json { render :as_json => @task.to_xml }
      f.yaml { render :as_yaml => @task.to_xml }
    end
  end

  def new
    authorize! :make_tasks, @current_project
    @task = @task_list.tasks.new
    
    respond_to do |f|
      f.any(:html, :m)
    end
  end

  def create
    authorize! :make_tasks, @current_project
    @task = @task_list.tasks.create_by_user(current_user, params[:task])
    
    respond_to do |f|
      f.any(:html, :m) {
        if request.xhr?
          if @task.new_record?
            output_errors_json(@task)
          else
            render :partial => 'tasks/task', :locals => {
              :project => @current_project,
              :task_list => @task_list,
              :task => @task.reload,
              :editable => true
            }
          end
        else
          if @task.new_record?
            render :new
          else
            redirect_to_task
          end
        end
      }
    end
  end

  def edit
    authorize! :update, @task
    respond_to do |f|
      f.any(:html, :m)
      f.js { render :layout => false }
    end
  end

  def update
    if can? :update, @task
      can? :update, @task
      @task.updating_user = current_user
      success = @task.update_attributes params[:task]
    elsif can? :comment, @task
      success = @task.update_attributes(:comments_attributes => params['task']['comments_attributes'])
    else
      authorize! :comment, @task
    end

    respond_to do |f|
      f.any(:html, :m) {
        if request.xhr? or iframe?
          if @task.comment_created?
            comment = @task.comments(true).first<commit_msg>fix comment authoring when a Commenter comments<commit_after>class TasksController < ApplicationController
  before_filter :load_task, :except => [:new, :create]
  before_filter :load_task_list, :only => [:new, :create]
  before_filter :set_page_title
  
  rescue_from CanCan::AccessDenied do |exception|
    handle_cancan_error(exception)
  end

  def show
    respond_to do |f|
      f.any(:html, :m)
      f.js {
        @show_part = params[:part]
        render :template => 'tasks/reload'
      }
      f.xml  { render :xml     => @task.to_xml }
      f.json { render :as_json => @task.to_xml }
      f.yaml { render :as_yaml => @task.to_xml }
    end
  end

  def new
    authorize! :make_tasks, @current_project
    @task = @task_list.tasks.new
    
    respond_to do |f|
      f.any(:html, :m)
    end
  end

  def create
    authorize! :make_tasks, @current_project
    @task = @task_list.tasks.create_by_user(current_user, params[:task])
    
    respond_to do |f|
      f.any(:html, :m) {
        if request.xhr?
          if @task.new_record?
            output_errors_json(@task)
          else
            render :partial => 'tasks/task', :locals => {
              :project => @current_project,
              :task_list => @task_list,
              :task => @task.reload,
              :editable => true
            }
          end
        else
          if @task.new_record?
            render :new
          else
            redirect_to_task
          end
        end
      }
    end
  end

  def edit
    authorize! :update, @task
    respond_to do |f|
      f.any(:html, :m)
      f.js { render :layout => false }
    end
  end

  def update
    if can? :update, @task
      can? :update, @task
      @task.updating_user = current_user
      success = @task.update_attributes params[:task]
    elsif can? :comment, @task
      @task.updating_user = current_user
      success = @task.update_attributes(:comments_attributes => params['task']['comments_attributes'])
    else
      authorize! :comment, @task
    end

    respond_to do |f|
      f.any(:html, :m) {
        if request.xhr? or iframe?
          if @task.comment_created?
            comment = @task.comments(true).first
{'fraction_non_alphanumeric': 0.1125491102380402, 'fraction_numerical': 0.0, 'mean_word_length': 2.0457424349049966, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, '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': '5697379', 'n_tokens_mistral': 1408, 'n_tokens_neox': 1395, 'n_words': 327}