debian-mirror-gitlab/app/controllers/projects/todos_controller.rb

26 lines
694 B
Ruby
Raw Normal View History

class Projects::TodosController < Projects::ApplicationController
2016-06-22 15:30:34 +05:30
before_action :authenticate_user!, only: [:create]
2016-06-22 15:30:34 +05:30
def create
todo = TodoService.new.mark_todo(issuable, current_user)
render json: {
2016-08-24 12:49:21 +05:30
count: TodosFinder.new(current_user, state: :pending).execute.count,
2016-06-22 15:30:34 +05:30
delete_path: dashboard_todo_path(todo)
}
end
private
def issuable
@issuable ||= begin
case params[:issuable_type]
when "issue"
2017-01-15 13:20:01 +05:30
IssuesFinder.new(current_user, project_id: @project.id).find(params[:issuable_id])
when "merge_request"
2017-01-15 13:20:01 +05:30
MergeRequestsFinder.new(current_user, project_id: @project.id).find(params[:issuable_id])
end
end
end
end