Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
OHR Support
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
97
Issues
97
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
OHR Support
Commits
477a5f37
Commit
477a5f37
authored
May 16, 2011
by
Eric Davis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor: replace comment with extracted utility method
parent
c62e16b6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
projects_controller.rb
app/controllers/projects_controller.rb
+10
-6
No files found.
app/controllers/projects_controller.rb
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
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