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
iv
gitlab-ce
Commits
5ce9f89c
Commit
5ce9f89c
authored
Oct 21, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8102 from cirosantilli/use-memoized-project
Use @project on controllers, don't call method
parents
456de99b
9e1b97ad
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
38 deletions
+41
-38
app/controllers/admin/projects_controller.rb
app/controllers/admin/projects_controller.rb
+2
-2
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+22
-19
app/controllers/projects/commit_controller.rb
app/controllers/projects/commit_controller.rb
+6
-6
app/controllers/projects/deploy_keys_controller.rb
app/controllers/projects/deploy_keys_controller.rb
+1
-1
app/controllers/projects/team_members_controller.rb
app/controllers/projects/team_members_controller.rb
+4
-4
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+6
-6
No files found.
app/controllers/admin/projects_controller.rb
View file @
5ce9f89c
...
@@ -36,10 +36,10 @@ class Admin::ProjectsController < Admin::ApplicationController
...
@@ -36,10 +36,10 @@ class Admin::ProjectsController < Admin::ApplicationController
end
end
def
group
def
group
@group
||=
project
.
group
@group
||=
@
project
.
group
end
end
def
repository
def
repository
@repository
||=
project
.
repository
@repository
||=
@
project
.
repository
end
end
end
end
app/controllers/application_controller.rb
View file @
5ce9f89c
...
@@ -81,6 +81,7 @@ class ApplicationController < ActionController::Base
...
@@ -81,6 +81,7 @@ class ApplicationController < ActionController::Base
end
end
def
project
def
project
unless
@project
id
=
params
[
:project_id
]
||
params
[
:id
]
id
=
params
[
:project_id
]
||
params
[
:id
]
# Redirect from
# Redirect from
...
@@ -104,6 +105,8 @@ class ApplicationController < ActionController::Base
...
@@ -104,6 +105,8 @@ class ApplicationController < ActionController::Base
render_404
and
return
render_404
and
return
end
end
end
end
@project
end
def
repository
def
repository
@repository
||=
project
.
repository
@repository
||=
project
.
repository
...
...
app/controllers/projects/commit_controller.rb
View file @
5ce9f89c
...
@@ -11,12 +11,12 @@ class Projects::CommitController < Projects::ApplicationController
...
@@ -11,12 +11,12 @@ class Projects::CommitController < Projects::ApplicationController
def
show
def
show
return
git_not_found!
unless
@commit
return
git_not_found!
unless
@commit
@line_notes
=
project
.
notes
.
for_commit_id
(
commit
.
id
).
inline
@line_notes
=
@
project
.
notes
.
for_commit_id
(
commit
.
id
).
inline
@branches
=
project
.
repository
.
branch_names_contains
(
commit
.
id
)
@branches
=
@
project
.
repository
.
branch_names_contains
(
commit
.
id
)
@diffs
=
@commit
.
diffs
@diffs
=
@commit
.
diffs
@note
=
project
.
build_commit_note
(
commit
)
@note
=
@
project
.
build_commit_note
(
commit
)
@notes_count
=
project
.
notes
.
for_commit_id
(
commit
.
id
).
count
@notes_count
=
@
project
.
notes
.
for_commit_id
(
commit
.
id
).
count
@notes
=
project
.
notes
.
for_commit_id
(
@commit
.
id
).
not_inline
.
fresh
@notes
=
@
project
.
notes
.
for_commit_id
(
@commit
.
id
).
not_inline
.
fresh
@noteable
=
@commit
@noteable
=
@commit
@comments_allowed
=
@reply_allowed
=
true
@comments_allowed
=
@reply_allowed
=
true
@comments_target
=
{
@comments_target
=
{
...
@@ -32,6 +32,6 @@ class Projects::CommitController < Projects::ApplicationController
...
@@ -32,6 +32,6 @@ class Projects::CommitController < Projects::ApplicationController
end
end
def
commit
def
commit
@commit
||=
project
.
repository
.
commit
(
params
[
:id
])
@commit
||=
@
project
.
repository
.
commit
(
params
[
:id
])
end
end
end
end
app/controllers/projects/deploy_keys_controller.rb
View file @
5ce9f89c
...
@@ -42,7 +42,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
...
@@ -42,7 +42,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
end
end
def
enable
def
enable
project
.
deploy_keys
<<
available_keys
.
find
(
params
[
:id
])
@
project
.
deploy_keys
<<
available_keys
.
find
(
params
[
:id
])
redirect_to
project_deploy_keys_path
(
@project
)
redirect_to
project_deploy_keys_path
(
@project
)
end
end
...
...
app/controllers/projects/team_members_controller.rb
View file @
5ce9f89c
...
@@ -10,7 +10,7 @@ class Projects::TeamMembersController < Projects::ApplicationController
...
@@ -10,7 +10,7 @@ class Projects::TeamMembersController < Projects::ApplicationController
end
end
def
new
def
new
@user_project_relation
=
project
.
project_members
.
new
@user_project_relation
=
@
project
.
project_members
.
new
end
end
def
create
def
create
...
@@ -26,7 +26,7 @@ class Projects::TeamMembersController < Projects::ApplicationController
...
@@ -26,7 +26,7 @@ class Projects::TeamMembersController < Projects::ApplicationController
end
end
def
update
def
update
@user_project_relation
=
project
.
project_members
.
find_by
(
user_id:
member
)
@user_project_relation
=
@
project
.
project_members
.
find_by
(
user_id:
member
)
@user_project_relation
.
update_attributes
(
member_params
)
@user_project_relation
.
update_attributes
(
member_params
)
unless
@user_project_relation
.
valid?
unless
@user_project_relation
.
valid?
...
@@ -36,7 +36,7 @@ class Projects::TeamMembersController < Projects::ApplicationController
...
@@ -36,7 +36,7 @@ class Projects::TeamMembersController < Projects::ApplicationController
end
end
def
destroy
def
destroy
@user_project_relation
=
project
.
project_members
.
find_by
(
user_id:
member
)
@user_project_relation
=
@
project
.
project_members
.
find_by
(
user_id:
member
)
@user_project_relation
.
destroy
@user_project_relation
.
destroy
respond_to
do
|
format
|
respond_to
do
|
format
|
...
@@ -46,7 +46,7 @@ class Projects::TeamMembersController < Projects::ApplicationController
...
@@ -46,7 +46,7 @@ class Projects::TeamMembersController < Projects::ApplicationController
end
end
def
leave
def
leave
project
.
project_members
.
find_by
(
user_id:
current_user
).
destroy
@
project
.
project_members
.
find_by
(
user_id:
current_user
).
destroy
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
{
redirect_to
:back
}
format
.
html
{
redirect_to
:back
}
...
...
app/controllers/projects_controller.rb
View file @
5ce9f89c
...
@@ -76,7 +76,7 @@ class ProjectsController < ApplicationController
...
@@ -76,7 +76,7 @@ class ProjectsController < ApplicationController
end
end
def
import
def
import
if
project
.
import_finished?
if
@
project
.
import_finished?
redirect_to
@project
redirect_to
@project
return
return
end
end
...
@@ -98,7 +98,7 @@ class ProjectsController < ApplicationController
...
@@ -98,7 +98,7 @@ class ProjectsController < ApplicationController
end
end
def
destroy
def
destroy
return
access_denied!
unless
can?
(
current_user
,
:remove_project
,
project
)
return
access_denied!
unless
can?
(
current_user
,
:remove_project
,
@
project
)
::
Projects
::
DestroyService
.
new
(
@project
,
current_user
,
{}).
execute
::
Projects
::
DestroyService
.
new
(
@project
,
current_user
,
{}).
execute
...
@@ -148,8 +148,8 @@ class ProjectsController < ApplicationController
...
@@ -148,8 +148,8 @@ class ProjectsController < ApplicationController
end
end
def
archive
def
archive
return
access_denied!
unless
can?
(
current_user
,
:archive_project
,
project
)
return
access_denied!
unless
can?
(
current_user
,
:archive_project
,
@
project
)
project
.
archive!
@
project
.
archive!
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
{
redirect_to
@project
}
format
.
html
{
redirect_to
@project
}
...
@@ -157,8 +157,8 @@ class ProjectsController < ApplicationController
...
@@ -157,8 +157,8 @@ class ProjectsController < ApplicationController
end
end
def
unarchive
def
unarchive
return
access_denied!
unless
can?
(
current_user
,
:archive_project
,
project
)
return
access_denied!
unless
can?
(
current_user
,
:archive_project
,
@
project
)
project
.
unarchive!
@
project
.
unarchive!
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
{
redirect_to
@project
}
format
.
html
{
redirect_to
@project
}
...
...
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