diff options
author | Stan Hu <stanhu@gmail.com> | 2016-06-14 22:01:43 +0000 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2016-06-14 22:01:43 +0000 |
commit | 5ac17fb2fa5b3f3ef8c4bed16f97d402858efe6f (patch) | |
tree | d85c6434cf2cb358356d41dbe7c9d869f03e7e31 /app/services | |
parent | 06784ee782ff8a3212e1c6f1361fc43d36ae44e5 (diff) | |
parent | b22ba26caa233bc6cb56bc0b82f493713f657909 (diff) | |
download | gitlab-ce-5ac17fb2fa5b3f3ef8c4bed16f97d402858efe6f.tar.gz |
Merge branch 'manual-todos-issuable-sidebar' into 'master'
Manually create todo for issuable
## What does this MR do?
Adds a button to the sidebar in issues & merge requests to allow users to manually create a todo item themselves.
## What are the relevant issue numbers?
Closes #15045
## Screenshots (if relevant)
![Screen_Shot_2016-06-07_at_09.52.14](/uploads/00af70244c0589d19f241c3e85f3d63d/Screen_Shot_2016-06-07_at_09.52.14.png)
![Screen_Shot_2016-06-07_at_09.52.06](/uploads/e232b02208613a4a50cff4d1e6f119ff/Screen_Shot_2016-06-07_at_09.52.06.png)
![Screen_Shot_2016-06-07_at_09.51.14](/uploads/f1d36435d49ab882538ae2252bec8086/Screen_Shot_2016-06-07_at_09.51.14.png)
See merge request !4502
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/todo_service.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/services/todo_service.rb b/app/services/todo_service.rb index 8e03ff8ddde..e1f9ea64dc4 100644 --- a/app/services/todo_service.rb +++ b/app/services/todo_service.rb @@ -139,10 +139,16 @@ class TodoService pending_todos(user, attributes).update_all(state: :done) end + # When user marks an issue as todo + def mark_todo(issuable, current_user) + attributes = attributes_for_todo(issuable.project, issuable, current_user, Todo::MARKED) + create_todos(current_user, attributes) + end + private def create_todos(users, attributes) - Array(users).each do |user| + Array(users).map do |user| next if pending_todos(user, attributes).exists? Todo.create(attributes.merge(user_id: user.id)) end |