summaryrefslogtreecommitdiff
path: root/app/controllers/dashboard
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-02-15 17:49:28 -0200
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-02-20 12:10:26 -0200
commit77d7910b8b4497dc52a80f8a35b765c978d547a4 (patch)
tree1830a4bfd7f99dcc6f640a1d105717359d956797 /app/controllers/dashboard
parentc8f2d18abde050c3b6d15ee32c99495c77b2a222 (diff)
downloadgitlab-ce-77d7910b8b4497dc52a80f8a35b765c978d547a4.tar.gz
Allow user to mark each task as done manually
Diffstat (limited to 'app/controllers/dashboard')
-rw-r--r--app/controllers/dashboard/tasks_controller.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/app/controllers/dashboard/tasks_controller.rb b/app/controllers/dashboard/tasks_controller.rb
index 66d891e3dfa..1102745067f 100644
--- a/app/controllers/dashboard/tasks_controller.rb
+++ b/app/controllers/dashboard/tasks_controller.rb
@@ -1,4 +1,6 @@
class Dashboard::TasksController < Dashboard::ApplicationController
+ before_action :authorize_destroy_task!, only: [:destroy]
+
def index
@tasks = case params[:state]
when 'done'
@@ -12,4 +14,25 @@ class Dashboard::TasksController < Dashboard::ApplicationController
@pending_count = current_user.tasks.pending.count
@done_count = current_user.tasks.done.count
end
+
+ def destroy
+ task.done!
+
+ respond_to do |format|
+ format.html { redirect_to dashboard_tasks_path, notice: 'Task was successfully marked as done.' }
+ format.js { render nothing: true }
+ end
+ end
+
+ private
+
+ def authorize_destroy_task!
+ unless can?(current_user, :destroy_task, task)
+ return render_404
+ end
+ end
+
+ def task
+ @task ||= current_user.tasks.find(params[:id])
+ end
end