diff --git a/app/controllers/my_profile/tasks_controller.rb b/app/controllers/my_profile/tasks_controller.rb index 9e3c268..bef6759 100644 --- a/app/controllers/my_profile/tasks_controller.rb +++ b/app/controllers/my_profile/tasks_controller.rb @@ -1,7 +1,7 @@ class TasksController < MyProfileController protect 'perform_task', :profile - + def index @filter = params[:filter_type].blank? ? nil : params[:filter_type] @task_types = Task.pending_types_for(profile) @@ -17,18 +17,33 @@ class TasksController < MyProfileController def close failed = {} + save = false if params[:tasks] params[:tasks].each do |id, value| decision = value[:decision] - if request.post? && VALID_DECISIONS.include?(decision) && id && decision != 'skip' + + if value[:task].is_a?(Hash) && value[:task][:tag_list] + task = profile.find_in_all_tasks(id) - begin - task.update_attributes(value[:task]) - task.send(decision) - rescue Exception => ex - message = "#{task.title} (#{task.requestor ? task.requestor.name : task.author_name})" - failed[ex.message] ? failed[ex.message] << message : failed[ex.message] = [message] + task.tag_list = value[:task][:tag_list] + value[:task].delete('tag_list') + + save = true + end + + if request.post? + if VALID_DECISIONS.include?(decision) && id && decision != 'skip' + task ||= profile.find_in_all_tasks(id) + begin + task.update_attributes(value[:task]) + task.send(decision) + rescue Exception => ex + message = "#{task.title} (#{task.requestor ? task.requestor.name : task.author_name})" + failed[ex.message] ? failed[ex.message] << message : failed[ex.message] = [message] + end + elsif save + task.save! end end end diff --git a/app/models/task.rb b/app/models/task.rb index 0620e84..f4d497f 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -12,6 +12,7 @@ class Task < ActiveRecord::Base acts_as_having_settings :field => :data + acts_as_ordered_taggable module Status # the status of tasks just created -- libgit2 0.21.2