Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
OHR Support
Manage
Activity
Members
Labels
Plan
Issues
97
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Projects
OHR Support
Commits
477a5f37
Commit
477a5f37
authored
13 years ago
by
Eric Davis
Browse files
Options
Downloads
Patches
Plain Diff
Refactor: replace comment with extracted utility method
parent
c62e16b6
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/controllers/projects_controller.rb
+10
-6
10 additions, 6 deletions
app/controllers/projects_controller.rb
with
10 additions
and
6 deletions
app/controllers/projects_controller.rb
+
10
−
6
View file @
477a5f37
...
...
@@ -70,12 +70,7 @@ class ProjectsController < ApplicationController
if
validate_parent_id
&&
@project
.
save
@project
.
set_allowed_parent!
(
params
[
:project
][
'parent_id'
])
if
params
[
:project
].
has_key?
(
'parent_id'
)
# Add current user as a project member if he is not admin
unless
User
.
current
.
admin?
r
=
Role
.
givable
.
find_by_id
(
Setting
.
new_project_user_role_id
.
to_i
)
||
Role
.
givable
.
first
m
=
Member
.
new
(
:user
=>
User
.
current
,
:roles
=>
[
r
])
@project
.
members
<<
m
end
add_current_user_to_project_if_not_admin
(
@project
)
respond_to
do
|
format
|
format
.
html
{
flash
[
:notice
]
=
l
(
:notice_successful_create
)
...
...
@@ -265,4 +260,13 @@ private
def
hide_project_in_layout
@project
=
nil
end
def
add_current_user_to_project_if_not_admin
(
project
)
unless
User
.
current
.
admin?
r
=
Role
.
givable
.
find_by_id
(
Setting
.
new_project_user_role_id
.
to_i
)
||
Role
.
givable
.
first
m
=
Member
.
new
(
:user
=>
User
.
current
,
:roles
=>
[
r
])
project
.
members
<<
m
end
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment