Sha256: f108a277dcd571de21ee09a009ee915e90d37e62b23777718c90c01710c9b90d

Contents?: true

Size: 827 Bytes

Versions: 1

Compression:

Stored size: 827 Bytes

Contents

class TasksController < ApplicationController
  before_filter :find_task
  
  attr_reader :task
  
  def update
    authorize! :update, task
    
    project = task.project
    effort = params[:effort]
    effort = effort.to_d if effort
    effort = nil if effort && effort <= 0
    task.updated_by = current_user
    task.update_attributes effort: effort
    render json: [], status: :ok
  end
  
  def complete
    authorize! :update, task
    
    # !todo: authorize completing a task
    task.complete! unless task.completed?
    render json: TaskPresenter.new(task)
  end
  
  def reopen
    authorize! :update, task
    
    # !todo: authorize completing a task
    task.reopen! unless task.open?
    render json: TaskPresenter.new(task)
  end
  
private
  
  def find_task
    @task = Task.find params[:id]
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
houston-core-0.5.0.beta1 app/controllers/tasks_controller.rb