2016-06-08 04:29:19 -04:00
|
|
|
class Projects::TodosController < Projects::ApplicationController
|
2016-06-17 04:06:00 -04:00
|
|
|
before_action :authenticate_user!, only: [:create]
|
2016-06-08 04:29:19 -04:00
|
|
|
|
2016-06-17 04:01:03 -04:00
|
|
|
def create
|
|
|
|
todo = TodoService.new.mark_todo(issuable, current_user)
|
2016-06-08 04:29:19 -04:00
|
|
|
|
2016-06-09 03:50:18 -04:00
|
|
|
render json: {
|
2016-07-11 02:10:04 -04:00
|
|
|
count: TodosFinder.new(current_user, state: :pending).execute.count,
|
2016-06-17 04:01:03 -04:00
|
|
|
delete_path: dashboard_todo_path(todo)
|
2016-06-09 03:50:18 -04:00
|
|
|
}
|
2016-06-08 04:29:19 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
2016-06-09 03:50:18 -04:00
|
|
|
|
2016-06-08 04:29:19 -04:00
|
|
|
def issuable
|
|
|
|
@issuable ||= begin
|
|
|
|
case params[:issuable_type]
|
|
|
|
when "issue"
|
2016-11-18 08:51:52 -05:00
|
|
|
IssuesFinder.new(current_user, project_id: @project.id).find(params[:issuable_id])
|
2016-06-08 04:29:19 -04:00
|
|
|
when "merge_request"
|
2016-11-29 08:47:43 -05:00
|
|
|
MergeRequestsFinder.new(current_user, project_id: @project.id).find(params[:issuable_id])
|
2016-06-08 04:29:19 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|