Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
5d428030
Commit
5d428030
authored
Apr 01, 2016
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve code
parent
1ba9a91c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
7 deletions
+15
-7
app/controllers/groups/milestones_controller.rb
app/controllers/groups/milestones_controller.rb
+15
-7
No files found.
app/controllers/groups/milestones_controller.rb
View file @
5d428030
...
...
@@ -21,10 +21,10 @@ class Groups::MilestonesController < Groups::ApplicationController
project_ids
=
params
[
:milestone
][
:project_ids
].
reject
(
&
:blank?
)
title
=
milestone_params
[
:title
]
if
project_ids
.
present?
create_milestones
(
project_ids
,
title
)
if
create_milestones
(
project_ids
,
title
)
redirect_to
milestone_path
(
title
)
else
render_new_with_error
(
"Select a project(s)."
)
render_new_with_error
(
@error
)
end
end
...
...
@@ -42,14 +42,22 @@ class Groups::MilestonesController < Groups::ApplicationController
private
def
create_milestones
(
project_ids
,
title
)
unless
project_ids
.
present?
@error
=
"Please select at least one project."
return
false
end
begin
@projects
.
where
(
id:
project_ids
).
each
do
|
project
|
ActiveRecord
::
Base
.
transaction
{
Milestones
::
CreateService
.
new
(
project
,
current_user
,
milestone_params
).
execute
}
ActiveRecord
::
Base
.
transaction
do
@projects
.
where
(
id:
project_ids
).
each
do
|
project
|
Milestones
::
CreateService
.
new
(
project
,
current_user
,
milestone_params
).
execute
end
end
redirect_to
milestone_path
(
title
)
true
rescue
=>
e
render_new_with_error
(
"Error creating milestones:
#{
e
.
message
}
"
)
@error
=
"Error creating milestone:
#{
e
.
message
}
."
false
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment