Class: BacklogsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/backlogs_controller.rb

Constant Summary

Constants included from Localization

Localization::LOCALIZED_STRINGS

Instance Method Summary collapse

Methods inherited from ApplicationController

in_place_edit_for

Methods included from ApplicationHelper

#back_or_link_to, #detour_to, #h, #image_button_to, #image_detour_to, #image_link_to, #t, #with_detour

Methods included from Localization

#l, load_localized_strings, #valid_language?

Instance Method Details

#burn_down_chartObject



90
91
92
# File 'app/controllers/backlogs_controller.rb', line 90

def burn_down_chart
  send_burn_down_chart 640
end

#burn_down_chart_thumbnailObject



86
87
88
# File 'app/controllers/backlogs_controller.rb', line 86

def burn_down_chart_thumbnail
  send_burn_down_chart 270
end

#createObject



47
48
49
50
51
52
53
54
55
# File 'app/controllers/backlogs_controller.rb', line 47

def create
  @backlog = Backlog.new(params[:backlog])
  if @backlog.save
    flash[:notice] = 'Backlog was successfully created.'
    redirect_to :action => :show, :id => @backlog
  else
    render :action => 'new'
  end
end

#destroyObject



80
81
82
83
84
# File 'app/controllers/backlogs_controller.rb', line 80

def destroy
  Backlog.find(params[:id]).destroy
  flash[:notice] = 'Backlog was successfully deleted.'
  redirect_to :action => 'index'
end

#editObject



57
58
59
60
61
62
63
# File 'app/controllers/backlogs_controller.rb', line 57

def edit
  @backlog = Backlog.find(params[:id])
  unplanned_tasks = @backlog.tasks.select {|t| t.period.nil? && t.finished_at.nil?}.sort_by {|t| t.position}
  planned_tasks = @backlog.tasks.select {|t| t.period && t.finished_at.nil?}.sort_by {|t| [t.period.end_on, t.position]}
  @tasks = planned_tasks + unplanned_tasks
  @completed_tasks = @backlog.tasks.select {|t| t.finished_at}.sort {|t1, t2| t2.finished_at <=> t1.finished_at}
end

#edit_no_layoutObject



65
66
67
68
# File 'app/controllers/backlogs_controller.rb', line 65

def edit_no_layout
  edit
  render :partial => 'tasks'
end

#indexObject



8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/backlogs_controller.rb', line 8

def index
  if Task.find_started.size > 0
    redirect_to :controller => 'tasks', :action => :list_started
    return
  end
  if Backlog.count == 0
    redirect_to :action => :new
    return
  end
  redirect_to :controller => 'periods', :action => :index
end

#listObject



20
21
22
# File 'app/controllers/backlogs_controller.rb', line 20

def list
  @backlogs = Backlog.find(:all, :order => 'name')
end

#newObject



43
44
45
# File 'app/controllers/backlogs_controller.rb', line 43

def new
  @backlog = Backlog.new
end

#showObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/backlogs_controller.rb', line 24

def show
  if params[:id]
    @backlog = Backlog.find(params[:id])
  end
  unless @backlog
    @backlog = Backlog.find(:first)
    unless @backlog
      redirect_to :controller => 'backlogs', :action => :new
      return
    end
  end
  @period = @backlog.first_active_period
  unless @period
    redirect_to :controller => 'periods', :action => :new, :backlog_id => @backlog.id
    return
  end
  redirect_to :controller => 'periods', :action => :show, :id => @period
end

#updateObject



70
71
72
73
74
75
76
77
78
# File 'app/controllers/backlogs_controller.rb', line 70

def update
  @backlog = Backlog.find(params[:id])
  if @backlog.update_attributes(params[:backlog])
    flash[:notice] = 'Backlog was successfully updated.'
    redirect_to :action => 'show', :id => @backlog
  else
    render :action => 'edit'
  end
end