Class: WorkAccountsController
Constant Summary
Localization::LOCALIZED_STRINGS
Instance Method Summary
collapse
in_place_edit_for, #initialize
#back_or_link_to, #detour?, #detour_to, #display_notice, #h, #image_button_to, #image_detour_to, #image_link_to, #image_link_to_remote, #insert, #record, #resolution_image, #t, #update_task, #with_detour
#l, load_localized_strings, #valid_language?
Instance Method Details
#create ⇒ Object
29
30
31
32
33
34
35
36
37
|
# File 'app/controllers/work_accounts_controller.rb', line 29
def create
@work_account = WorkAccount.new(params[:work_account])
if @work_account.save
flash[:notice] = 'WorkAccount was successfully created.'
redirect_to :action => 'list'
else
render :action => 'new'
end
end
|
#destroy ⇒ Object
53
54
55
56
|
# File 'app/controllers/work_accounts_controller.rb', line 53
def destroy
WorkAccount.find(params[:id]).destroy
redirect_to :action => 'list'
end
|
#edit ⇒ Object
39
40
41
|
# File 'app/controllers/work_accounts_controller.rb', line 39
def edit
@work_account = WorkAccount.find(params[:id])
end
|
#index ⇒ Object
2
3
4
5
|
# File 'app/controllers/work_accounts_controller.rb', line 2
def index
list
render :action => 'list'
end
|
#list ⇒ Object
11
12
13
|
# File 'app/controllers/work_accounts_controller.rb', line 11
def list
@work_accounts = WorkAccount.paginate :page => params[:page], :order => 'name'
end
|
#new ⇒ Object
25
26
27
|
# File 'app/controllers/work_accounts_controller.rb', line 25
def new
@work_account = WorkAccount.new
end
|
#show ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'app/controllers/work_accounts_controller.rb', line 15
def show
@work_account = WorkAccount.find(params[:id])
works = @work_account.works.select{|w|w.user_id == current_user.id}
@backlog_totals = works.to_summarized_hash {|work| [work.task && work.task.backlog, work.hours]}
@task_totals = works.to_summarized_hash {|work| [work.task, work.hours]}
@task_totals_per_backlog = @task_totals.to_a.to_grouped_hash {|task, hours| [task && task.backlog, [task, hours]]}
@total_hours = works.inject(BigDecimal('0')) {|total, work| total += work.hours}
@works_without_backlog = works.select {|w| w.task_id.nil?}
end
|
#update ⇒ Object
43
44
45
46
47
48
49
50
51
|
# File 'app/controllers/work_accounts_controller.rb', line 43
def update
@work_account = WorkAccount.find(params[:id])
if @work_account.update_attributes(params[:work_account])
flash[:notice] = 'WorkAccount was successfully updated.'
back_or_redirect_to :action => 'show', :id => @work_account
else
render :action => 'edit'
end
end
|