Sha256: 31103b1e06beaf292edc85243db817255b67e210f68efd66bbc4b9d96ad65250

Contents?: true

Size: 1.22 KB

Versions: 41

Compression:

Stored size: 1.22 KB

Contents

class EstimatesController < ApplicationController
  helper :tasks
  
  verify :method => :post, :redirect_to => ''
  
  def create
    @success, flash[:notice] = do_create

    unless @success
      @task.errors.add :estimate, flash[:notice]
      render :file => "public/500.html", :layout => true, :status => 500
      return
    end

    redirect_to :controller => 'periods', :action => :show, :id => @task.root_task.period, :task_id => @task.id
  end
  
  def create_ajax
    @task = Task.find_by_id(params[:id])
    @success, flash[:notice] = do_create
    if @task.finished?
      render :template => '/tasks/finish', :layout => false
    end
  end
  
  private
  
  def do_create
    if params[:id]
      @task = Task.find(params[:id])
      if params[:estimate] && params[:estimate][:todo]
        begin
          Float(params[:estimate][:todo])
          @task.estimate(params[:estimate][:todo])
          @period = @task.period
          return true, 'Estimate updated'
          rescue ArgumentError => e
          return false, "Estimate was not numeric"
        end
      else
        return false, "Estimate is missing."
      end
    else
      @estimate = Estimate.new
      return false, 'Task id is missing.'
    end
  end
  
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
backlog-0.36.2 app/controllers/estimates_controller.rb
backlog-0.16.0 app/controllers/estimates_controller.rb
backlog-0.17.0 app/controllers/estimates_controller.rb
backlog-0.17.2 app/controllers/estimates_controller.rb
backlog-0.17.1 app/controllers/estimates_controller.rb
backlog-0.17.4 app/controllers/estimates_controller.rb
backlog-0.17.3 app/controllers/estimates_controller.rb
backlog-0.17.5 app/controllers/estimates_controller.rb
backlog-0.18.0 app/controllers/estimates_controller.rb
backlog-0.17.6 app/controllers/estimates_controller.rb
backlog-0.19.0 app/controllers/estimates_controller.rb
backlog-0.20.0 app/controllers/estimates_controller.rb
backlog-0.20.1 app/controllers/estimates_controller.rb
backlog-0.21.0 app/controllers/estimates_controller.rb
backlog-0.21.1 app/controllers/estimates_controller.rb
backlog-0.21.2 app/controllers/estimates_controller.rb
backlog-0.21.3 app/controllers/estimates_controller.rb
backlog-0.22.1 app/controllers/estimates_controller.rb
backlog-0.22.0 app/controllers/estimates_controller.rb
backlog-0.23.0 app/controllers/estimates_controller.rb