Class: PeriodsController
Constant Summary
Localization::LOCALIZED_STRINGS
Instance Method Summary
collapse
in_place_edit_for
#l, load_localized_strings, #valid_language?
Instance Method Details
#burn_down_chart ⇒ Object
88
89
90
|
# File 'app/controllers/periods_controller.rb', line 88
def burn_down_chart
send_burn_down_chart 640
end
|
#burn_down_chart_large ⇒ Object
92
93
94
|
# File 'app/controllers/periods_controller.rb', line 92
def burn_down_chart_large
send_burn_down_chart '1440x900'
end
|
#burn_down_chart_thumbnail ⇒ Object
84
85
86
|
# File 'app/controllers/periods_controller.rb', line 84
def burn_down_chart_thumbnail
send_burn_down_chart 270
end
|
#create ⇒ Object
53
54
55
56
57
58
59
60
61
62
|
# File 'app/controllers/periods_controller.rb', line 53
def create
@period = Period.new(params[:period])
if @period.save
@period.reload
flash[:notice] = 'Period was successfully created.'
back_or_redirect_to :action => 'show', :id => @period.higher_item ? @period.higher_item : @period
else
render :action => 'new'
end
end
|
#destroy ⇒ Object
78
79
80
81
82
|
# File 'app/controllers/periods_controller.rb', line 78
def destroy
Period.find(params[:id]).destroy
flash[:notice] = 'Period was successfully deleted.'
redirect_to :action => 'index'
end
|
#edit ⇒ Object
64
65
66
|
# File 'app/controllers/periods_controller.rb', line 64
def edit
@period = Period.find(params[:id])
end
|
#index ⇒ Object
5
6
7
8
9
|
# File 'app/controllers/periods_controller.rb', line 5
def index
periods = Period.find(:all).select {|period| period.active?(true)}
most_urgent_period = periods.sort_by {|p| p.required_speed}.last
redirect_to :action => 'show', :id => most_urgent_period
end
|
#list_work ⇒ Object
96
97
98
99
100
|
# File 'app/controllers/periods_controller.rb', line 96
def list_work
@period = Period.find(params[:id])
@works = Work.find_by_sql("SELECT w.* FROM works w LEFT OUTER JOIN tasks t ON t.id = w.task_id WHERE t.period_id = #{@period.id} ORDER BY w.completed_at")
render :template => '/works/list'
end
|
#new ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'app/controllers/periods_controller.rb', line 38
def new
@period = Period.new
if params[:period] && params[:period][:party_id]
@period.party_id = params[:period][:party_id]
previous = @period.party.periods.last
if previous
@period.start_on = previous.end_on + 1
@period.end_on = previous.end_on + (1 + (previous.end_on - previous.start_on))
else
@period.start_on = Date.today
end
end
@parties = Party.find(:all)
end
|
#show ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'app/controllers/periods_controller.rb', line 14
def show
if params[:task_id]
@selected_task = Task.find(params[:task_id])
end
if @selected_task
@period = @selected_task.period
elsif params[:id] && @period = Period.find_by_id(params[:id])
elsif @period = Period.find(:first)
else
redirect_to :action => :new
return
end
if @selected_task.nil?
@selected_task = Task.find(:first, :conditions => "position = 1 AND period_id = #{@period.id}")
end
@tasks = @period.open_tasks
@completed_tasks = @period.completed_tasks.reverse
end
|
#show_nolayout ⇒ Object
33
34
35
36
|
# File 'app/controllers/periods_controller.rb', line 33
def show_nolayout
show
render :partial => 'show_active', :layout => false, :locals => {:i => 0}
end
|
#update ⇒ Object
68
69
70
71
72
73
74
75
76
|
# File 'app/controllers/periods_controller.rb', line 68
def update
@period = Period.find(params[:id])
if @period.update_attributes(params[:period])
flash[:notice] = 'Period was successfully updated.'
redirect_to :action => 'show', :id => @period
else
render :action => 'edit'
end
end
|