Commit a5b5066efab7d7c62093b3b346b002b8d48b497d
1 parent
ce1c8afe
Exists in
staging
and in
4 other branches
Store task tags on database using acts_as_taggable gem
Showing
2 changed files
with
24 additions
and
8 deletions
Show diff stats
app/controllers/my_profile/tasks_controller.rb
1 | 1 | class TasksController < MyProfileController |
2 | 2 | |
3 | 3 | protect 'perform_task', :profile |
4 | - | |
4 | + | |
5 | 5 | def index |
6 | 6 | @filter = params[:filter_type].blank? ? nil : params[:filter_type] |
7 | 7 | @task_types = Task.pending_types_for(profile) |
... | ... | @@ -17,18 +17,33 @@ class TasksController < MyProfileController |
17 | 17 | |
18 | 18 | def close |
19 | 19 | failed = {} |
20 | + save = false | |
20 | 21 | |
21 | 22 | if params[:tasks] |
22 | 23 | params[:tasks].each do |id, value| |
23 | 24 | decision = value[:decision] |
24 | - if request.post? && VALID_DECISIONS.include?(decision) && id && decision != 'skip' | |
25 | + | |
26 | + if value[:task].is_a?(Hash) && value[:task][:tag_list] | |
27 | + | |
25 | 28 | task = profile.find_in_all_tasks(id) |
26 | - begin | |
27 | - task.update_attributes(value[:task]) | |
28 | - task.send(decision) | |
29 | - rescue Exception => ex | |
30 | - message = "#{task.title} (#{task.requestor ? task.requestor.name : task.author_name})" | |
31 | - failed[ex.message] ? failed[ex.message] << message : failed[ex.message] = [message] | |
29 | + task.tag_list = value[:task][:tag_list] | |
30 | + value[:task].delete('tag_list') | |
31 | + | |
32 | + save = true | |
33 | + end | |
34 | + | |
35 | + if request.post? | |
36 | + if VALID_DECISIONS.include?(decision) && id && decision != 'skip' | |
37 | + task ||= profile.find_in_all_tasks(id) | |
38 | + begin | |
39 | + task.update_attributes(value[:task]) | |
40 | + task.send(decision) | |
41 | + rescue Exception => ex | |
42 | + message = "#{task.title} (#{task.requestor ? task.requestor.name : task.author_name})" | |
43 | + failed[ex.message] ? failed[ex.message] << message : failed[ex.message] = [message] | |
44 | + end | |
45 | + elsif save | |
46 | + task.save! | |
32 | 47 | end |
33 | 48 | end |
34 | 49 | end | ... | ... |