tasks_controller.rb
1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
class TasksController < MyProfileController
protect 'perform_task', :profile
def index
@tasks = profile.tasks.pending
end
def processed
@tasks = profile.tasks.finished
end
VALID_DECISIONS = [ 'finish', 'cancel' ]
def close
decision = params[:decision]
if request.post? && VALID_DECISIONS.include?(decision) && params[:id]
task = profile.tasks.find(params[:id])
task.update_attributes!(params[:task])
task.send(decision)
end
redirect_to :action => 'index'
end
def new
@ticket = Ticket.new(params[:ticket])
if params[:target_id]
@ticket.target = profile.friends.find(params[:target_id])
end
@ticket.requestor = profile
if request.post?
if @ticket.save
redirect_to :action => 'index'
end
end
end
def list_requested
@tasks = Task.find_all_by_requestor_id(profile.id)
end
def ticket_details
@ticket = Ticket.find(:first, :conditions => ['(requestor_id = ? or target_id = ?) and id = ?', profile.id, profile.id, params[:id]])
end
end