summaryrefslogtreecommitdiff
path: root/app/controllers/projects/todos_controller.rb
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-06-16 13:04:00 +0200
committerJames Lopez <james@jameslopez.es>2016-06-16 13:04:00 +0200
commit778d72664f386dfee45dab171f137395739958f6 (patch)
tree7f2c902f4b97ac29aa97e96e877da201130a33b3 /app/controllers/projects/todos_controller.rb
parent452c076a34cc11cc97f4b1c3113e86ce4367e055 (diff)
parentc369cc8bf42a680b2b0fc9721a9a7926dc5426f6 (diff)
downloadgitlab-ce-feature/project-export.tar.gz
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into feature/project-exportfeature/project-export
# Conflicts: # app/models/ci/pipeline.rb
Diffstat (limited to 'app/controllers/projects/todos_controller.rb')
-rw-r--r--app/controllers/projects/todos_controller.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/app/controllers/projects/todos_controller.rb b/app/controllers/projects/todos_controller.rb
new file mode 100644
index 00000000000..a51bd5e2b49
--- /dev/null
+++ b/app/controllers/projects/todos_controller.rb
@@ -0,0 +1,31 @@
+class Projects::TodosController < Projects::ApplicationController
+ def create
+ todos = TodoService.new.mark_todo(issuable, current_user)
+
+ render json: {
+ todo: todos,
+ count: current_user.todos.pending.count,
+ }
+ end
+
+ def update
+ current_user.todos.find_by_id(params[:id]).update(state: :done)
+
+ render json: {
+ count: current_user.todos.pending.count,
+ }
+ end
+
+ private
+
+ def issuable
+ @issuable ||= begin
+ case params[:issuable_type]
+ when "issue"
+ @project.issues.find(params[:issuable_id])
+ when "merge_request"
+ @project.merge_requests.find(params[:issuable_id])
+ end
+ end
+ end
+end