Class: PeriodsController
Constant Summary
Localization::LOCALIZED_STRINGS
Instance Method Summary
collapse
in_place_edit_for
#back_or_link_to, #detour_to, #h, #image_button_to, #image_detour_to, #image_link_to, #t, #with_detour
#l, load_localized_strings, #valid_language?
Instance Method Details
#burn_down_chart ⇒ Object
93
94
95
|
# File 'app/controllers/periods_controller.rb', line 93
def burn_down_chart
send_burn_down_chart 640
end
|
#burn_down_chart_large ⇒ Object
97
98
99
|
# File 'app/controllers/periods_controller.rb', line 97
def burn_down_chart_large
send_burn_down_chart '1440x900'
end
|
#burn_down_chart_thumbnail ⇒ Object
89
90
91
|
# File 'app/controllers/periods_controller.rb', line 89
def burn_down_chart_thumbnail
send_burn_down_chart 270
end
|
#create ⇒ Object
58
59
60
61
62
63
64
65
66
67
|
# File 'app/controllers/periods_controller.rb', line 58
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
83
84
85
86
87
|
# File 'app/controllers/periods_controller.rb', line 83
def destroy
Period.find(params[:id]).destroy
flash[:notice] = 'Period was successfully deleted.'
redirect_to :action => 'index'
end
|
#edit ⇒ Object
69
70
71
|
# File 'app/controllers/periods_controller.rb', line 69
def edit
@period = Period.find(params[:id])
end
|
#index ⇒ Object
5
6
7
8
9
10
11
12
13
14
|
# File 'app/controllers/periods_controller.rb', line 5
def index
active_periods = Period.find(:all).select {|period| period.active?(true)}
my_active_periods = active_periods.select {|period| period.party.includes?(current_user)}
unless my_active_periods.empty?
most_urgent_period = my_active_periods.sort_by {|p| p.required_speed}.last
else
most_urgent_period = active_periods.sort_by {|p| p.required_speed}.last
end
redirect_to :action => 'show', :id => most_urgent_period
end
|
#list_work ⇒ Object
101
102
103
104
105
|
# File 'app/controllers/periods_controller.rb', line 101
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'app/controllers/periods_controller.rb', line 43
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
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'app/controllers/periods_controller.rb', line 19
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_no_layout ⇒ Object
38
39
40
41
|
# File 'app/controllers/periods_controller.rb', line 38
def show_no_layout
show
render :partial => 'show_active', :layout => false, :locals => {:i => 0}
end
|
#update ⇒ Object
73
74
75
76
77
78
79
80
81
|
# File 'app/controllers/periods_controller.rb', line 73
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
|