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
Jérome Perrin
gitlab-ce
Commits
078a8f0e
Commit
078a8f0e
authored
Sep 26, 2012
by
Cyril
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
factorize before_filters and layout for projects related controllers
parent
0439387b
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
33 additions
and
101 deletions
+33
-101
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+1
-1
app/controllers/commits_controller.rb
app/controllers/commits_controller.rb
+1
-5
app/controllers/deploy_keys_controller.rb
app/controllers/deploy_keys_controller.rb
+1
-8
app/controllers/hooks_controller.rb
app/controllers/hooks_controller.rb
+1
-5
app/controllers/issues_controller.rb
app/controllers/issues_controller.rb
+1
-7
app/controllers/labels_controller.rb
app/controllers/labels_controller.rb
+1
-7
app/controllers/merge_requests_controller.rb
app/controllers/merge_requests_controller.rb
+1
-6
app/controllers/milestones_controller.rb
app/controllers/milestones_controller.rb
+1
-6
app/controllers/notes_controller.rb
app/controllers/notes_controller.rb
+1
-5
app/controllers/project_controller.rb
app/controllers/project_controller.rb
+16
-0
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+2
-19
app/controllers/protected_branches_controller.rb
app/controllers/protected_branches_controller.rb
+1
-6
app/controllers/refs_controller.rb
app/controllers/refs_controller.rb
+1
-5
app/controllers/repositories_controller.rb
app/controllers/repositories_controller.rb
+1
-6
app/controllers/snippets_controller.rb
app/controllers/snippets_controller.rb
+1
-6
app/controllers/team_members_controller.rb
app/controllers/team_members_controller.rb
+1
-5
app/controllers/wikis_controller.rb
app/controllers/wikis_controller.rb
+1
-4
No files found.
app/controllers/application_controller.rb
View file @
078a8f0e
...
...
@@ -76,7 +76,7 @@ class ApplicationController < ActionController::Base
end
def
project
@project
||=
current_user
.
projects
.
find_by_code
(
params
[
:project_id
])
@project
||=
current_user
.
projects
.
find_by_code
(
params
[
:project_id
]
||
params
[
:id
]
)
@project
||
render_404
end
...
...
app/controllers/commits_controller.rb
View file @
078a8f0e
require
"base64"
class
CommitsController
<
ApplicationController
before_filter
:project
layout
"project"
class
CommitsController
<
ProjectController
# Authorize
before_filter
:add_project_abilities
before_filter
:authorize_read_project!
before_filter
:authorize_code_access!
before_filter
:require_non_empty_project
...
...
app/controllers/deploy_keys_controller.rb
View file @
078a8f0e
class
DeployKeysController
<
Application
Controller
class
DeployKeysController
<
Project
Controller
respond_to
:html
layout
"project"
before_filter
:project
# Authorize
before_filter
:add_project_abilities
before_filter
:authorize_admin_project!
def
project
@project
||=
Project
.
find_by_code
(
params
[
:project_id
])
end
def
index
@keys
=
@project
.
deploy_keys
.
all
end
...
...
app/controllers/hooks_controller.rb
View file @
078a8f0e
class
HooksController
<
ApplicationController
before_filter
:project
layout
"project"
class
HooksController
<
ProjectController
# Authorize
before_filter
:add_project_abilities
before_filter
:authorize_read_project!
before_filter
:authorize_admin_project!
,
only:
[
:new
,
:create
,
:destroy
]
...
...
app/controllers/issues_controller.rb
View file @
078a8f0e
class
IssuesController
<
ApplicationController
before_filter
:project
class
IssuesController
<
ProjectController
before_filter
:module_enabled
before_filter
:issue
,
only:
[
:edit
,
:update
,
:destroy
,
:show
]
helper_method
:issues_filter
layout
"project"
# Authorize
before_filter
:add_project_abilities
# Allow read any issue
before_filter
:authorize_read_issue!
...
...
app/controllers/labels_controller.rb
View file @
078a8f0e
class
LabelsController
<
ApplicationController
before_filter
:project
class
LabelsController
<
ProjectController
before_filter
:module_enabled
layout
"project"
# Authorize
before_filter
:add_project_abilities
# Allow read any issue
before_filter
:authorize_read_issue!
...
...
app/controllers/merge_requests_controller.rb
View file @
078a8f0e
class
MergeRequestsController
<
ApplicationController
before_filter
:project
class
MergeRequestsController
<
ProjectController
before_filter
:module_enabled
before_filter
:merge_request
,
only:
[
:edit
,
:update
,
:destroy
,
:show
,
:commits
,
:diffs
,
:automerge
,
:automerge_check
,
:raw
]
before_filter
:validates_merge_request
,
only:
[
:show
,
:diffs
,
:raw
]
before_filter
:define_show_vars
,
only:
[
:show
,
:diffs
]
layout
"project"
# Authorize
before_filter
:add_project_abilities
# Allow read any merge_request
before_filter
:authorize_read_merge_request!
...
...
app/controllers/milestones_controller.rb
View file @
078a8f0e
class
MilestonesController
<
ApplicationController
before_filter
:project
class
MilestonesController
<
ProjectController
before_filter
:module_enabled
before_filter
:milestone
,
only:
[
:edit
,
:update
,
:destroy
,
:show
]
layout
"project"
# Authorize
before_filter
:add_project_abilities
# Allow read any milestone
before_filter
:authorize_read_milestone!
...
...
app/controllers/notes_controller.rb
View file @
078a8f0e
class
NotesController
<
ApplicationController
before_filter
:project
class
NotesController
<
ProjectController
# Authorize
before_filter
:add_project_abilities
before_filter
:authorize_read_note!
before_filter
:authorize_write_note!
,
only:
[
:create
]
...
...
app/controllers/project_controller.rb
0 → 100644
View file @
078a8f0e
class
ProjectController
<
ApplicationController
before_filter
:project
# Authorize
before_filter
:add_project_abilities
layout
:determine_layout
protected
def
determine_layout
if
@project
&&
!
@project
.
new_record?
'project'
else
'application'
end
end
end
app/controllers/projects_controller.rb
View file @
078a8f0e
require
Rails
.
root
.
join
(
'lib'
,
'gitlab'
,
'graph_commit'
)
class
ProjectsController
<
ApplicationController
before_filter
:project
,
except:
[
:index
,
:new
,
:create
]
layout
:determine_layout
class
ProjectsController
<
ProjectController
skip_before_filter
:project
,
only:
[
:new
,
:create
]
# Authorize
before_filter
:add_project_abilities
before_filter
:authorize_read_project!
,
except:
[
:index
,
:new
,
:create
]
before_filter
:authorize_admin_project!
,
only:
[
:edit
,
:update
,
:destroy
]
before_filter
:require_non_empty_project
,
only:
[
:blob
,
:tree
,
:graph
]
...
...
@@ -93,19 +91,4 @@ class ProjectsController < ApplicationController
format
.
html
{
redirect_to
root_path
}
end
end
protected
def
project
@project
||=
Project
.
find_by_code
(
params
[
:id
])
@project
||
render_404
end
def
determine_layout
if
@project
&&
!
@project
.
new_record?
"project"
else
"application"
end
end
end
app/controllers/protected_branches_controller.rb
View file @
078a8f0e
class
ProtectedBranchesController
<
ApplicationController
before_filter
:project
class
ProtectedBranchesController
<
ProjectController
# Authorize
before_filter
:add_project_abilities
before_filter
:authorize_read_project!
before_filter
:require_non_empty_project
before_filter
:authorize_admin_project!
,
only:
[
:destroy
,
:create
]
before_filter
:render_full_content
layout
"project"
def
index
@branches
=
@project
.
protected_branches
.
all
@protected_branch
=
@project
.
protected_branches
.
new
...
...
app/controllers/refs_controller.rb
View file @
078a8f0e
require
'github/markup'
class
RefsController
<
Application
Controller
class
RefsController
<
Project
Controller
include
Gitlab
::
Encode
before_filter
:project
# Authorize
before_filter
:add_project_abilities
before_filter
:authorize_read_project!
before_filter
:authorize_code_access!
before_filter
:require_non_empty_project
...
...
@@ -14,8 +12,6 @@ class RefsController < ApplicationController
before_filter
:define_tree_vars
,
only:
[
:tree
,
:blob
,
:blame
,
:logs_tree
]
before_filter
:render_full_content
layout
"project"
def
switch
respond_to
do
|
format
|
format
.
html
do
...
...
app/controllers/repositories_controller.rb
View file @
078a8f0e
class
RepositoriesController
<
ApplicationController
before_filter
:project
class
RepositoriesController
<
ProjectController
# Authorize
before_filter
:add_project_abilities
before_filter
:authorize_read_project!
before_filter
:authorize_code_access!
before_filter
:require_non_empty_project
before_filter
:render_full_content
layout
"project"
def
show
@activities
=
@project
.
commits_with_refs
(
20
)
end
...
...
app/controllers/snippets_controller.rb
View file @
078a8f0e
class
SnippetsController
<
ApplicationController
before_filter
:project
class
SnippetsController
<
ProjectController
before_filter
:snippet
,
only:
[
:show
,
:edit
,
:destroy
,
:update
,
:raw
]
layout
"project"
# Authorize
before_filter
:add_project_abilities
# Allow read any snippet
before_filter
:authorize_read_snippet!
...
...
app/controllers/team_members_controller.rb
View file @
078a8f0e
class
TeamMembersController
<
ApplicationController
before_filter
:project
layout
"project"
class
TeamMembersController
<
ProjectController
# Authorize
before_filter
:add_project_abilities
before_filter
:authorize_read_project!
before_filter
:authorize_admin_project!
,
except:
[
:index
,
:show
]
...
...
app/controllers/wikis_controller.rb
View file @
078a8f0e
class
WikisController
<
ApplicationController
before_filter
:project
before_filter
:add_project_abilities
class
WikisController
<
ProjectController
before_filter
:authorize_read_wiki!
before_filter
:authorize_write_wiki!
,
only:
[
:edit
,
:create
,
:history
]
before_filter
:authorize_admin_wiki!
,
only: :destroy
layout
"project"
def
pages
@wikis
=
@project
.
wikis
.
group
(
:slug
).
order
(
"created_at"
)
...
...
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