Commit 456e9347e1962ccfa6b5474d1293c83203082025
Committed by
Leandro Santos
1 parent
9db9c4b8
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Store task tags on database using acts_as_taggable gem
Showing
2 changed files
with
23 additions
and
7 deletions
Show diff stats
app/controllers/my_profile/tasks_controller.rb
... | ... | @@ -41,18 +41,33 @@ class TasksController < MyProfileController |
41 | 41 | |
42 | 42 | def close |
43 | 43 | failed = {} |
44 | + save = false | |
44 | 45 | |
45 | 46 | if params[:tasks] |
46 | 47 | params[:tasks].each do |id, value| |
47 | 48 | decision = value[:decision] |
48 | - if request.post? && VALID_DECISIONS.include?(decision) && id && decision != 'skip' | |
49 | + | |
50 | + if value[:task].is_a?(Hash) && value[:task][:tag_list] | |
51 | + | |
49 | 52 | task = profile.find_in_all_tasks(id) |
50 | - begin | |
51 | - task.update_attributes(value[:task]) | |
52 | - task.send(decision) | |
53 | - rescue Exception => ex | |
54 | - message = "#{task.title} (#{task.requestor ? task.requestor.name : task.author_name})" | |
55 | - failed[ex.message] ? failed[ex.message] << message : failed[ex.message] = [message] | |
53 | + task.tag_list = value[:task][:tag_list] | |
54 | + value[:task].delete('tag_list') | |
55 | + | |
56 | + save = true | |
57 | + end | |
58 | + | |
59 | + if request.post? | |
60 | + if VALID_DECISIONS.include?(decision) && id && decision != 'skip' | |
61 | + task ||= profile.find_in_all_tasks(id) | |
62 | + begin | |
63 | + task.update_attributes(value[:task]) | |
64 | + task.send(decision) | |
65 | + rescue Exception => ex | |
66 | + message = "#{task.title} (#{task.requestor ? task.requestor.name : task.author_name})" | |
67 | + failed[ex.message] ? failed[ex.message] << message : failed[ex.message] = [message] | |
68 | + end | |
69 | + elsif save | |
70 | + task.save! | |
56 | 71 | end |
57 | 72 | end |
58 | 73 | end | ... | ... |